Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlRootElement


  @Override public JavaXMLBean createElement(Class<?> bean) throws JAXBException {
    String name = null;
    String namespace = "";
    boolean rootElement = false;
   
    XmlRootElement root = bean.getAnnotation(XmlRootElement.class);
   
    if (root != null) {
      name = root.name();
      namespace = !root.namespace().equals("##default") ? root.namespace() : "";
      rootElement = true;
    } else {
      XmlElement element = bean.getAnnotation(XmlElement.class);
      if (element != null) {
        name = element.name();
View Full Code Here


        } catch (ClassNotFoundException ex) {
            //ignore
        }       
        if (!found) {
            //not in object factory or no object factory, try other annotations
            XmlRootElement elAnnot = cls.getAnnotation(XmlRootElement.class);
            if (elAnnot != null) {
                String name = elAnnot.name();
                String ns = elAnnot.namespace();
                if (StringUtils.isEmpty(ns)
                    || "##default".equals(ns)) {
                    XmlSchema schema = null;
                    if (cls.getPackage() != null) {
                        schema = cls.getPackage().getAnnotation(XmlSchema.class);
View Full Code Here

        String postfix = "";
        while (cls.isArray()) {
            cls = cls.getComponentType();
            postfix += "Array";
        }
        XmlRootElement xre = cls.getAnnotation(XmlRootElement.class);
        String name = xre == null ? "##default" : xre.name();
        String namespace = xre == null ? "##default" : xre.namespace();
        if ("##default".equals(name)) {
            name = java.beans.Introspector.decapitalize(cls.getSimpleName());
        }
        if ("##default".equals(namespace) && cls.getPackage() != null) {
            XmlSchema sc = cls.getPackage().getAnnotation(XmlSchema.class);
View Full Code Here

//      Thread.sleep(1000000);
     
      assertNotNull(packet);
      assertTrue( packet instanceof OADR2IQ );
      Object payload1 = ((OADR2IQ)packet).getOADRPayload();
      XmlRootElement annotation = payload1.getClass().getAnnotation( XmlRootElement.class );
      assertEquals( OADR2_XMLNS, annotation.namespace() );
      assertEquals( "oadrDistributeEvent", annotation.name() );
        assertTrue( payload1 instanceof OadrDistributeEvent );
     
        OADR2PacketExtension extension = (OADR2PacketExtension)packet.getExtension(OADR2_XMLNS);
      assertEquals("oadrDistributeEvent", extension.getElementName());
      assertEquals(OADR2_XMLNS, extension.getNamespace());
View Full Code Here

    XmlType xmlType = clazz.getAnnotation(XmlType.class);
    if (xmlType != null) {
      elementName = xmlType.name();
      namespace = xmlType.namespace();
    } else {
      XmlRootElement xmlRootElement = clazz.getAnnotation(XmlRootElement.class);
      if (xmlRootElement != null) {
        elementName = xmlRootElement.name();
        namespace = xmlRootElement.namespace();
      }
    }

    if ("##default".equals(elementName)) {
      elementName = StringUtils.uncapitalize(clazz.getSimpleName());
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

                if(jsonAnnoation!=null && jsonAnnoation.value()!=null) {
                    typeToId.put(c, jsonAnnoation.value());
                    idToType.put(jsonAnnoation.value(), TypeFactory.specialize(baseType,  c));
                    idToType.put(c.getName(), TypeFactory.specialize(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.specialize(baseType,  c));
                        idToType.put(c.getName(), TypeFactory.specialize(baseType,  c));
                    }
                }
            }
        }
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

            throw new RuntimeCamelException(e);
        }
    }

    protected <T> boolean isJaxbType(Class<T> type) {
        XmlRootElement element = type.getAnnotation(XmlRootElement.class);
        boolean jaxbType = element != null;
        return jaxbType;
    }
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

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.