类javax.xml.bind.annotation.XmlAccessorType源码实例Demo

下面列出了怎么用javax.xml.bind.annotation.XmlAccessorType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: raml-java-tools   文件: JaxbUnionExtensionTest.java
@Test
public void implementationClassCreated() {

    JaxbUnionExtension jaxb = new JaxbUnionExtension();
    TypeSpec.Builder classBuilder = TypeSpec.classBuilder("my.BuiltClass");

    TypeSpec.Builder builder = jaxb.classCreated(null, unionTypeDeclaration, classBuilder, EventType.IMPLEMENTATION);
    TypeSpec buildClass = builder.build();

    TypeSpecAssert.assertThat(buildClass)
            .hasName("my.BuiltClass");

    AnnotationSpecAssert.assertThat(buildClass.annotations.get(0)).hasType(ClassName.get(XmlAccessorType.class));
    assertEquals("javax.xml.bind.annotation.XmlAccessType.FIELD", builder.build().annotations.get(0).members.get("value").get(0).toString());

    AnnotationSpecAssert.assertThat(buildClass.annotations.get(1)).hasType(ClassName.get(XmlRootElement.class));
    assertEquals("null", builder.build().annotations.get(1).members.get("name").get(0).toString());
    assertEquals("\"##default\"", builder.build().annotations.get(1).members.get("namespace").get(0).toString());
}
 
源代码2 项目: TencentKona-8   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码4 项目: jdk8u60   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
源代码5 项目: jdk8u60   文件: WebServiceWrapperGenerator.java
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码6 项目: openjdk-jdk8u   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码8 项目: openjdk-jdk8u-backup   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码10 项目: openjdk-jdk9   文件: WebServiceWrapperGenerator.java
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码11 项目: openjdk-jdk9   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
源代码12 项目: hottub   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
源代码13 项目: hottub   文件: WebServiceWrapperGenerator.java
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码14 项目: openjdk-8-source   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码16 项目: openjdk-8   文件: ClassInfoImpl.java
/**
 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
 * annotations.
 */
private XmlAccessType getAccessType() {
    XmlAccessorType xat = getClassOrPackageAnnotation(XmlAccessorType.class);
    if(xat!=null)
        return xat.value();
    else
        return XmlAccessType.PUBLIC_MEMBER;
}
 
源代码17 项目: openjdk-8   文件: WebServiceWrapperGenerator.java
private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {

       if (cls == null)
            return;
        JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
        xmlRootElementAnn.param("name", elementName);
        if (namespaceUri.length() > 0) {
            xmlRootElementAnn.param("namespace", namespaceUri);
        }
        JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
        xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
    }
 
源代码18 项目: jaxrs-analyzer   文件: JavaTypeAnalyzer.java
private XmlAccessType getXmlAccessType(final Class<?> clazz) {
    Class<?> current = clazz;

    while (current != null) {
        if (isAnnotationPresent(current, XmlAccessorType.class))
            return getAnnotation(current, XmlAccessorType.class).value();
        current = current.getSuperclass();
    }

    return XmlAccessType.PUBLIC_MEMBER;
}
 
