Class StringAdapter

All Implemented Interfaces:
AdapterNode, Element, Node

public class StringAdapter extends AbstractAdapterElement

StringAdapter adapts a Java String value to a DOM Element with the specified property name containing the String's text. e.g. a property String getFoo() { return "My Text!"; } will appear in the result DOM as: <foo>MyText!</foo>

Subclasses may override the getStringValue() method in order to use StringAdapter as a simplified custom XML adapter for Java types. A subclass can enable XML parsing of the value string via the setParseStringAsXML() method and then override getStringValue() to return a String containing the custom formatted XML.

  • Constructor Details

  • Method Details

    • getStringValue

      protected String getStringValue()

      Get the object to be adapted as a String value.

      This method can be overridden by subclasses that wish to use StringAdapter as a simplified customizable XML adapter for Java types. A subclass can enable parsing of the value string as containing XML text via the setParseStringAsXML() method and then override getStringValue() to return a String containing the custom formatted XML.

      Returns:
      the string value
    • buildChildAdapters

      protected List<Node> buildChildAdapters()
      Description copied from class: AbstractAdapterNode
      subclasses override to produce their children
      Overrides:
      buildChildAdapters in class AbstractAdapterNode
      Returns:
      List of child adapters.
    • getParseStringAsXML

      public boolean getParseStringAsXML()
      Returns:
      is this StringAdapter to interpret its string values as containing XML Text?
      See Also:
    • setParseStringAsXML

      public void setParseStringAsXML(boolean parseStringAsXML)
      When set to true the StringAdapter will interpret its String value as containing XML text and parse it to a DOM Element. The new DOM Element will be a child of this String element. (i.e. wrapped in an element of the property name specified for this StringAdapter).
      Parameters:
      parseStringAsXML - when set to true the StringAdapter will interpret its String value as containing XML text
      See Also: