本文整理汇总了Java中javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters类的典型用法代码示例。如果您正苦于以下问题:Java XmlJavaTypeAdapters类的具体用法?Java XmlJavaTypeAdapters怎么用?Java XmlJavaTypeAdapters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlJavaTypeAdapters类属于javax.xml.bind.annotation.adapters包,在下文中一共展示了XmlJavaTypeAdapters类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateOneAnnotation
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
private final void validateOneAnnotation(final PackageInfoModifier.Modification mod) throws Exception {
assertNotNull(mod);
final byte[] newClass = mod.toByteArray();
assertNotNull(newClass);
assertTrue(newClass.length > 0);
final Class<?> c = new ClassDefiner().define(mod.getPackageName(), newClass);
assertNotNull(c);
final Annotation[] annotations = c.getAnnotations();
assertNotNull(annotations);
assertTrue(annotations.length == 1);
Annotation a = annotations[0];
assertNotNull(a);
assertTrue(a instanceof XmlJavaTypeAdapters);
final XmlJavaTypeAdapters adaptersAnnotation = (XmlJavaTypeAdapters)a;
final XmlJavaTypeAdapter[] adapters = adaptersAnnotation.value();
assertNotNull(adapters);
assertEquals(1, adapters.length);
final XmlJavaTypeAdapter adapter = adapters[0];
assertNotNull(adapter);
assertEquals(Person.class, adapter.type());
assertEquals(AnyTypeAdapter.class, adapter.value());
}
示例2: getApplicableAdapter
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
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;
}
示例3: getApplicableAdapter
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
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;
if (type instanceof Type) {
jta = JefAdapters.get((Type)type);
if (jta != null && 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;
}
示例4: generatePackageInfo
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
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());
}
示例5: generateXmlJavaTypeAdapters
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
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();
}
示例6: validateTwoAnnotations
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; //导入依赖的package包/类
private final void validateTwoAnnotations(final PackageInfoModifier.Modification mod) throws Exception {
assertNotNull(mod);
final byte[] newClass = mod.toByteArray();
assertNotNull(newClass);
assertTrue(newClass.length > 0);
final Class<?> c = new ClassDefiner().define(mod.getPackageName(), newClass);
assertNotNull(c);
final Annotation[] annotations = c.getAnnotations();
assertNotNull(annotations);
assertTrue(annotations.length == 2);
Annotation a = annotations[0];
assertNotNull(a);
if (a instanceof Deprecated) {
a = annotations[1];
assertNotNull(a);
}
assertTrue(a instanceof XmlJavaTypeAdapters);
final XmlJavaTypeAdapters adaptersAnnotation = (XmlJavaTypeAdapters)a;
final XmlJavaTypeAdapter[] adapters = adaptersAnnotation.value();
assertNotNull(adapters);
assertEquals(1, adapters.length);
final XmlJavaTypeAdapter adapter = adapters[0];
assertNotNull(adapter);
assertEquals(Person.class, adapter.type());
assertEquals(AnyTypeAdapter.class, adapter.value());
}