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


                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

    public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
        Annotation[] a = (Annotation[])mpi.getProperty(ReflectionServiceFactoryBean.PARAM_ANNOTATION);
        if (a != null) {
            for (Annotation a2 : a) {
                if (a2 instanceof XmlElement) {
                    XmlElement e = (XmlElement)a2;
                    if (e.required()) {
                        return 1L;
                    }
                }
            }
        }
View Full Code Here

      accessor.getAnnotation(XmlAnyAttribute.class);
    XmlAnyElement xmlAnyElement =
      accessor.getAnnotation(XmlAnyElement.class);
    XmlAttribute xmlAttribute =
      accessor.getAnnotation(XmlAttribute.class);
    XmlElement xmlElement =
      accessor.getAnnotation(XmlElement.class);
    XmlElementRef xmlElementRef =
      accessor.getAnnotation(XmlElementRef.class);
    XmlElements xmlElements =
      accessor.getAnnotation(XmlElements.class);
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

     * @param  method The name of the getter method to search for.
     * @param  uml    The UML annotation on the GeoAPI interface, or {@code null} if none.
     * @return The {@code XmlElement}, or {@code null} if none.
     */
    private static XmlElement getXmlElement(final Class<?> impl, final String method, final UML uml) {
        XmlElement element = null;
        try {
            element = impl.getMethod(method, (Class<?>[]) null).getAnnotation(XmlElement.class);
            if (element == null && uml != null) {
                element = impl.getDeclaredField(uml.identifier()).getAnnotation(XmlElement.class);
            }
View Full Code Here

                if (isIgnored(method)) {
                    continue;
                }
                testingMethod = method.getName();
                final UML uml = method.getAnnotation(UML.class);
                final XmlElement element = getXmlElement(impl, testingMethod, uml);
                /*
                 * Just display the missing @XmlElement annotation for the method, since we know
                 * that some elements are not yet implemented (and consequently can not yet be
                 * annotated).
                 */
                if (element == null) {
                    // Note: lines with the "[WARNING]" string are highlighted by Jenkins.
                    warning("[WARNING] Missing @XmlElement annotation for ");
                    continue;
                }
                /*
                 * The UML annotation is mandatory in the default implementation of the
                 * 'testInterfaceAnnotations()' method, but we don't require the UML to
                 * be non-null here since this is not the job of this test method. This
                 * is because subclasses may choose to override the above test method.
                 */
                if (uml != null) {
                    assertEquals("Wrong @XmlElement.name().", uml.identifier(), element.name());
                    assertEquals("Wrong @XmlElement.required().", uml.obligation() == Obligation.MANDATORY, element.required());
                }
                /*
                 * Check that the namespace is the expected one (according subclass)
                 * and is not redundant with the package @XmlSchema annotation.
                 */
                assertExpectedNamespace(element.namespace(), impl, uml);
            }
        }
        done();
    }
View Full Code Here

            assertEquals("The setter method must be declared in the same class than the " +
                         "getter method - not in a parent class, to avoid issues with JAXB.",
                         getter.getDeclaringClass(), setter.getDeclaringClass());
            assertEquals("The setter parameter type shall be the same than the getter return type.",
                         getter.getReturnType(), getSingleton(setter.getParameterTypes()));
            final XmlElement element = getter.getAnnotation(XmlElement.class);
            assertEquals("Expected @XmlElement XOR @XmlElementRef.", (element == null),
                         getter.isAnnotationPresent(XmlElementRef.class));
            /*
             * If the annotation is @XmlElement, ensure that XmlElement.name() is equals to
             * the UML identifier. Then verify that the
             */
            if (element != null) {
                assertFalse("Expected @XmlElementRef.", wrapper.isInherited);
                final UML uml = type.getAnnotation(UML.class);
                if (uml != null) { // 'assertNotNull' is 'testInterfaceAnnotations()' job.
                    assertEquals("Wrong @XmlElement.", uml.identifier(), element.name());
                }
                final String namespace = assertExpectedNamespace(element.namespace(), wrapper.type, uml);
                if (!CodeList.class.isAssignableFrom(type)) {
                    final String expected = getNamespace(getImplementation(type));
                    if (expected != null) { // 'assertNotNull' is 'testImplementationAnnotations()' job.
                        assertEquals("Inconsistent @XmlRootElement namespace.", expected, namespace);
                    }
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.