Search in sources :

Example 1 with XmlNameTransformer

use of org.eclipse.persistence.oxm.annotations.XmlNameTransformer in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method buildTypeInfo.

/**
 * INTERNAL:
 *
 * Complete building TypeInfo objects for a given set of JavaClass
 * instances. This method assumes that init, preBuildTypeInfo, and
 * postBuildTypeInfo have been called.
 */
private Map<String, TypeInfo> buildTypeInfo(JavaClass[] allClasses) {
    for (JavaClass javaClass : allClasses) {
        if (javaClass == null) {
            continue;
        }
        TypeInfo info = typeInfos.get(javaClass.getQualifiedName());
        if (info == null || info.isPostBuilt()) {
            continue;
        }
        info.setPostBuilt(true);
        // handle factory methods
        processFactoryMethods(javaClass, info);
        PackageInfo packageInfo = getPackageInfoForPackage(javaClass);
        XMLNameTransformer transformer = info.getXmlNameTransformer();
        if (transformer == TypeInfo.DEFAULT_NAME_TRANSFORMER) {
            XMLNameTransformer nsInfoXmlNameTransformer = packageInfo.getXmlNameTransformer();
            if (nsInfoXmlNameTransformer != null) {
                info.setXmlNameTransformer(nsInfoXmlNameTransformer);
            } else if (helper.isAnnotationPresent(javaClass, XmlNameTransformer.class)) {
                XmlNameTransformer xmlNameTransformer = (XmlNameTransformer) helper.getAnnotation(javaClass, XmlNameTransformer.class);
                Class<? extends XMLNameTransformer> nameTransformerClass = xmlNameTransformer.value();
                try {
                    info.setXmlNameTransformer(nameTransformerClass.getConstructor().newInstance());
                } catch (ReflectiveOperationException ex) {
                    throw JAXBException.exceptionWithNameTransformerClass(nameTransformerClass.getName(), ex);
                }
            } else if (helper.isAnnotationPresent(javaClass.getPackage(), XmlNameTransformer.class)) {
                XmlNameTransformer xmlNameTransformer = (XmlNameTransformer) helper.getAnnotation(javaClass.getPackage(), XmlNameTransformer.class);
                Class<? extends XMLNameTransformer> nameTransformerClass = xmlNameTransformer.value();
                try {
                    info.setXmlNameTransformer(nameTransformerClass.getConstructor().newInstance());
                } catch (ReflectiveOperationException ex) {
                    throw JAXBException.exceptionWithNameTransformerClass(nameTransformerClass.getName(), ex);
                }
            }
        }
        // handle @XmlAccessorType
        postProcessXmlAccessorType(info, packageInfo);
        // handle @XmlType
        postProcessXmlType(javaClass, info, packageInfo);
        // handle @XmlEnum
        if (info.isEnumerationType()) {
            addEnumTypeInfo(javaClass, ((EnumTypeInfo) info));
            continue;
        }
        // process schema type name
        processTypeQName(javaClass, info, packageInfo.getNamespaceInfo());
        // handle superclass if necessary
        JavaClass superClass = javaClass.getSuperclass();
        processPropertiesSuperClass(javaClass, info);
        processReferencedClass(superClass);
        // add properties
        info.setProperties(getPropertiesForClass(javaClass, info));
        // process properties
        processTypeInfoProperties(javaClass, info);
        // handle @XmlAccessorOrder
        postProcessXmlAccessorOrder(info, packageInfo);
        validatePropOrderForInfo(info);
    }
    return typeInfos;
}
Also used : JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) XmlNameTransformer(org.eclipse.persistence.oxm.annotations.XmlNameTransformer) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) XMLNameTransformer(org.eclipse.persistence.oxm.XMLNameTransformer)

Aggregations

JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)1 XMLNameTransformer (org.eclipse.persistence.oxm.XMLNameTransformer)1 XmlNameTransformer (org.eclipse.persistence.oxm.annotations.XmlNameTransformer)1