java类javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters的实例源码

TestCasePackageInfoModifier.java 文件源码 项目:jaxb-tools 阅读 25 收藏 0 点赞 0 评论 0
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());
}
PropertyInfoImpl.java 文件源码 项目:OpenJSharp 阅读 28 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:openjdk-jdk10 阅读 35 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:openjdk9 阅读 26 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 21 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:infobip-open-jdk-8 阅读 26 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:cxf-plus 阅读 22 收藏 0 点赞 0 评论 0
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;
}
PlusWrapperClassGenerator.java 文件源码 项目:cxf-plus 阅读 26 收藏 0 点赞 0 评论 0
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());
  }
PlusWrapperClassGenerator.java 文件源码 项目:cxf-plus 阅读 26 收藏 0 点赞 0 评论 0
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();
}
PropertyInfoImpl.java 文件源码 项目:OLD-OpenJDK8 阅读 29 收藏 0 点赞 0 评论 0
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;
}
PropertyInfoImpl.java 文件源码 项目:openjdk-icedtea7 阅读 27 收藏 0 点赞 0 评论 0
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;
}
TestCasePackageInfoModifier.java 文件源码 项目:jaxb-tools 阅读 28 收藏 0 点赞 0 评论 0
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());
}


问题


面经


文章

微信
公众号

扫码关注公众号