javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters Java Examples

The following examples show how to use javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java    From cxf with Apache License 2.0 6 votes vote down vote up
static XmlJavaTypeAdapter getFieldXJTA(final Field f) {
    XmlJavaTypeAdapter adapter = f.getAnnotation(XmlJavaTypeAdapter.class);
    if (adapter == null) {
        adapter = f.getType().getAnnotation(XmlJavaTypeAdapter.class);
    }
    if (adapter == null) {
        Package packageDeclaration = f.getDeclaringClass().getPackage();
        if (packageDeclaration != null) {
            XmlJavaTypeAdapters adapters = packageDeclaration.getAnnotation(XmlJavaTypeAdapters.class);
            if (adapters != null) {
                for (XmlJavaTypeAdapter candidate : adapters.value()) {
                    if (candidate != null && candidate.type().equals(f.getType())) {
                        adapter = candidate;
                        break;
                    }
                }
            }
        }
    }
    return adapter;
}
 
Example #2
Source File: PropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #3
Source File: PropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #4
Source File: PropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #5
Source File: PropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #6
Source File: PropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #7
Source File: PropertyInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #8
Source File: PropertyInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #9
Source File: PropertyInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if(jta!=null && isApplicable(jta,type))
        return jta;

    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed );
    if(jtas!=null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if(isApplicable(xjta,type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed );
    if(isApplicable(jta,type))
        return jta;

    // then on the target class
    C refType = nav().asDecl(type);
    if(refType!=null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed );
        if(jta!=null && isApplicable(jta,type)) // the one on the type always apply.
            return jta;
    }

    return null;
}
 
Example #10
Source File: Utils.java    From cxf with Apache License 2.0 5 votes vote down vote up
static XmlJavaTypeAdapter getMethodXJTA(final Method m) {
    XmlJavaTypeAdapter adapter = m.getAnnotation(XmlJavaTypeAdapter.class);
    if (adapter == null) {
        Method setter = getSetter(m);
        if (setter != null) {
            adapter = setter.getAnnotation(XmlJavaTypeAdapter.class);
        }
    }
    if (adapter == null) {
        adapter = m.getReturnType().getAnnotation(XmlJavaTypeAdapter.class);
    }
    if (adapter == null) {
        Package packageDeclaration = m.getDeclaringClass().getPackage();
        if (packageDeclaration != null) {
            XmlJavaTypeAdapters adapters = packageDeclaration.getAnnotation(XmlJavaTypeAdapters.class);
            if (adapters != null) {
                for (XmlJavaTypeAdapter candidate : adapters.value()) {
                    if (candidate != null && candidate.type().equals(m.getGenericReturnType())) {
                        adapter = candidate;
                        break;
                    }
                }
            }
        }
    }
    return adapter;
}
 
Example #11
Source File: WrapperClassGenerator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void generatePackageInfo(String className, String ns, Class<?> clz) {
    ClassWriter cw = createClassWriter();
    String classFileName = periodToSlashes(className);
    cw.visit(Opcodes.V1_5, Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE, classFileName, null,
             "java/lang/Object", null);

    boolean q = qualified;
    SchemaInfo si = interfaceInfo.getService().getSchema(ns);
    if (si != null) {
        q = si.isElementFormQualified();
    }
    AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true);
    av0.visit("namespace", ns);
    av0.visitEnum("elementFormDefault",
                  getClassCode(XmlNsForm.class),
                  q ? "QUALIFIED" : "UNQUALIFIED");
    av0.visitEnd();

    if (clz.getPackage() != null && clz.getPackage().getAnnotations() != null) {
        for (Annotation ann : clz.getPackage().getAnnotations()) {
            if (ann instanceof XmlJavaTypeAdapters) {
                av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapters;", true);
                generateXmlJavaTypeAdapters(av0, (XmlJavaTypeAdapters)ann);
                av0.visitEnd();
            } else if (ann instanceof XmlJavaTypeAdapter) {
                av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
                generateXmlJavaTypeAdapter(av0, (XmlJavaTypeAdapter)ann);
                av0.visitEnd();
            }
        }
    }
    cw.visitEnd();

    loadClass(className, clz, cw.toByteArray());
}
 
Example #12
Source File: WrapperClassGenerator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void generateXmlJavaTypeAdapters(AnnotationVisitor av, XmlJavaTypeAdapters adapters) {
    AnnotationVisitor av1 = av.visitArray("value");

    for (XmlJavaTypeAdapter adapter : adapters.value()) {
        AnnotationVisitor av2
            = av1.visitAnnotation(null, "Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;");
        generateXmlJavaTypeAdapter(av2, adapter);
        av2.visitEnd();
    }
    av1.visitEnd();
}