當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlAccessType.PUBLIC_MEMBER屬性代碼示例

本文整理匯總了Java中javax.xml.bind.annotation.XmlAccessType.PUBLIC_MEMBER屬性的典型用法代碼示例。如果您正苦於以下問題:Java XmlAccessType.PUBLIC_MEMBER屬性的具體用法?Java XmlAccessType.PUBLIC_MEMBER怎麽用?Java XmlAccessType.PUBLIC_MEMBER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.xml.bind.annotation.XmlAccessType的用法示例。


在下文中一共展示了XmlAccessType.PUBLIC_MEMBER屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: isFieldAccepted

/**
 * Checks if the field is accepted as a JAXB property.
 */
static boolean isFieldAccepted(Field field, XmlAccessType accessType) {
    // We only accept non static fields which are not marked @XmlTransient
    if (Modifier.isStatic(field.getModifiers()) || field.isAnnotationPresent(XmlTransient.class)) {
        return false;
    }
    if (accessType == XmlAccessType.PUBLIC_MEMBER 
        && !Modifier.isPublic(field.getModifiers())) {
        return false;
    }
    if (field.getAnnotation(XmlJavaTypeAdapter.class) != null) {
        return false;
    }
    if (accessType == XmlAccessType.NONE
        || accessType == XmlAccessType.PROPERTY) {
        return checkJaxbAnnotation(field.getAnnotations());
    } else {
        return true;
    }
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:22,代碼來源:JAXBContextInitializer.java

示例3: getAccessType

/**
 * 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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:ClassInfoImpl.java

示例4: getXmlAccessType

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;
}
 
開發者ID:sdaschner,項目名稱:jaxrs-analyzer,代碼行數:11,代碼來源:JavaTypeAnalyzer.java

示例5: 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

示例6: marshallException

public static void marshallException(Marshaller marshaller, Exception elValue,
                                     MessagePartInfo part, Object source) {
    XMLStreamWriter writer = getStreamWriter(source);
    QName qn = part.getElementQName();
    try {
        writer.writeStartElement("ns1", qn.getLocalPart(), qn.getNamespaceURI());
        Class<?> cls = part.getTypeClass();
        XmlAccessorType accessorType = cls.getAnnotation(XmlAccessorType.class);
        if (accessorType == null && cls.getPackage() != null) {
            accessorType = cls.getPackage().getAnnotation(XmlAccessorType.class);
        }
        XmlAccessType accessType = accessorType != null
            ? accessorType.value() : XmlAccessType.PUBLIC_MEMBER;
        String namespace = part.getElementQName().getNamespaceURI();
        
        SchemaInfo sch = part.getMessageInfo().getOperation().getInterface()
            .getService().getSchema(namespace);
        if (sch != null) {
            if (!sch.isElementFormQualified()) {
                namespace = null;
            }
        } else {
            LOG.warning("Schema associated with " + namespace + " is null");
        }
        
        for (Field f : cls.getDeclaredFields()) {
            if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                QName fname = new QName(namespace, f.getName());
                f.setAccessible(true);
                if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                    writeArrayObject(marshaller, writer, fname, f.get(elValue));                        
                } else {
                    writeObject(marshaller, writer, new JAXBElement(fname, String.class, 
                                                                    f.get(elValue)));
                }
            }
        }
        for (Method m : cls.getMethods()) {
            if (JAXBContextInitializer.isMethodAccepted(m, accessType)) {
                int idx = m.getName().startsWith("get") ? 3 : 2;
                String name = m.getName().substring(idx);
                name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
                QName mname = new QName(namespace, name);
                if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
                    writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
                } else {
                    writeObject(marshaller, writer, new JAXBElement(mname, String.class, 
                                                                    m.invoke(elValue)));
                }
            }
        }

        writer.writeEndElement();
        writer.flush();
    } catch (Exception e) {
        throw new Fault(new Message("MARSHAL_ERROR", LOG, e.getMessage()), e);
    }
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:58,代碼來源:JAXBEncoderDecoder.java

示例7: 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


注:本文中的javax.xml.bind.annotation.XmlAccessType.PUBLIC_MEMBER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。