类javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter源码实例Demo

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

源代码1 项目: cxf   文件: JAXBUtils.java
@SuppressWarnings("unchecked")
public static Object useAdapter(Object obj,
                                XmlJavaTypeAdapter typeAdapter,
                                boolean marshal,
                                Object defaultValue) {
    if (typeAdapter != null) {
        try {
            @SuppressWarnings("rawtypes")
            XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
            if (marshal) {
                return xmlAdapter.marshal(obj);
            }
            return xmlAdapter.unmarshal(obj);
        } catch (Exception ex) {
            LOG.log(Level.INFO, "(un)marshalling failed, using defaultValue", ex);
        }
    }
    return defaultValue;
}
 
源代码2 项目: openjdk-jdk8u-backup   文件: PropertyInfoImpl.java
/**
 * Checks if the given adapter is applicable to the declared property type.
 */
private boolean isApplicable(XmlJavaTypeAdapter jta, T declaredType ) {
    if(jta==null)   return false;

    T type = reader().getClassValue(jta,"type");
    if(nav().isSameType(declaredType, type))
        return true;    // for types explicitly marked in XmlJavaTypeAdapter.type()

    T ad = reader().getClassValue(jta,"value");
    T ba = nav().getBaseClass(ad, nav().asDecl(XmlAdapter.class));
    if(!nav().isParameterizedType(ba))
        return true;   // can't check type applicability. assume Object, which means applicable to any.
    T inMemType = nav().getTypeArgument(ba, 1);

    return nav().isSubClassOf(declaredType,inMemType);
}
 
源代码3 项目: cxf   文件: WrapperUtil.java
public static List<Annotation> getJaxbAnnotations(Method method) {
    List<Annotation> jaxbAnnotation = new ArrayList<>();
    Annotation ann = method.getAnnotation(XmlAttachmentRef.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlMimeType.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlJavaTypeAdapter.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    ann = method.getAnnotation(XmlList.class);
    if (ann != null) {
        jaxbAnnotation.add(ann);
    }
    return jaxbAnnotation;
}
 
源代码4 项目: jdk8u60   文件: PropertyInfoImpl.java
/**
 * Checks if the given adapter is applicable to the declared property type.
 */
private boolean isApplicable(XmlJavaTypeAdapter jta, T declaredType ) {
    if(jta==null)   return false;

    T type = reader().getClassValue(jta,"type");
    if(nav().isSameType(declaredType, type))
        return true;    // for types explicitly marked in XmlJavaTypeAdapter.type()

    T ad = reader().getClassValue(jta,"value");
    T ba = nav().getBaseClass(ad, nav().asDecl(XmlAdapter.class));
    if(!nav().isParameterizedType(ba))
        return true;   // can't check type applicability. assume Object, which means applicable to any.
    T inMemType = nav().getTypeArgument(ba, 1);

    return nav().isSubClassOf(declaredType,inMemType);
}
 
源代码5 项目: cxf   文件: JAXBUtils.java
public static Class<?> getValueTypeFromAdapter(Class<?> expectedBoundType,
                                               Class<?> defaultClass,
                                               Annotation[] anns) {
    try {
        XmlJavaTypeAdapter adapter = getAdapter(expectedBoundType, anns);
        if (adapter != null) {
            Class<?> boundType = JAXBUtils.getTypeFromAdapter(adapter, null, true);
            if (boundType != null && boundType.isAssignableFrom(expectedBoundType)) {
                return JAXBUtils.getTypeFromAdapter(adapter, null, false);
            }
        }
    } catch (Throwable ex) {
        // ignore
    }
    return defaultClass;
}
 
源代码6 项目: nifi   文件: ParameterContextsEntity.java
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
    value = "The current time on the system.",
    dataType = "string",
    readOnly = true
)
public Date getCurrentTime() {
    return currentTime;
}
 
源代码7 项目: sis   文件: DefaultRepresentativeFraction.java
/**
 * Invoked by JAXB for fetching the unique identifier unique for the XML document.
 *
 * @see org.apache.sis.metadata.iso.ISOMetadata#getID()
 */
@XmlID
@XmlAttribute  // Defined in "gco" as unqualified attribute.
@XmlSchemaType(name = "ID")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
private String getID() {
    return isNullOrEmpty(identifiers) ? null : MetadataUtilities.getObjectID(this);
}
 
源代码8 项目: openjdk-8-source   文件: JavaCompilerImpl.java
public J2SJAXBModel bind(
    Collection<Reference> rootClasses,
    Map<QName,Reference> additionalElementDecls,
    String defaultNamespaceRemap,
    ProcessingEnvironment env) {

    ModelBuilder<TypeMirror, TypeElement, VariableElement, ExecutableElement> builder =
            new ModelBuilder<TypeMirror, TypeElement, VariableElement, ExecutableElement>(
            InlineAnnotationReaderImpl.theInstance,
            new ApNavigator(env),
            Collections.<TypeElement, TypeElement>emptyMap(),
            defaultNamespaceRemap );

    builder.setErrorHandler(new ErrorHandlerImpl(env.getMessager()));

    for ( Reference ref : rootClasses ) {
        TypeMirror t = ref.type;

        XmlJavaTypeAdapter xjta = ref.annotations.getAnnotation(XmlJavaTypeAdapter.class);
        XmlList xl = ref.annotations.getAnnotation(XmlList.class);

        builder.getTypeInfo(new Ref<TypeMirror, TypeElement>(builder, t, xjta, xl));
    }

    TypeInfoSet<TypeMirror, TypeElement, VariableElement, ExecutableElement> r = builder.link();
    if(r==null)     return null;

    if(additionalElementDecls==null)
        additionalElementDecls = Collections.emptyMap();
    else {
        // fool proof check
        for (Map.Entry<QName, ? extends Reference> e : additionalElementDecls.entrySet()) {
            if(e.getKey()==null)
                throw new IllegalArgumentException("nulls in additionalElementDecls");
        }
    }
    return new JAXBModelImpl(r, builder.reader, rootClasses, new HashMap<QName, Reference>(additionalElementDecls));
}
 
源代码9 项目: TencentKona-8   文件: Adapter.java
public Adapter(
    XmlJavaTypeAdapter spec,
    AnnotationReader<TypeT,ClassDeclT,?,?> reader,
    Navigator<TypeT,ClassDeclT,?,?> nav) {

    this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
}
 
源代码10 项目: nifi-registry   文件: ExtensionRepoVersion.java
@XmlElement
@XmlJavaTypeAdapter(LinkAdapter.class)
@ApiModelProperty(value = "The WebLink to view the metadata about the extensions contained in the extension bundle.",
        dataType = "org.apache.nifi.registry.link.JaxbLink", readOnly = true)
public Link getExtensionsLink() {
    return extensionsLink;
}
 
源代码11 项目: nifi   文件: BulletinDTO.java
/**
 * @return When this bulletin was generated as a formatted string
 */
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
        value = "When this bulletin was generated.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
源代码12 项目: localization_nifi   文件: ProvenanceNodeDTO.java
/**
 * @return timestamp of this node
 */
@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the node formatted.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
源代码13 项目: rice   文件: RoleTypeService.java
/**
 * Gets whether a role membership with the given details is applicable for the given qualification.
 *
 * @param qualification the qualification.  cannot be null.
 * @param roleMemberships the list of roleMemberships to check for matches. cannot be null.
 * @return an immutable list of matched roleMemberships.  will not return null.
 * @throws RiceIllegalArgumentException if the qualification or roleMemberships is null.
 */
@WebMethod(operationName="getMatchingRoleMemberships")
@XmlElementWrapper(name = "roleMemberships", required = true)
@XmlElement(name = "roleMembership", required = false)
@WebResult(name = "roleMemberships")
List<RoleMembership> getMatchingRoleMemberships(@WebParam(name = "qualification")
                                                @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
                                                Map<String, String> qualification,
                                                @WebParam(name = "roleMemberships")
                                                List<RoleMembership> roleMemberships) throws RiceIllegalArgumentException;
 
源代码14 项目: openjdk-8-source   文件: Adapter.java
public Adapter(
    XmlJavaTypeAdapter spec,
    AnnotationReader<TypeT,ClassDeclT,?,?> reader,
    Navigator<TypeT,ClassDeclT,?,?> nav) {

    this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
}
 
源代码15 项目: rice   文件: RoleService.java
/**
* This method gets all the members, then traverses down into members of type role and group to obtain the nested principal ids
*
   * @param namespaceCode the namespace code of the role.
   * @param roleName the name of the role
   * @param qualification the qualifications for the roleIds.
   * @return a list of role member principalIds for the given roleIds and qualifications, or an empty list if none found.
   * @throws RiceIllegalArgumentException if namespaceCode, or roleName is null or blank.
*/
  @WebMethod(operationName = "getRoleMemberPrincipalIds")
  @XmlElementWrapper(name = "principalIds", required = true)
  @XmlElement(name = "principalId", required = false)
  @WebResult(name = "principalIds")
  @Cacheable(value= RoleMember.Cache.NAME,
             key="'namespaceCode=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'qualification=' + T(org.kuali.rice.core.api.cache.CacheKeyUtils).mapKey(#p2)",
             condition="!T(org.kuali.rice.kim.api.cache.KimCacheUtils).isDynamicMembshipRoleByNamespaceAndName(#p0, #p1)" )
  Collection<String> getRoleMemberPrincipalIds(@WebParam(name="namespaceCode") String namespaceCode,
              @WebParam(name="roleName") String roleName,
              @WebParam(name="qualification")
              @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
              Map<String, String> qualification)
          throws RiceIllegalArgumentException;
 
源代码16 项目: nifi   文件: ProcessGroupFlowDTO.java
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
    value = "The time the flow for the process group was last refreshed.",
    dataType = "string"
)
public Date getLastRefreshed() {
    return lastRefreshed;
}
 
源代码17 项目: localization_nifi   文件: ProvenanceEventDTO.java
/**
 * @return time the event occurred
 */
@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the event.",
        dataType = "string"
)
public Date getEventTime() {
    return eventTime;
}
 
源代码18 项目: openjdk-jdk8u   文件: JAXBModelImpl.java
private NonElement<TypeMirror, TypeElement> getXmlType(Reference r) {
    if(r==null)
        throw new IllegalArgumentException();

    XmlJavaTypeAdapter xjta = r.annotations.getAnnotation(XmlJavaTypeAdapter.class);
    XmlList xl = r.annotations.getAnnotation(XmlList.class);

    Ref<TypeMirror, TypeElement> ref = new Ref<TypeMirror, TypeElement>(
        reader,types.getNavigator(),r.type,xjta,xl);

    return types.getTypeInfo(ref);
}
 
源代码19 项目: rice   文件: RoleService.java
/**
* Assigns the principal with the given id to the role with the specified
* namespace code and name with the supplied set of qualifications.
   *
   * @param principalId the principalId
   * @param namespaceCode the namespaceCode of the Role
   * @param roleName the name of the role
   * @param qualifications the qualifications for the principalId to be assigned to the role
   * @return newly created/assigned RoleMember.
   * @throws RiceIllegalArgumentException if princialId, namespaceCode or roleName is null or blank.
*/
  @WebMethod(operationName = "assignPrincipalToRole")
  @WebResult(name = "roleMember")
  @CacheEvict(value={Role.Cache.NAME, Permission.Cache.NAME, Responsibility.Cache.NAME, RoleMembership.Cache.NAME, RoleMember.Cache.NAME, DelegateMember.Cache.NAME, RoleResponsibility.Cache.NAME, DelegateType.Cache.NAME }, allEntries = true)
  RoleMember assignPrincipalToRole(@WebParam(name="principalId") String principalId,
              @WebParam(name="namespaceCode")
              String namespaceCode,
              @WebParam(name="roleName")
              String roleName,
              @WebParam(name="qualifications")
              @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
              Map<String, String> qualifications)
          throws RiceIllegalArgumentException;
 
