javax.xml.bind.annotation.XmlAttachmentRef Java Examples

The following examples show how to use javax.xml.bind.annotation.XmlAttachmentRef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #2
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Map<Class<?>, Boolean> getJaxbAnnoMap(MessagePartInfo mpi) {
    Map<Class<?>, Boolean> map = new ConcurrentHashMap<>(4, 0.75f, 1);
    Annotation[] anns = getMethodParameterAnnotations(mpi);

    if (anns != null) {
        for (Annotation anno : anns) {
            if (anno instanceof XmlList) {
                map.put(XmlList.class, true);
            }
            if (anno instanceof XmlAttachmentRef) {
                map.put(XmlAttachmentRef.class, true);
            }
            if (anno instanceof XmlJavaTypeAdapter) {
                map.put(XmlJavaTypeAdapter.class, true);
            }
            if (anno instanceof XmlElementWrapper) {
                map.put(XmlElementWrapper.class, true);
            }
        }
    }
    return map;
}
 
Example #3
Source File: WrapperClassGenerator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private List<Annotation> getJaxbAnnos(MessagePartInfo mpi) {
    List<Annotation> list = new java.util.concurrent.CopyOnWriteArrayList<>();
    Annotation[] anns = getMethodParameterAnnotations(mpi);
    if (anns != null) {
        for (Annotation anno : anns) {
            if (anno.annotationType() == XmlList.class
                || anno.annotationType() == XmlAttachmentRef.class
                || anno.annotationType() == XmlJavaTypeAdapter.class
                || anno.annotationType() == XmlMimeType.class
                || anno.annotationType() == XmlElement.class
                || anno.annotationType() == XmlElementWrapper.class) {
                list.add(anno);
            }
        }
    }
    return list;
}
 
Example #4
Source File: WrapperUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<Annotation> getJaxbAnnotations(Method method, int idx) {
    List<Annotation> jaxbAnnotation = new ArrayList<>();
    Annotation[][] anns = method.getParameterAnnotations();
    for (int i = 0; i < method.getParameterTypes().length; i++) {
        if (i == idx) {
            for (Annotation ann : anns[i]) {
                if (ann.annotationType() == XmlAttachmentRef.class
                    || ann.annotationType() == XmlMimeType.class
                    || ann.annotationType() == XmlJavaTypeAdapter.class
                    || ann.annotationType() == XmlList.class
                    || ann.annotationType() == XmlElement.class) {
                    jaxbAnnotation.add(ann);
                }
            }
        }
    }
    return jaxbAnnotation;
}
 
