Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlElement


    private static QName getXmlElementRefOrElementQName(Class<?> jaxbClass, Field field) throws NoSuchFieldException {
        XmlElementRef xmlElementRef = (XmlElementRef)getAnnotation(field, XmlElementRef.class);
        if (xmlElementRef != null) {
            return new QName(xmlElementRef.namespace(), xmlElementRef.name());
        }
        XmlElement xmlElement = (XmlElement)getAnnotation(field, XmlElement.class);

        // If XmlElement does not exist, default to using the field name
        if (xmlElement == null || xmlElement.name().equals("##default")) {
            return new QName("", field.getName());
        }
        return new QName(xmlElement.namespace(), xmlElement.name());
    }
View Full Code Here


            } else if (ann instanceof XmlList) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
                av0.visitEnd();
            } else if (ann instanceof XmlElement) {
                addedEl = true;  
                XmlElement el = (XmlElement)ann;
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
                av0.visit("name", el.name());
                av0.visit("nillable", el.nillable());
                av0.visit("required", el.required());
                av0.visit("namespace", el.namespace());
                av0.visit("defaultValue", el.defaultValue());
                av0.visit("type", el.type());
                av0.visitEnd();
            } else if (ann instanceof XmlElementWrapper) {
                XmlElementWrapper el = (XmlElementWrapper)ann;
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElementWrapper;", true);
                av0.visit("name", el.name());
                av0.visit("nillable", el.nillable());
                av0.visit("required", el.required());
                av0.visit("namespace", el.namespace());
                av0.visitEnd();
            }
        }
        return addedEl;
    }
View Full Code Here

    private static QName getXmlElementRefOrElementQName(Class<?> jaxbClass, Field field) throws NoSuchFieldException {
        XmlElementRef xmlElementRef = (XmlElementRef)getAnnotation(field, XmlElementRef.class);
        if (xmlElementRef != null) {
            return new QName(xmlElementRef.namespace(), xmlElementRef.name());
        }
        XmlElement xmlElement = (XmlElement)getAnnotation(field, XmlElement.class);

        // If XmlElement does not exist, default to using the field name
        if (xmlElement == null || xmlElement.name().equals("##default")) {
            return new QName("", field.getName());
        }
        return new QName(xmlElement.namespace(), xmlElement.name());
    }
View Full Code Here

                jaxbMethods.add(null);
            }

            if (elField != null) {
                // JAXB Type get XmlElement Annotation
                XmlElement el = elField.getAnnotation(XmlElement.class);
                if (el != null
                    && (partName.equals(el.name())
                        || "##default".equals(el.name()))) {
                    elField.setAccessible(true);
                    fields.add(elField);
                } else {
                    if (getMethod == null && setMethod == null) {
                        if (el != null) {
                            LOG.warning("Could not create accessor for property " + partName
                                        + " of type " + wrapperType.getName() + " as the @XmlElement "
                                        + "defines the name as " + el.name());
                        } else {
                            LOG.warning("Could not create accessor for property " + partName
                                        + " of type " + wrapperType.getName());
                        }
                    }
View Full Code Here

    }

    private static Field getElField(String partName, Class<?> wrapperType) {
        String fieldName = JAXBUtils.nameToIdentifier(partName, JAXBUtils.IdentifierType.VARIABLE);
        for (Field field : wrapperType.getDeclaredFields()) {
            XmlElement el = field.getAnnotation(XmlElement.class);
            if (el != null
                && partName.equals(el.name())) {
                return field;
            }
            if (field.getName().equals(fieldName)) {
                return field;
            }
View Full Code Here

                jaxbMethods.add(null);
            }

            if (elField != null) {
                // JAXB Type get XmlElement Annotation
                XmlElement el = elField.getAnnotation(XmlElement.class);
                if (el != null
                    && (partName.equals(el.name())
                        || "##default".equals(el.name()))) {
                    elField.setAccessible(true);
                    fields.add(elField);
                } else {
                    if (getMethod == null && setMethod == null) {
                        if (el != null) {
                            LOG.warning("Could not create accessor for property " + partName
                                        + " of type " + wrapperType.getName() + " as the @XmlElement "
                                        + "defines the name as " + el.name());
                        } else {
                            LOG.warning("Could not create accessor for property " + partName
                                        + " of type " + wrapperType.getName());
                        }
                    }
View Full Code Here

    }

    private static Field getElField(String partName, Class<?> wrapperType) {
        String fieldName = JAXBUtils.nameToIdentifier(partName, JAXBUtils.IdentifierType.VARIABLE);
        for (Field field : wrapperType.getDeclaredFields()) {
            XmlElement el = field.getAnnotation(XmlElement.class);
            if (el != null
                && partName.equals(el.name())) {
                return field;
            }
            if (field.getName().equals(fieldName)) {
                return field;
            }
View Full Code Here

    }

    private Class<?> getConcreteTypeFromXmlElementAnno(Class<?> type, Annotation[] annotations) {
        Class<?> ret = xmlElementConcreteClassCache.get(type);
        if (ret == null) {
            XmlElement xmlElement = getXmlElementAnno(type, annotations);
            if (xmlElement != null) {
                Type xmlElementType = xmlElement.type();
                if (xmlElementType != null) {
                    ret = (Class<?>)xmlElementType;
                }
            }
            if (ret == null)
View Full Code Here

     * @param type
     * @param annotations
     * @return
     */
    private XmlElement getXmlElementAnno(Type type, Annotation[] annotations) {
        XmlElement xmlElement = null;
        for (int i = 0; (annotations != null) && i < annotations.length; i++) {
            if (annotations[i].annotationType() == XmlElement.class) {
                xmlElement = (XmlElement)annotations[i];
                break;
            }
View Full Code Here

            } else if (ann instanceof XmlList) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
                av0.visitEnd();
            } else if (ann instanceof XmlElement) {
                addedEl = true;  
                XmlElement el = (XmlElement)ann;
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
                if ("##default".equals(el.name())) {
                    av0.visit("name", name);
                } else {
                    av0.visit("name", el.name());
                }
                av0.visit("nillable", el.nillable());
                av0.visit("required", el.required());
                av0.visit("namespace", el.namespace());
                av0.visit("defaultValue", el.defaultValue());
                if (el.type() != XmlElement.DEFAULT.class) {
                    av0.visit("type", el.type());                   
                }
                av0.visitEnd();
            } else if (ann instanceof XmlElementWrapper) {
                XmlElementWrapper el = (XmlElementWrapper)ann;
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElementWrapper;", true);
                av0.visit("name", el.name());
                av0.visit("nillable", el.nillable());
                av0.visit("required", el.required());
                av0.visit("namespace", el.namespace());
                av0.visitEnd();
            }
        }
        return addedEl;
    }
View Full Code Here

TOP

Related Classes of javax.xml.bind.annotation.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.