源代码20 项目: localization_nifi   文件: ProcessGroupStatusDTO.java
/**
 * When the status for this process group was calculated.
 *
 * @return The the status was calculated
 */
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
    value = "The time the status for the process group was last refreshed.",
    dataType = "string"
)
public Date getStatsLastRefreshed() {
    return statsLastRefreshed;
}
 
源代码21 项目: nifi-registry   文件: LinkableEntity.java
@XmlElement
@XmlJavaTypeAdapter(LinkAdapter.class)
@ApiModelProperty(value = "An WebLink to this entity.",
        dataType = "org.apache.nifi.registry.link.JaxbLink", readOnly = true)
public Link getLink() {
    return link;
}
 
源代码22 项目: nifi   文件: ProvenanceDTO.java
/**
 * @return time the query was submitted
 */
@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(
        value = "The timestamp when the query was submitted.",
        dataType = "string"
)
public Date getSubmissionTime() {
    return submissionTime;
}
 
源代码23 项目: nifi   文件: AboutDTO.java
/**
 * @return the timezone of the NiFi instance
 */
@XmlJavaTypeAdapter(TimezoneAdapter.class)
@ApiModelProperty(
        value = "The timezone of the NiFi instance.",
        readOnly = true,
        dataType = "string"
)
public Date getTimezone() {
    return timezone;
}
 
源代码24 项目: yes-cart   文件: CartOrderInfoRO.java
@XmlJavaTypeAdapter(StringMapAdapter.class)
@XmlElement(name = "order-details")
public Map<String, String> getDetails() {
    if (this.details == null) {
        this.details = new HashMap<>();
    }
    return this.details;
}
 
源代码25 项目: yes-cart   文件: CartOrderInfoRO.java
@XmlJavaTypeAdapter(CarrierSlaMapAdapter.class)
@XmlElement(name = "carrier-sla-ids")
public Map<String, Long> getCarrierSlaId() {
    if (this.carrierSlaId == null) {
        this.carrierSlaId = new HashMap<>();
    }
    return carrierSlaId;
}
 
源代码26 项目: localization_nifi   文件: ActionDTO.java
/**
 * @return action's timestamp
 */
@XmlJavaTypeAdapter(DateTimeAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the action.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
源代码27 项目: nifi   文件: NodeEventDTO.java
/**
 * @return timestamp of the node event
 */
@XmlJavaTypeAdapter(DateTimeAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the node event.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
源代码28 项目: openjdk-jdk8u-backup   文件: JAXBContextImpl.java
private NonElement<Type,Class> getXmlType(RuntimeTypeInfoSet tis, TypeReference tr) {
    if(tr==null)
        throw new IllegalArgumentException();

    XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
    XmlList xl = tr.get(XmlList.class);

    Ref<Type,Class> ref = new Ref<Type,Class>(annotationReader, tis.getNavigator(), tr.type, xjta, xl );

    return tis.getTypeInfo(ref);
}
 
源代码29 项目: hottub   文件: JAXBModelImpl.java
private NonElement<TypeMirror, TypeElement> getXmlType(Reference r) {
    if(r==null)
        throw new IllegalArgumentException();

    XmlJavaTypeAdapter xjta = r.annotations.getAnnotation(XmlJavaTypeAdapter.class);
    XmlList xl = r.annotations.getAnnotation(XmlList.class);

    Ref<TypeMirror, TypeElement> ref = new Ref<TypeMirror, TypeElement>(
        reader,types.getNavigator(),r.type,xjta,xl);

    return types.getTypeInfo(ref);
}
 
源代码30 项目: sis   文件: DefaultAssociatedResource.java
/**
 * Returns the type of relation between the resources.
 *
 * @return type of relation between the resources.
 */
@XmlElement(name = "associationType", required = true)
@XmlJavaTypeAdapter(DS_AssociationTypeCode.Since2014.class)
@UML(identifier="associationType", obligation=MANDATORY, specification=ISO_19115)
public AssociationType getAssociationType() {
    return associationType;
}
 
 类方法
 同包方法