javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter Java Examples

The following examples show how to use javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: PropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: JAXBUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: JAXBUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: WrapperUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: ActionDTO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return action's timestamp
 */
@XmlJavaTypeAdapter(DateTimeAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the action.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
Example #7
Source File: ExtensionRepoVersion.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: RoleTypeService.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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;
 
Example #9
Source File: ProvenanceNodeDTO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return timestamp of this node
 */
@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the node formatted.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
Example #10
Source File: JAXBContextImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: DefaultAssociatedResource.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: ParameterContextsEntity.java    From nifi with Apache License 2.0 5 votes vote down vote up
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
    value = "The current time on the system.",
    dataType = "string",
    readOnly = true
)
public Date getCurrentTime() {
    return currentTime;
}
 
Example #13
Source File: DefaultRepresentativeFraction.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: JavaCompilerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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));
}
 
Example #15
Source File: Adapter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Adapter(
    XmlJavaTypeAdapter spec,
    AnnotationReader<TypeT,ClassDeclT,?,?> reader,
    Navigator<TypeT,ClassDeclT,?,?> nav) {

    this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
}
 
Example #16
Source File: JAXBModelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #17
Source File: BulletinDTO.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #18
Source File: NodeEventDTO.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return timestamp of the node event
 */
@XmlJavaTypeAdapter(DateTimeAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the node event.",
        dataType = "string"
)
public Date getTimestamp() {
    return timestamp;
}
 
Example #19
Source File: CartOrderInfoRO.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
@XmlJavaTypeAdapter(CarrierSlaMapAdapter.class)
@XmlElement(name = "carrier-sla-ids")
public Map<String, Long> getCarrierSlaId() {
    if (this.carrierSlaId == null) {
        this.carrierSlaId = new HashMap<>();
    }
    return carrierSlaId;
}
 
Example #20
Source File: Adapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Adapter(
    XmlJavaTypeAdapter spec,
    AnnotationReader<TypeT,ClassDeclT,?,?> reader,
    Navigator<TypeT,ClassDeclT,?,?> nav) {

    this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
}
 
Example #21
Source File: RoleService.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
* 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;
 
Example #22
Source File: CartOrderInfoRO.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
@XmlJavaTypeAdapter(StringMapAdapter.class)
@XmlElement(name = "order-details")
public Map<String, String> getDetails() {
    if (this.details == null) {
        this.details = new HashMap<>();
    }
    return this.details;
}
 
Example #23
Source File: ProcessGroupFlowDTO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@XmlJavaTypeAdapter(TimeAdapter.class)
@ApiModelProperty(
    value = "The time the flow for the process group was last refreshed.",
    dataType = "string"
)
public Date getLastRefreshed() {
    return lastRefreshed;
}
 
Example #24
Source File: ProvenanceEventDTO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return time the event occurred
 */
@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(
        value = "The timestamp of the event.",
        dataType = "string"
)
public Date getEventTime() {
    return eventTime;
}
 
Example #25
Source File: JAXBModelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: RoleService.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
* 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;
 
Example #27
Source File: AboutDTO.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #28
Source File: ProvenanceDTO.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #29
Source File: ProcessGroupStatusDTO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: LinkableEntity.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@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;
}