Annotation Interface Text


@Retention(RUNTIME) public @interface Text
The Text annotation is used to represent a field or method that appears as text within an XML element. Methods and fields annotated with this must represent primitive values, which means that the type is converted to and from an XML representation using a Transform object. For example, the primitive types typically annotated could be strings, integers, or dates.

One restriction on this annotation is that it can only appear once within a schema class, and it can not appear with the another XML element annotations, such as the Element annotation. It can however appear with any number of Attribute annotations.

 
    <example one="value" two="value">
       Example text value       
    </example>
 
 
Text values are used when an element containing attributes is used to wrap a text value with no child elements. This can be used in place of an element annotation to represent a primitive which is wrapped in a surrounding XML element.
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    This is used to determine whether the text is written within CDATA block or not.
    This is used to provide a default value for the text data if the annotated field or method is null.
    boolean
    Determines whether the text value is required within the XML document.
  • Element Details

    • empty

      String empty
      This is used to provide a default value for the text data if the annotated field or method is null. This ensures the the serialization process writes the text data with a value even if the value is null, and allows deserialization to determine whether the value within the object was null or not.
      Returns:
      this returns the default attribute value to use
      Default:
      ""
    • data

      boolean data
      This is used to determine whether the text is written within CDATA block or not. If this is set to true then the text is written within a CDATA block, by default the text is output as escaped XML. Typically this is used for large text values.
      Returns:
      true if the data is to be wrapped in a CDATA block
      Default:
      false
    • required

      boolean required
      Determines whether the text value is required within the XML document. Any field marked as not required may not have its value set when the object is deserialized. If an object is to be serialized only a null attribute will not appear in XML.
      Returns:
      true if the element is required, false otherwise
      Default:
      true