当前位置: 首页>>代码示例>>Java>>正文


Java XmlAccessType.FIELD属性代码示例

本文整理汇总了Java中javax.xml.bind.annotation.XmlAccessType.FIELD属性的典型用法代码示例。如果您正苦于以下问题:Java XmlAccessType.FIELD属性的具体用法?Java XmlAccessType.FIELD怎么用?Java XmlAccessType.FIELD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.xml.bind.annotation.XmlAccessType的用法示例。


在下文中一共展示了XmlAccessType.FIELD属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRelevant

private static boolean isRelevant(final Field field, final XmlAccessType accessType) {
    if (field.isSynthetic())
        return false;

    if (hasIgnoreAnnotation(field) || isTypeIgnored(field.getType())) {
        ignoredFieldNames.add(field.getName());
        return false;
    }

    if (isAnnotationPresent(field, XmlElement.class))
        return true;

    final int modifiers = field.getModifiers();
    if (accessType == XmlAccessType.FIELD)
        // always take, unless static or transient
        return !Modifier.isTransient(modifiers) && !Modifier.isStatic(modifiers) && !isAnnotationPresent(field, XmlTransient.class);
    else if (accessType == XmlAccessType.PUBLIC_MEMBER)
        // only for public, non-static
        return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && !isAnnotationPresent(field, XmlTransient.class);

    return false;
}
 
开发者ID:sdaschner,项目名称:jaxrs-analyzer,代码行数:22,代码来源:JavaTypeAnalyzer.java

示例2: findFieldProperties

private void findFieldProperties(C c, XmlAccessType at) {

        // always find properties from the super class first
        C sc = nav().getSuperClass(c);
        if (shouldRecurseSuperClass(sc)) {
            findFieldProperties(sc,at);
        }

        for( F f : nav().getDeclaredFields(c) ) {
            Annotation[] annotations = reader().getAllFieldAnnotations(f,this);
            boolean isDummy = reader().hasFieldAnnotation(OverrideAnnotationOf.class, f);

            if( nav().isTransient(f) ) {
                // it's an error for transient field to have any binding annotation
                if(hasJAXBAnnotation(annotations))
                    builder.reportError(new IllegalAnnotationException(
                        Messages.TRANSIENT_FIELD_NOT_BINDABLE.format(nav().getFieldName(f)),
                            getSomeJAXBAnnotation(annotations)));
            } else
            if( nav().isStaticField(f) ) {
                // static fields are bound only when there's explicit annotation.
                if(hasJAXBAnnotation(annotations))
                    addProperty(createFieldSeed(f),annotations, false);
            } else {
                if(at==XmlAccessType.FIELD
                ||(at==XmlAccessType.PUBLIC_MEMBER && nav().isPublicField(f))
                || hasJAXBAnnotation(annotations)) {
                    if (isDummy) {
                        ClassInfo<T, C> top = getBaseClass();
                        while ((top != null) && (top.getProperty("content") == null)) {
                            top = top.getBaseClass();
                        }
                        DummyPropertyInfo prop = (DummyPropertyInfo) top.getProperty("content");
                        PropertySeed seed = createFieldSeed(f);
                        ((DummyPropertyInfo)prop).addType(createReferenceProperty(seed));
                    } else {
                        addProperty(createFieldSeed(f), annotations, false);
                    }
                }
                checkFieldXmlLocation(f);
            }
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:ClassInfoImpl.java

示例3: findFieldProperties

@SuppressWarnings("unchecked")
private void findFieldProperties(C c, XmlAccessType at) {

       // always find properties from the super class first
       C sc = nav().getSuperClass(c);
       if (shouldRecurseSuperClass(sc)) {
           findFieldProperties(sc,at);
       }

       for( F f : nav().getDeclaredFields(c) ) {
           Annotation[] annotations = reader().getAllFieldAnnotations(f,this);
           boolean isDummy = reader().hasFieldAnnotation(OverrideAnnotationOf.class, f);

           if( nav().isTransient(f) ) {
               // it's an error for transient field to have any binding annotation
               if(hasJAXBAnnotation(annotations))
                   builder.reportError(new IllegalAnnotationException(
                       Messages.TRANSIENT_FIELD_NOT_BINDABLE.format(nav().getFieldName(f)),
                           getSomeJAXBAnnotation(annotations)));
           } else
           if( nav().isStaticField(f) ) {
               // static fields are bound only when there's explicit annotation.
               if(hasJAXBAnnotation(annotations))
                   addProperty(createFieldSeed(f),annotations, false);
           } else {
               if(at==XmlAccessType.FIELD
               ||(at==XmlAccessType.PUBLIC_MEMBER && nav().isPublicField(f))
               || hasJAXBAnnotation(annotations)) {
                   if (isDummy) {
                       ClassInfo<T, C> top = getBaseClass();
                       while ((top != null) && (top.getProperty("content") == null)) {
                           top = top.getBaseClass();
                       }
					DummyPropertyInfo prop = (DummyPropertyInfo) top.getProperty("content");
                       PropertySeed seed = createFieldSeed(f);
                       ((DummyPropertyInfo<T,C,F,M>)prop).addType(createReferenceProperty(seed));
                   } else {
                       addProperty(createFieldSeed(f), annotations, false);
                   }
               }
               checkFieldXmlLocation(f);
           }
       }
   }
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:44,代码来源:ClassInfoImpl.java

示例4: isMethodAccepted

/**
 * Checks if the method is accepted as a JAXB property getter.
 */
static boolean isMethodAccepted(Method method, XmlAccessType accessType) {
    // We only accept non static property getters which are not marked @XmlTransient
    if (Modifier.isStatic(method.getModifiers()) 
        || method.isAnnotationPresent(XmlTransient.class)
        || !Modifier.isPublic(method.getModifiers())) {
        return false;
    }

    // must not have parameters and return type must not be void
    if (method.getReturnType() == Void.class 
        || method.getParameterTypes().length != 0
        || method.getDeclaringClass().equals(Throwable.class)) {
        return false;
    }

    boolean isPropGetter = method.getName().startsWith("get") || method.getName().startsWith("is");

    if (!isPropGetter 
        || method.getAnnotation(XmlJavaTypeAdapter.class) != null) {
        return false;
    }
    int beginIndex = 3;
    if (method.getName().startsWith("is")) {
        beginIndex = 2;
    }
    try {
        method.getDeclaringClass().getMethod("set" + method.getName().substring(beginIndex),
                                             new Class[] {method.getReturnType()});
    } catch (Exception e) {
        //getter, but no setter
        return false;
    }

    if (accessType == XmlAccessType.NONE
        || accessType == XmlAccessType.FIELD) {
        return checkJaxbAnnotation(method.getAnnotations());
    } else {
        return true;
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:43,代码来源:JAXBContextInitializer.java


注:本文中的javax.xml.bind.annotation.XmlAccessType.FIELD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。