Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlAttribute


            } else {
                LOG.warning("Schema associated with " + namespace + " is null");
            }
            for (Field f : ReflectionUtil.getDeclaredFields(cls)) {
                if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                    XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                    if (at == null) {
                        QName fname = new QName(namespace, f.getName());
                        ReflectionUtil.setAccessible(f);
                        if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                            writeArrayObject(marshaller, writer, fname, f.get(elValue));
View Full Code Here


            XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
            if (elem != null) {
                ns = elem.namespace();
            }
            if (ns == null || MARKER_FOR_DEFAULT.equals(ns)) {
                XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
                if (attr != null) {
                    ns = attr.namespace();
                }
            }
        }
        // JAXB uses marker for "not defined"
        if (MARKER_FOR_DEFAULT.equals(ns)) {
View Full Code Here

     * Caller is likely to default to considering things as elements.
     */
    @Override
    public Boolean isOutputAsAttribute(Annotated ann)
    {
        XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
        if (attr != null) {
            return Boolean.TRUE;
        }
        XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
        if (elem != null) {
View Full Code Here

            XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
            if (elem != null) {
                ns = elem.namespace();
            }
            if (ns == null || MARKER_FOR_DEFAULT.equals(ns)) {
                XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
                if (attr != null) {
                    ns = attr.namespace();
                }
            }
        }
        // JAXB uses marker for "not defined"
        if (MARKER_FOR_DEFAULT.equals(ns)) {
View Full Code Here

     * Caller is likely to default to considering things as elements.
     */
    @Override
    public Boolean isOutputAsAttribute(Annotated ann)
    {
        XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
        if (attr != null) {
            return Boolean.TRUE;
        }
        XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
        if (elem != null) {
View Full Code Here

            } else {
                LOG.warning("Schema associated with " + namespace + " is null");
            }
            for (Field f : ReflectionUtil.getDeclaredFields(cls)) {
                if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                    XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                    if (at == null) {
                        QName fname = new QName(namespace, f.getName());
                        ReflectionUtil.setAccessible(f);
                        if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                            writeArrayObject(marshaller, writer, fname, f.get(elValue));
View Full Code Here

                }
            }
            List<Member> combinedMembers = new ArrayList<Member>();

            for (Field f : Utils.getFields(cls, accessType)) {
                XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                if (at == null) {
                    combinedMembers.add(f);
                } else {
                    QName fname = new QName(attNs, StringUtils.isEmpty(at.name()) ? f.getName() : at.name());
                    ReflectionUtil.setAccessible(f);
                    Object o = Utils.getFieldValue(f, elValue);
                    Document doc = DOMUtils.newDocument();
                    writeObject(marshaller, doc, newJAXBElement(fname, String.class, o));
                   
                    if (attNs != null) {
                        writer.writeAttribute(attNs, fname.getLocalPart(),
                                              DOMUtils.getAllContent(doc.getDocumentElement()));
                    } else {
                        writer.writeAttribute(fname.getLocalPart(), DOMUtils.getAllContent(doc.getDocumentElement()));
                    }
                }
            }
            for (Method m : Utils.getGetters(cls, accessType)) {
                if (!m.isAnnotationPresent(XmlAttribute.class)) {
                    combinedMembers.add(m);
                } else {
                    int idx = m.getName().startsWith("get") ? 3 : 2;
                    String name = m.getName().substring(idx);
                    name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
                    XmlAttribute at = m.getAnnotation(XmlAttribute.class);
                    QName mname = new QName(namespace, StringUtils.isEmpty(at.name()) ? name : at.name());
                    Document doc = DOMUtils.newDocument();
                    Object o = Utils.getMethodValue(m, elValue);
                    writeObject(marshaller, doc, newJAXBElement(mname, String.class, o));
                    if (attNs != null) {
                        writer.writeAttribute(attNs, mname.getLocalPart(),
View Full Code Here

                }
            } else {
                LOG.warning("Schema associated with " + namespace + " is null");
            }
            for (Field f : Utils.getFields(cls, accessType)) {
                XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                if (at == null) {
                    QName fname = new QName(namespace, f.getName());
                    ReflectionUtil.setAccessible(f);
                    if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                        writeArrayObject(marshaller, writer, fname, f.get(elValue));
View Full Code Here

            } else {
                LOG.warning("Schema associated with " + namespace + " is null");
            }
            for (Field f : ReflectionUtil.getDeclaredFields(cls)) {
                if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                    XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                    if (at == null) {
                        QName fname = new QName(namespace, f.getName());
                        ReflectionUtil.setAccessible(f);
                        if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                            writeArrayObject(marshaller, writer, fname, f.get(elValue));
View Full Code Here

                }
            }
            List<Member> combinedMembers = new ArrayList<Member>();

            for (Field f : Utils.getFields(cls, accessType)) {
                XmlAttribute at = f.getAnnotation(XmlAttribute.class);
                if (at == null) {
                    combinedMembers.add(f);
                } else {
                    QName fname = new QName(attNs, StringUtils.isEmpty(at.name()) ? f.getName() : at.name());
                    ReflectionUtil.setAccessible(f);
                    Object o = Utils.getFieldValue(f, elValue);
                    Document doc = DOMUtils.newDocument();
                    writeObject(marshaller, doc, newJAXBElement(fname, String.class, o));
                   
                    if (attNs != null) {
                        writer.writeAttribute(attNs, fname.getLocalPart(),
                                              DOMUtils.getAllContent(doc.getDocumentElement()));
                    } else {
                        writer.writeAttribute(fname.getLocalPart(), DOMUtils.getAllContent(doc.getDocumentElement()));
                    }
                }
            }
            for (Method m : Utils.getGetters(cls, accessType)) {
                if (!m.isAnnotationPresent(XmlAttribute.class)) {
                    combinedMembers.add(m);
                } else {
                    int idx = m.getName().startsWith("get") ? 3 : 2;
                    String name = m.getName().substring(idx);
                    name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
                    XmlAttribute at = m.getAnnotation(XmlAttribute.class);
                    QName mname = new QName(namespace, StringUtils.isEmpty(at.name()) ? name : at.name());
                    Document doc = DOMUtils.newDocument();
                    Object o = Utils.getMethodValue(m, elValue);
                    writeObject(marshaller, doc, newJAXBElement(mname, String.class, o));
                    if (attNs != null) {
                        writer.writeAttribute(attNs, mname.getLocalPart(),
View Full Code Here

TOP

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

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.