Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlElementDecl


        return ctx;
    }
   
    private boolean checkObjectFactoryNamespaces(Class<?> clz) {
        for (Method meth : clz.getMethods()) {
            XmlElementDecl decl = meth.getAnnotation(XmlElementDecl.class);
            if (decl != null
                && XmlElementDecl.GLOBAL.class.equals(decl.scope())
                && StringUtils.isEmpty(decl.namespace())) {
                return true;
            }
        }

        return false;
View Full Code Here


                    type = (JavaClass) next.getReturnType().getActualTypeArguments().toArray()[0];
                } else {
                    this.factoryMethods.put(next.getReturnType().getRawName(), next);
                }
                if (helper.isAnnotationPresent(next, XmlElementDecl.class)) {
                    XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                    String url = elementDecl.namespace();
                    if ("##default".equals(url)) {
                        url = namespaceInfo.getNamespace();
                    }
                    String localName = elementDecl.name();
                    QName qname = new QName(url, localName);

                    if (this.globalElements == null) {
                        globalElements = new HashMap<QName, ElementDeclaration>();
                    }

                    boolean isList = false;
                    if ("java.util.List".equals(type.getName())) {
                        isList = true;
                        if (type.hasActualTypeArguments()) {
                            type = (JavaClass) type.getActualTypeArguments().toArray()[0];
                        }
                    }

                    ElementDeclaration declaration = new ElementDeclaration(qname, type, type.getQualifiedName(), isList, elementDecl.scope());
                    if (!elementDecl.substitutionHeadName().equals("")) {
                        String subHeadLocal = elementDecl.substitutionHeadName();
                        String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                        if (subHeadNamespace.equals("##default")) {
                            subHeadNamespace = namespaceInfo.getNamespace();
                        }
                        declaration.setSubstitutionHead(new QName(subHeadNamespace, subHeadLocal));
                    }
                    if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("\u0000"))) {
                        declaration.setDefaultValue(elementDecl.defaultValue());
                    }

                    if (helper.isAnnotationPresent(next, XmlJavaTypeAdapter.class)) {
                        XmlJavaTypeAdapter typeAdapter = (XmlJavaTypeAdapter) helper.getAnnotation(next, XmlJavaTypeAdapter.class);
                        Class typeAdapterClass = typeAdapter.value();
View Full Code Here

                            defaultValue = xmlEltDecl.getDefaultValue();
                        }
                    } else {
                        // there was no xml-element-decl for this method in XML,
                        // so use the annotation
                        XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                        url = elementDecl.namespace();
                        localName = elementDecl.name();
                        scopeClass = elementDecl.scope();
                        if (!elementDecl.substitutionHeadName().equals(EMPTY_STRING)) {
                            String subHeadLocal = elementDecl.substitutionHeadName();
                            String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                            if (subHeadNamespace.equals(XMLProcessor.DEFAULT)) {
                                subHeadNamespace = packageInfo.getNamespace();
                            }

                            substitutionHead = new QName(subHeadNamespace, subHeadLocal);
                        }
                        if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith(ELEMENT_DECL_DEFAULT))) {
                            defaultValue = elementDecl.defaultValue();
                        }
                    }

                    if (XMLProcessor.DEFAULT.equals(url)) {
                        url = packageInfo.getNamespace();
View Full Code Here

                    type = (JavaClass) next.getReturnType().getActualTypeArguments().toArray()[0];
                } else {
                    this.factoryMethods.put(next.getReturnType().getRawName(), next);
                }
                if (helper.isAnnotationPresent(next, XmlElementDecl.class)) {
                    XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                    String url = elementDecl.namespace();
                    if ("##default".equals(url)) {
                        url = namespaceInfo.getNamespace();
                    }
                    String localName = elementDecl.name();
                    QName qname = new QName(url, localName);

                    if (this.globalElements == null) {
                        globalElements = new HashMap<QName, ElementDeclaration>();
                    }

                    boolean isList = false;
                    if ("java.util.List".equals(type.getName())) {
                        isList = true;
                        if (type.hasActualTypeArguments()) {
                            type = (JavaClass) type.getActualTypeArguments().toArray()[0];
                        }
                    }

                    ElementDeclaration declaration = new ElementDeclaration(qname, type, type.getQualifiedName(), isList, elementDecl.scope());
                    if (!elementDecl.substitutionHeadName().equals("")) {
                        String subHeadLocal = elementDecl.substitutionHeadName();
                        String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                        if (subHeadNamespace.equals("##default")) {
                            subHeadNamespace = namespaceInfo.getNamespace();
                        }
                        declaration.setSubstitutionHead(new QName(subHeadNamespace, subHeadLocal));
                    }
                    if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("\u0000"))) {
                        declaration.setDefaultValue(elementDecl.defaultValue());
                    }

                    if (helper.isAnnotationPresent(next, XmlJavaTypeAdapter.class)) {
                        XmlJavaTypeAdapter typeAdapter = (XmlJavaTypeAdapter) helper.getAnnotation(next, XmlJavaTypeAdapter.class);
                        Class typeAdapterClass = typeAdapter.value();
View Full Code Here

                    defaultValue = xmlEltDecl.getDefaultValue();
                }
            } else {
                // there was no xml-element-decl for this method in XML,
                // so use the annotation
                XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                url = elementDecl.namespace();
                localName = elementDecl.name();
                scopeClass = elementDecl.scope();
                if (!elementDecl.substitutionHeadName().equals(EMPTY_STRING)) {
                    String subHeadLocal = elementDecl.substitutionHeadName();
                    String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                    if (subHeadNamespace.equals(XMLProcessor.DEFAULT)) {
                        subHeadNamespace = packageInfo.getNamespace();
                    }

                    substitutionHead = new QName(subHeadNamespace, subHeadLocal);
                }
                if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith(ELEMENT_DECL_DEFAULT))) {
                    defaultValue = elementDecl.defaultValue();
                }
            }

            if (XMLProcessor.DEFAULT.equals(url)) {
                url = packageInfo.getNamespace();
View Full Code Here

                            defaultValue = xmlEltDecl.getDefaultValue();
                        }
                    } else {
                        // there was no xml-element-decl for this method in XML,
                        // so use the annotation
                        XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                        url = elementDecl.namespace();
                        localName = elementDecl.name();
                        scopeClass = elementDecl.scope();
                        if (!elementDecl.substitutionHeadName().equals(EMPTY_STRING)) {
                            String subHeadLocal = elementDecl.substitutionHeadName();
                            String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                            if (subHeadNamespace.equals(XMLProcessor.DEFAULT)) {
                                subHeadNamespace = packageInfo.getNamespace();
                            }

                            substitutionHead = new QName(subHeadNamespace, subHeadLocal);
                        }
                        if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith(ELEMENT_DECL_DEFAULT))) {
                            defaultValue = elementDecl.defaultValue();
                        }
                    }

                    if(XMLConstants.EMPTY_STRING.equals(url)) {
                        isDefaultNamespaceAllowed = false;
View Full Code Here

                        if (!(xmlEltDecl.getDefaultValue().length() == 1 && xmlEltDecl.getDefaultValue().startsWith("\u0000"))) {
                            defaultValue = xmlEltDecl.getDefaultValue();
                        }
                    } else {
                        // there was no xml-element-decl for this method in XML, so use the annotation
                        XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                        url = elementDecl.namespace();
                        localName = elementDecl.name();
                        scopeClass = elementDecl.scope();
                        if (!elementDecl.substitutionHeadName().equals("")) {
                            String subHeadLocal = elementDecl.substitutionHeadName();
                            String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                            if (subHeadNamespace.equals("##default")) {
                                subHeadNamespace = namespaceInfo.getNamespace();
                            }
                           
                            substitutionHead = new QName(subHeadNamespace, subHeadLocal);
                        }
                        if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("\u0000"))) {
                            defaultValue = elementDecl.defaultValue();
                        }
                    }
                   
                    if ("##default".equals(url)) {
                        url = namespaceInfo.getNamespace();
View Full Code Here

                        if (!(xmlEltDecl.getDefaultValue().length() == 1 && xmlEltDecl.getDefaultValue().startsWith("\u0000"))) {
                            defaultValue = xmlEltDecl.getDefaultValue();
                        }
                    } else {
                        // there was no xml-element-decl for this method in XML, so use the annotation
                        XmlElementDecl elementDecl = (XmlElementDecl) helper.getAnnotation(next, XmlElementDecl.class);
                        url = elementDecl.namespace();
                        localName = elementDecl.name();
                        scopeClass = elementDecl.scope();
                        if (!elementDecl.substitutionHeadName().equals("")) {
                            String subHeadLocal = elementDecl.substitutionHeadName();
                            String subHeadNamespace = elementDecl.substitutionHeadNamespace();
                            if (subHeadNamespace.equals("##default")) {
                                subHeadNamespace = namespaceInfo.getNamespace();
                            }
                           
                            substitutionHead = new QName(subHeadNamespace, subHeadLocal);
                        }
                        if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("\u0000"))) {
                            defaultValue = elementDecl.defaultValue();
                        }
                    }
                   
                    if ("##default".equals(url)) {
                        url = namespaceInfo.getNamespace();
View Full Code Here

/*     */
/*  89 */       return;
/*     */     }
/*     */
/*  92 */     for (Iterator i$ = this.nav.getDeclaredMethods(registryClass).iterator(); i$.hasNext(); ) { Object m = i$.next();
/*  93 */       XmlElementDecl em = (XmlElementDecl)builder.reader.getMethodAnnotation(XmlElementDecl.class, m, this);
/*     */
/*  96 */       if (em == null) {
/*  97 */         if (!this.nav.getMethodName(m).startsWith("create"))
/*     */           continue;
/*  99 */         this.references.add(builder.getTypeInfo(this.nav.getReturnType(m), new MethodLocatable(this, m, this.nav)));
View Full Code Here

            Method methods[] = objectFactory.getDeclaredMethods();
            for (Method method : methods) {
                if (method.getParameterTypes().length == 1
                    && method.getParameterTypes()[0].equals(cls)) {
                   
                    XmlElementDecl elementDecl = method.getAnnotation(XmlElementDecl.class);
                    if (null != elementDecl) {
                        String name = elementDecl.name();
                        String ns = namespace != null ? namespace : elementDecl.namespace();
                        if (namespace != null) {
                            helper.setJaxbNamespace(elementDecl.namespace());
                        }
                        QName elementType = new QName(ns, name);
                        registry.registerDeserializer(parentType, elementType, helper);
                        registry.registerSerializer(parentType, elementType, helper);                        
                        registry.mapExtensionTypes(parentType, elementType, cls);
View Full Code Here

TOP

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

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.