Example #5
Source File: WrapperUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<Annotation> getJaxbAnnotations(Method method) {
    List<Annotation> jaxbAnnotation = new ArrayList<>();
    Annotation ann = method.getAnnotation(XmlAttachmentRef.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlMimeType.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlJavaTypeAdapter.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlList.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    return jaxbAnnotation;
}
 
Example #6
Source File: TypeAndAnnotationImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #7
Source File: TypeAndAnnotationImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #8
Source File: TypeAndAnnotationImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #9
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #10
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #11
Source File: TypeAndAnnotationImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #12
Source File: TypeAndAnnotationImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #13
Source File: ObjectFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
@XmlElementDecl(
   namespace = "urn:be:fgov:ehealth:commons:enc:v2",
   name = "URI"
)
@XmlAttachmentRef
public JAXBElement<DataHandler> createURI(DataHandler value) {
   return new JAXBElement(_URI_QNAME, DataHandler.class, (Class)null, value);
}
 
Example #14
Source File: ObjectFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
@XmlElementDecl(
   namespace = "urn:be:fgov:ehealth:commons:enc:v2",
   name = "URI"
)
@XmlAttachmentRef
public JAXBElement<DataHandler> createURI(DataHandler value) {
   return new JAXBElement(_URI_QNAME, DataHandler.class, (Class)null, value);
}
 
Example #15
Source File: BeanGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #16
Source File: ObjectFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
@XmlElementDecl(
   namespace = "urn:be:fgov:ehealth:commons:enc:v2",
   name = "URI"
)
@XmlAttachmentRef
public JAXBElement<DataHandler> createURI(DataHandler value) {
   return new JAXBElement(_URI_QNAME, DataHandler.class, (Class)null, value);
}
 
Example #17
Source File: BeanGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #18
Source File: ObjectFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
@XmlElementDecl(
   namespace = "urn:be:fgov:ehealth:commons:enc:v2",
   name = "URI"
)
@XmlAttachmentRef
public JAXBElement<DataHandler> createURI(DataHandler value) {
   return new JAXBElement(_URI_QNAME, DataHandler.class, (Class)null, value);
}
 
Example #19
Source File: BeanGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #20
Source File: ObjectFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
@XmlElementDecl(
   namespace = "urn:be:fgov:ehealth:commons:enc:v2",
   name = "URI"
)
@XmlAttachmentRef
public JAXBElement<DataHandler> createURI(DataHandler value) {
   return new JAXBElement(_URI_QNAME, DataHandler.class, (Class)null, value);
}
 
Example #21
Source File: BeanGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #22
Source File: JAXBDataBase.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<Annotation> extractJAXBAnnotations(Annotation[] anns) {
    List<Annotation> annoList = null;
    if (anns != null) {
        for (Annotation ann : anns) {
            if (ann instanceof XmlList || ann instanceof XmlAttachmentRef
                || ann instanceof XmlJavaTypeAdapter) {
                if (annoList == null) {
                    annoList = new ArrayList<>();
                }
                annoList.add(ann);
            }
        }
    }
    return annoList;
}
 
Example #23
Source File: BeanGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #24
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #25
Source File: BeanGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #26
Source File: BeanGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #27
Source File: PropertyInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected PropertyInfoImpl(ClassInfoImpl<T,C,F,M> parent, PropertySeed<T,C,F,M> spi) {
    this.seed = spi;
    this.parent = parent;

    if(parent==null)
        /*
            Various people reported a bug where this parameter is somehow null.
            In an attempt to catch the error better, let's do an explicit check here.

            http://forums.java.net/jive/thread.jspa?threadID=18479
            http://forums.java.net/jive/thread.jspa?messageID=165946
         */
        throw new AssertionError();

    MimeType mt = Util.calcExpectedMediaType(seed,parent.builder);
    if(mt!=null && !kind().canHaveXmlMimeType) {
        parent.builder.reportError(new IllegalAnnotationException(
            Messages.ILLEGAL_ANNOTATION.format(XmlMimeType.class.getName()),
            seed.readAnnotation(XmlMimeType.class)
        ));
        mt = null;
    }
    this.expectedMimeType = mt;
    this.inlineBinary = seed.hasAnnotation(XmlInlineBinaryData.class);

    T t = seed.getRawType();

    // check if there's an adapter applicable to the whole property
    XmlJavaTypeAdapter xjta = getApplicableAdapter(t);
    if(xjta!=null) {
        isCollection = false;
        adapter = new Adapter<T,C>(xjta,reader(),nav());
    } else {
        // check if the adapter is applicable to the individual item in the property

        this.isCollection = nav().isSubClassOf(t, nav().ref(Collection.class))
                         || nav().isArrayButNotByteArray(t);

        xjta = getApplicableAdapter(getIndividualType());
        if(xjta==null) {
            // ugly ugly hack, but we implement swaRef as adapter
            XmlAttachmentRef xsa = seed.readAnnotation(XmlAttachmentRef.class);
            if(xsa!=null) {
                parent.builder.hasSwaRef = true;
                adapter = new Adapter<T,C>(nav().asDecl(SwaRefAdapter.class),nav());
            } else {
                adapter = null;

                // if this field has adapter annotation but not applicable,
                // that must be an error of the user
                xjta = seed.readAnnotation(XmlJavaTypeAdapter.class);
                if(xjta!=null) {
                    T ad = reader().getClassValue(xjta,"value");
                    parent.builder.reportError(new IllegalAnnotationException(
                        Messages.UNMATCHABLE_ADAPTER.format(
                                nav().getTypeName(ad), nav().getTypeName(t)),
                        xjta
                    ));
                }
            }
        } else {
            adapter = new Adapter<T,C>(xjta,reader(),nav());
        }
    }

    this.id = calcId();
    this.schemaType = Util.calcSchemaType(reader(),seed,parent.clazz,
            getIndividualType(),this);
}
 
Example #28
Source File: AddNumbers.java    From cxf with Apache License 2.0 4 votes vote down vote up
@WebMethod
int addNumbers(@WebParam
               @XmlAttachmentRef
               DataHandler body);
 
Example #29
Source File: XopType.java    From cxf with Apache License 2.0 4 votes vote down vote up
@XmlAttachmentRef
@XmlElement(required = true)
@XmlMimeType("application/octet-stream")
public DataHandler getAttachInfoRef() {
    return attachInfoRef;
}
 
Example #30
Source File: PropertyInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected PropertyInfoImpl(ClassInfoImpl<T,C,F,M> parent, PropertySeed<T,C,F,M> spi) {
    this.seed = spi;
    this.parent = parent;

    if(parent==null)
        /*
            Various people reported a bug where this parameter is somehow null.
            In an attempt to catch the error better, let's do an explicit check here.

            http://forums.java.net/jive/thread.jspa?threadID=18479
            http://forums.java.net/jive/thread.jspa?messageID=165946
         */
        throw new AssertionError();

    MimeType mt = Util.calcExpectedMediaType(seed,parent.builder);
    if(mt!=null && !kind().canHaveXmlMimeType) {
        parent.builder.reportError(new IllegalAnnotationException(
            Messages.ILLEGAL_ANNOTATION.format(XmlMimeType.class.getName()),
            seed.readAnnotation(XmlMimeType.class)
        ));
        mt = null;
    }
    this.expectedMimeType = mt;
    this.inlineBinary = seed.hasAnnotation(XmlInlineBinaryData.class);

    T t = seed.getRawType();

    // check if there's an adapter applicable to the whole property
    XmlJavaTypeAdapter xjta = getApplicableAdapter(t);
    if(xjta!=null) {
        isCollection = false;
        adapter = new Adapter<T,C>(xjta,reader(),nav());
    } else {
        // check if the adapter is applicable to the individual item in the property

        this.isCollection = nav().isSubClassOf(t, nav().ref(Collection.class))
                         || nav().isArrayButNotByteArray(t);

        xjta = getApplicableAdapter(getIndividualType());
        if(xjta==null) {
            // ugly ugly hack, but we implement swaRef as adapter
            XmlAttachmentRef xsa = seed.readAnnotation(XmlAttachmentRef.class);
            if(xsa!=null) {
                parent.builder.hasSwaRef = true;
                adapter = new Adapter<T,C>(nav().asDecl(SwaRefAdapter.class),nav());
            } else {
                adapter = null;

                // if this field has adapter annotation but not applicable,
                // that must be an error of the user
                xjta = seed.readAnnotation(XmlJavaTypeAdapter.class);
                if(xjta!=null) {
                    T ad = reader().getClassValue(xjta,"value");
                    parent.builder.reportError(new IllegalAnnotationException(
                        Messages.UNMATCHABLE_ADAPTER.format(
                                nav().getTypeName(ad), nav().getTypeName(t)),
                        xjta
                    ));
                }
            }
        } else {
            adapter = new Adapter<T,C>(xjta,reader(),nav());
        }
    }

    this.id = calcId();
    this.schemaType = Util.calcSchemaType(reader(),seed,parent.clazz,
            getIndividualType(),this);
}