Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlRootElement


                if(jsonAnnoation!=null && jsonAnnoation.value()!=null) {
                    typeToId.put(c, jsonAnnoation.value());
                    idToType.put(jsonAnnoation.value(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                    idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                } else {
                    XmlRootElement xmlAnnoation = c.getAnnotation(XmlRootElement.class);
                    if(xmlAnnoation!=null && xmlAnnoation.name()!=null) {
                        typeToId.put(c, xmlAnnoation.name());
                        idToType.put(xmlAnnoation.name(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                        idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                    }
                }
            }
        }
View Full Code Here


     *         root element
     */
    public static QName getXmlRootElementQName(Class<?> clazz) {

        // See if the object represents a root element
        XmlRootElement root = (XmlRootElement)getAnnotation(clazz, XmlRootElement.class);
        if (root == null) {
            return null;
        }

        String name = root.name();
        String namespace = root.namespace();

        // The name may need to be defaulted
        if (name == null || name.length() == 0 || name.equals("##default")) {
            name = getSimpleName(clazz.getCanonicalName());
        }
View Full Code Here

        if (type != null) {
            String typeNamespace = type.namespace();
            String typeName = type.name();

            if (typeNamespace.equals("##default") && typeName.equals("")) {
                XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
                if (rootElement != null) {
                    namespace = rootElement.namespace();
                } else {
                    // FIXME: The namespace should be from the referencing
                    // property
                    namespace = null;
                }
View Full Code Here

            }
        }

        QName elementQName = null;
        QName typeQName = null;
        XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
        if (rootElement != null) {
            String elementName = rootElement.name();
            String elementNamespace = rootElement.namespace();
            if (elementNamespace.equals("##default")) {
                elementNamespace = namespace;
            }
            if (elementName.equals("##default")) {
                elementName = jaxbDecapitalize(javaType.getSimpleName());
View Full Code Here

        return xmlSchemaCollection;
    }

    private QName getJaxbQName(JAXBContextProxy jaxbProxy, Class<?> type, Map<Class<?>, QName> clsMap) {

        XmlRootElement root = type.getAnnotation(XmlRootElement.class);
        if (root != null) {
            QName qname = getQNameFromParts(root.name(), root.namespace(), type, clsMap);
            if (qname != null) {
                return qname;
            }
            String ns = JAXBUtils.getPackageNamespace(type);
            if (ns != null) {
                return getQNameFromParts(root.name(), ns, type, clsMap);
            } else {
                return null;
            }
        }
View Full Code Here

        }
        return null;
    }

    protected static QName getJaxbQName(Class<?> cls) {
        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
        if (root != null) {
            String namespace = getNamespace(root.namespace());
            String name = getLocalName(root.name(), cls.getSimpleName());
            return new QName(namespace, name);
        }
        return null;
    }
View Full Code Here

       
        if (cls == JAXBElement.class) {
            return object != null ? ((JAXBElement)object).getName() : null;
        }
       
        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
        if (root != null) {
            return getQNameFromNamespaceAndName(root.namespace(), root.name(), cls, pluralName);
        } else if (cls.getAnnotation(XmlType.class) != null) {
            XmlType xmlType = cls.getAnnotation(XmlType.class);
            return getQNameFromNamespaceAndName(xmlType.namespace(), xmlType.name(), cls, pluralName);
        } else {
            return new QName(getPackageNamespace(cls), cls.getSimpleName());
View Full Code Here

        return xmlSchemaCollection;
    }

    private QName getJaxbQName(JAXBContextProxy jaxbProxy, Class<?> type, Map<Class<?>, QName> clsMap) {

        XmlRootElement root = type.getAnnotation(XmlRootElement.class);
        if (root != null) {
            QName qname = getQNameFromParts(root.name(), root.namespace(), clsMap);
            if (qname != null) {
                return qname;
            }
            String ns = JAXBUtils.getPackageNamespace(type);
            if (ns != null) {
                return getQNameFromParts(root.name(), ns, clsMap);
            } else {
                return null;
            }
        }
View Full Code Here

    protected void doStop() throws Exception {
        contexts.clear();
    }

    protected <T> boolean isJaxbType(Class<T> type) {
        XmlRootElement element = type.getAnnotation(XmlRootElement.class);
        return element != null;
    }
View Full Code Here

     *  in an incoming stream amd all we have is the type information)
     *  TODO: work out with JAXB guys a better way of doing it,
     *        probably we could take it from an existing JAXBContext?
     */
    public static String getRootElementName(Class<Object> clazz) {
        XmlRootElement e = clazz.getAnnotation(XmlRootElement.class);
        if (e == null) {
            return getVariableName(clazz.getSimpleName());
        }
        if ("##default".equals(e.name())) {
            return getVariableName(clazz.getSimpleName());
        } else {
            return e.name();
        }
    }
View Full Code Here

TOP

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

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.