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

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

源代码1 项目: proarc   文件: TaskParameter.java
@XmlValue
/* Jackson 2.0 ignores @XmlValue for methods and thus @JsonProperty. */
@JsonProperty
public String getValue() {
    String value = null;
    if (valueType == ValueType.NUMBER) {
        BigDecimal n = getValueNumber();
        value = n == null ? null : n.toPlainString();
    } else if (valueType == ValueType.DATETIME) {
        Timestamp t = getValueDateTime();
        if (t != null) {
            value = ISODateTimeFormat.dateTime().withZoneUTC().print(t.getTime());
        }
    } else if (valueType == ValueType.STRING) {
        value = getValueString();
    } else {
        throw new IllegalStateException("Unsupported type: " + valueType);
    }
    return value;
}
 
源代码2 项目: TencentKona-8   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码3 项目: jdk8u60   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码4 项目: openjdk-jdk8u   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码5 项目: openjdk-jdk9   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码6 项目: hottub   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码7 项目: openjdk-8-source   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码8 项目: openjdk-8   文件: AbstractField.java
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    /*
    TODO: consider moving this logic to somewhere else
    so that it can be better shared, for how a field gets
    annotated doesn't really depend on how we generate accessors.

    so perhaps we should separate those two.
    */

    // TODO: consider a visitor
    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);

    QName st = prop.getSchemaType();
    if(st!=null)
        field.annotate2(XmlSchemaTypeWriter.class)
            .name(st.getLocalPart())
            .namespace(st.getNamespaceURI());

    if(prop.inlineBinaryData())
        field.annotate(XmlInlineBinaryData.class);
}
 
源代码9 项目: c2mon   文件: DOMFactory.java
/**
 * Generates an xml element from this pojo. Translating the fields like described
 * in the class description.
 * @param document The document in which the nodes should be.
 * @param rootName This is to use another name for the root element than the
 * simple class name.
 * @param pojo The pojo to take the fields from.
 * @param attributes The fields which should be used as attributes and not
 * as elements.
 * @return The create element representing the provided pojo.
 * @throws ParserConfigurationException Might throw a ParserConfigurationException.
 * @throws IllegalAccessException Might throw a IllegalAccessException.
 * @throws InstantiationException Might throw a InstantiationException.
 */
public Element generateSimpleElement(final Document document, final String rootName,
        final Object pojo, final List<String> attributes) 
        throws ParserConfigurationException,
        IllegalAccessException, InstantiationException {
    Element rootNode = document.createElementNS(getDefaultNamespace(), rootName);
    List<Field> fields = getNonTransientSimpleFields(pojo.getClass());
    for (Field field : fields) {            
        field.setAccessible(true);
        String fieldName = field.getName();
                                
        if (field.get(pojo) != null) {
            
            if (!attributes.contains(fieldName)) {
                
                Element element = document.createElementNS(getDefaultNamespace(), getElementName(field));
                
                // handle CDATAs
                if (field.isAnnotationPresent(XmlValue.class)) {
                    CDATASection cdata = document.createCDATASection(field.get(pojo).toString());
                    element.appendChild(cdata);
                }
                else {
                  element.setTextContent(field.get(pojo).toString());                    
                }
                
                rootNode.appendChild(element);                    
            }
            else {
                rootNode.setAttribute(getAttributeName(field), field.get(pojo).toString());
            }
        }
    }
    return rootNode;
}
 
源代码10 项目: ph-ubl   文件: MainFindOccurrances.java
/**
 * Create an XML name from the passed field. It uses the {@link XmlElement},
 * {@link XmlAttribute} and {@link XmlValue} annotations to differentiate.
 *
 * @param aField
 *        Source field
 * @return Never <code>null</code>.
 */
@Nonnull
public static String _getXMLName (@Nonnull final Field aField)
{
  final XmlElement aElement = aField.getAnnotation (XmlElement.class);
  if (aElement != null)
    return "/" + aElement.name ();
  final XmlAttribute aAttr = aField.getAnnotation (XmlAttribute.class);
  if (aAttr != null)
    return "/@" + aAttr.name ();
  if (aField.getAnnotation (XmlValue.class) != null)
    return "/value()";
  throw new IllegalStateException ("Field is neither XML element nor attribute nor value: " + aField);
}
 
