Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlElement


    }

    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


     * @return
     * @throws NoSuchFieldException
     */
    private static String getXmlElementName(Class jaxbClass, Field field)
            throws NoSuchFieldException {
        XmlElement xmlElement = field.getAnnotation(XmlElement.class);

        // If XmlElement does not exist, default to using the field name
        if (xmlElement == null ||
                xmlElement.name().equals("##default")) {
            return field.getName();
        }
        return 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())) {
                    elField.setAccessible(true);
                    fields.add(elField);
                } else {
                    fields.add(null);
                }
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 String getFieldName(ParameterImpl p, Class wrpCls) {
        for (Field f : wrpCls.getFields()) {
            XmlElement xe = f.getAnnotation(XmlElement.class);
            if (xe != null && p.getName().getLocalPart().equals(xe.name())) {
                return f.getName();
            } else {
                if (p.getName().getLocalPart().equals(f.getName())) {
                    return f.getName();
                }
View Full Code Here

    private static Element findXmlElement(Map<String, Object> properties) {
        return (Element) properties.get(OXM_XML_ELEMENT);
    }

    private static TypeInfo repeatedWrapee(TypeInfo e, Element xmlAnn) {
        XmlElement xe = getAnnotation(e, XmlElement.class);
        if (xe != null) {
            e.type = xe.type();
        }
        if (xmlAnn != null) {
            String typeAttr = xmlAnn.getAttribute("type");
            if (typeAttr != null) {
                try {
View Full Code Here

            String fieldName = partName;
            if (JAXBUtils.isJavaKeyword(partName)) {
                fieldName = JAXBUtils.nameToIdentifier(partName, JAXBUtils.IdentifierType.VARIABLE);
            }

            XmlElement el = null;
            for (Field field : wrapperType.getClass().getDeclaredFields()) {

                if (field.getName().equals(fieldName)) {
                    // JAXB Type get XmlElement Annotation
                    el = field.getAnnotation(XmlElement.class);
                    // assert el != null;
                }
            }

            if (part == null) {
                if (el != null && !el.nillable()) {
                    throw new IllegalArgumentException("null value for field not permitted.");
                }
                return;
            }
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())) {
                    elField.setAccessible(true);
                    fields.add(elField);
                } else {
                    fields.add(null);
                }
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

                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

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.