源代码19 项目: rice   文件: ImmutableJaxbGenerator.java
private void renderClassLevelAnnotations(JDefinedClass classModel, List<FieldModel> fields) throws Exception {
	JFieldRef constantsClass = classModel.staticRef(Util.CONSTANTS_CLASS_NAME);
	JFieldRef elementsClass = classModel.staticRef(Util.ELEMENTS_CLASS_NAME);
	JClass coreConstants = codeModel.ref(CoreConstants.class);
	JFieldRef commonElementsRef = coreConstants.staticRef("CommonElements");
	
	// XmlRootElement
	JAnnotationUse rootElementAnnotation = classModel.annotate(XmlRootElement.class);
	rootElementAnnotation.param("name", constantsClass.ref(Util.ROOT_ELEMENT_NAME_FIELD));
	
	// XmlAccessorType
	JAnnotationUse xmlAccessorTypeAnnotation = classModel.annotate(XmlAccessorType.class);
	xmlAccessorTypeAnnotation.param("value", XmlAccessType.NONE);
	
	// XmlType
	JAnnotationUse xmlTypeAnnotation = classModel.annotate(XmlType.class);
	xmlTypeAnnotation.param("name", constantsClass.ref(Util.TYPE_NAME_FIELD));
	JAnnotationArrayMember propOrderMember = xmlTypeAnnotation.paramArray("propOrder");
	for (FieldModel field : fields) {
		if (Util.isCommonElement(field.fieldName)) {
			propOrderMember.param(commonElementsRef.ref(Util.toConstantsVariable(field.fieldName)));
		} else {
			propOrderMember.param(elementsClass.ref(Util.toConstantsVariable(field.fieldName)));
		}
	}
	propOrderMember.param(commonElementsRef.ref("FUTURE_ELEMENTS"));
}
 
源代码20 项目: cxf   文件: Utils.java
static XmlAccessType getXmlAccessType(Class<?> cls) {
    XmlAccessorType accessorType = cls.getAnnotation(XmlAccessorType.class);
    if (accessorType == null && cls.getPackage() != null) {
        accessorType = cls.getPackage().getAnnotation(XmlAccessorType.class);
    }
    return accessorType != null
        ? accessorType.value() : XmlAccessType.PUBLIC_MEMBER;
}
 
源代码21 项目: cxf   文件: WrapperBeanAnnotator.java
public void annotate(final JavaAnnotatable clz) {
    WrapperBeanClass beanClass = null;
    if (clz instanceof WrapperBeanClass) {
        beanClass = (WrapperBeanClass) clz;
    } else {
        throw new RuntimeException("WrapperBeanAnnotator expect JavaClass as input");
    }

    JAnnotation xmlRootElement = new JAnnotation(XmlRootElement.class);
    xmlRootElement.addElement(new JAnnotationElement("name",
                                                     beanClass.getElementName().getLocalPart()));
    xmlRootElement.addElement(new JAnnotationElement("namespace",
                                                     beanClass.getElementName().getNamespaceURI()));

    JAnnotation xmlAccessorType = new JAnnotation(XmlAccessorType.class);
    xmlAccessorType.addElement(new JAnnotationElement(null, XmlAccessType.FIELD));

    XmlType tp = null;
    if (sourceClass != null) {
        tp = sourceClass.getAnnotation(XmlType.class);
    }
    JAnnotation xmlType = new JAnnotation(XmlType.class);
    if (tp == null) {
        xmlType.addElement(new JAnnotationElement("name",
                                              beanClass.getElementName().getLocalPart()));
        xmlType.addElement(new JAnnotationElement("namespace",
                                              beanClass.getElementName().getNamespaceURI()));
    } else {
        if (!"##default".equals(tp.name())) {
            xmlType.addElement(new JAnnotationElement("name",
                                                      tp.name()));
        }
        if (!"##default".equals(tp.namespace())) {
            xmlType.addElement(new JAnnotationElement("namespace",
                                                      tp.namespace()));
        }
        if (!StringUtils.isEmpty(tp.factoryMethod())) {
            xmlType.addElement(new JAnnotationElement("factoryMethod",
                                                      tp.factoryMethod()));
        }
        if (tp.propOrder().length != 1
            || !StringUtils.isEmpty(tp.propOrder()[0])) {
            xmlType.addElement(new JAnnotationElement("propOrder",
                                                  tp.propOrder()));
        }

    }
    List<String> props = new ArrayList<>();
    for (JavaField f : beanClass.getFields()) {
        props.add(f.getParaName());
    }
    if (props.size() > 1) {
        xmlType.addElement(new JAnnotationElement("propOrder",
                                                  props));
    }

    // Revisit: why annotation is string?
    beanClass.addAnnotation(xmlRootElement);
    beanClass.addAnnotation(xmlAccessorType);
    beanClass.addAnnotation(xmlType);
}
 
 类方法
 同包方法