源代码11 项目: sis   文件: DefaultRecordType.java
/**
 * Returns the record type value as a string. Current implementation returns the members with
 * one member per line, but it may change in any future version for adapting to common practice.
 */
@XmlValue
private String getValue() {
    switch (size()) {
        case 0:  return null;
        case 1:  return String.valueOf(memberTypes[0]);
        default: return toString(null, null);
    }
}
 
源代码12 项目: sis   文件: DefaultRecord.java
/**
 * Returns the record value as a string.
 */
@XmlValue
private String getValue() {
    if (values != null) {
        switch (Array.getLength(values)) {
            case 0:  break;
            case 1:  return String.valueOf(Array.get(values, 0));
            default: return definition.toString(null, values);
        }
    }
    return null;
}
 
源代码13 项目: micro-integrator   文件: JNDIConfig.java
@XmlValue
public String getValue() {
	return value;
}
 
源代码14 项目: micro-integrator   文件: RDBMSConfiguration.java
@XmlValue
public String getValue() {
	return value;
}
 
源代码15 项目: micro-integrator   文件: RDBMSConfiguration.java
@XmlValue
public String getValue() {
	return value;
}
 
源代码16 项目: TencentKona-8   文件: XmlValueQuick.java
public XmlValueQuick(Locatable upstream, XmlValue core) {
    super(upstream);
    this.core = core;
}
 
源代码17 项目: TencentKona-8   文件: XmlValueQuick.java
protected Quick newInstance(Locatable upstream, Annotation core) {
    return new XmlValueQuick(upstream, ((XmlValue) core));
}
 
源代码18 项目: sissi   文件: Type.java
@XmlValue
public String getText() {
	return value;
}
 
源代码19 项目: sissi   文件: TimeTzo.java
@XmlValue
public String getText() {
	return text;
}
 
源代码20 项目: sissi   文件: Group.java
@XmlValue
public String getValue() {
	return this.value == null || this.value.isEmpty() ? null : this.value;
}
 
源代码21 项目: jdk8u60   文件: XmlValueQuick.java
public Class<XmlValue> annotationType() {
    return XmlValue.class;
}
 
源代码22 项目: openjdk-jdk8u   文件: XmlValueQuick.java
public XmlValueQuick(Locatable upstream, XmlValue core) {
    super(upstream);
    this.core = core;
}
 
源代码23 项目: openjdk-jdk8u   文件: XmlValueQuick.java
protected Quick newInstance(Locatable upstream, Annotation core) {
    return new XmlValueQuick(upstream, ((XmlValue) core));
}
 
源代码24 项目: openjdk-jdk8u   文件: XmlValueQuick.java
public Class<XmlValue> annotationType() {
    return XmlValue.class;
}
 
源代码25 项目: reladomo-scala   文件: MithraObject.java
@XmlValue
public String getClause() {
    return clause;
}
 
源代码26 项目: sissi   文件: Desc.java
@XmlValue
public String getText() {
	return this.text;
}
 
源代码27 项目: staedi   文件: TransactionBindTest.java
Class<?> classForValue(Class<?> bean) {
    return getAnnotatedClass(bean, XmlValue.class, a -> true);
}
 
源代码28 项目: openjdk-jdk8u-backup   文件: XmlValueQuick.java
public XmlValueQuick(Locatable upstream, XmlValue core) {
    super(upstream);
    this.core = core;
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: XmlValueQuick.java
protected Quick newInstance(Locatable upstream, Annotation core) {
    return new XmlValueQuick(upstream, ((XmlValue) core));
}
 
源代码30 项目: openjdk-jdk8u-backup   文件: XmlValueQuick.java
public Class<XmlValue> annotationType() {
    return XmlValue.class;
}
 
 同包方法