本文整理汇总了Java中javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters.value方法的典型用法代码示例。如果您正苦于以下问题:Java XmlJavaTypeAdapters.value方法的具体用法?Java XmlJavaTypeAdapters.value怎么用?Java XmlJavaTypeAdapters.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
的用法示例。
在下文中一共展示了XmlJavaTypeAdapters.value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例5: 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());
}