Class MicroText

All Implemented Interfaces:
com.helger.commons.hierarchy.IHasChildren<IMicroNode>, com.helger.commons.hierarchy.IHasChildrenRecursive<IMicroNode>, com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>, com.helger.commons.hierarchy.IHasParent<IMicroNode>, com.helger.commons.lang.ICloneable<IMicroNode>, IMicroDataAware, IMicroNode, IMicroText

public final class MicroText extends AbstractMicroNode implements IMicroText
Default implementation of the IMicroText interface.
Author:
Philip Helger
  • Field Details

    • DEFAULT_IGNORABLE_WHITESPACE

      public static final boolean DEFAULT_IGNORABLE_WHITESPACE
      By default the text is not ignorable whitespaces
      See Also:
    • DEFAULT_ESCAPE

      public static final boolean DEFAULT_ESCAPE
      By default the text should be XML escaped when emitting to a file etc.
      See Also:
  • Constructor Details

  • Method Details

    • getType

      @Nonnull public EMicroNodeType getType()
      Specified by:
      getType in interface IMicroNode
      Returns:
      The node type. Never null.
    • getNodeName

      @Nonnull @Nonempty public String getNodeName()
      Specified by:
      getNodeName in interface IMicroNode
      Returns:
      Just an abstract name that depends on the implementing class. For IMicroElement nodes this is the same as the tag name.
    • getNodeValue

      @Nonnull public String getNodeValue()
      Specified by:
      getNodeValue in interface IMicroNode
      Returns:
      The value of this node. This depends on the concrete implementation class. It is currently implemented for IMicroText, IMicroComment and IMicroEntityReference.
    • getData

      @Nonnull public CharSequence getData()
      Specified by:
      getData in interface IMicroDataAware
      Returns:
      The currently assigned character data. May not be null .
    • appendData

      public void appendData(@Nullable CharSequence sData)
      Description copied from interface: IMicroDataAware
      Append characters to the string.
      Specified by:
      appendData in interface IMicroDataAware
      Parameters:
      sData - The characters to be appended.
    • appendData

      public void appendData(@Nonnull char[] aChars, @Nonnegative int nOfs, @Nonnegative int nLen)
      Description copied from interface: IMicroDataAware
      Append characters to the string.
      Specified by:
      appendData in interface IMicroDataAware
      Parameters:
      aChars - Base character array. May not be null.
      nOfs - Offset to start copying. Must be ≥ 0.
      nLen - Number of chars to take. Must be ≥ 0.
    • appendData

      public void appendData(char cChar)
      Description copied from interface: IMicroDataAware
      Append a character to the string.
      Specified by:
      appendData in interface IMicroDataAware
      Parameters:
      cChar - The character to append
    • prependData

      public void prependData(@Nullable CharSequence sData)
      Description copied from interface: IMicroDataAware
      Add characters to the beginning of the current data.
      Specified by:
      prependData in interface IMicroDataAware
      Parameters:
      sData - The characters to be added at the front.
    • prependData

      public void prependData(@Nonnull char[] aChars, @Nonnegative int nOfs, @Nonnegative int nLen)
      Description copied from interface: IMicroDataAware
      Add characters to the beginning of the current data.
      Specified by:
      prependData in interface IMicroDataAware
      Parameters:
      aChars - Base character array. May not be null.
      nOfs - Offset to start copying. Must be ≥ 0.
      nLen - Number of chars to take. Must be ≥ 0.
    • prependData

      public void prependData(char cChar)
      Description copied from interface: IMicroDataAware
      Add a character to the beginning of the current data.
      Specified by:
      prependData in interface IMicroDataAware
      Parameters:
      cChar - The character to preprend
    • setData

      public void setData(@Nullable CharSequence sData)
      Description copied from interface: IMicroDataAware
      Change the character sequence. Any previously set characters are lost.
      Specified by:
      setData in interface IMicroDataAware
      Parameters:
      sData - The new character sequence to be set.
    • isElementContentWhitespace

      public boolean isElementContentWhitespace()
      Description copied from interface: IMicroText
      Check whether the text node consists solely of whitespaces. This may be helpful in detecting XML that has been indented :)
      Specified by:
      isElementContentWhitespace in interface IMicroText
      Returns:
      true if the text node consists solely of whitespaces (blank, tab etc.).
    • isEscape

      public boolean isEscape()
      Specified by:
      isEscape in interface IMicroText
      Returns:
      true if the content of this text node should be masked, and false if not. By default a text node should always be masked.
    • setEscape

      @Nonnull public MicroText setEscape(boolean bEscape)
    • getClone

      @Nonnull public IMicroText getClone()
      Description copied from interface: IMicroText
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<IMicroNode>
      Specified by:
      getClone in interface IMicroText
    • isEqualContent

      public boolean isEqualContent(@Nullable IMicroNode o)
      Description copied from interface: IMicroNode
      As instances of this class may not implement equals/hashCode we need a way to determine, if 2 nodes are equal by content.
      Specified by:
      isEqualContent in interface IMicroNode
      Parameters:
      o - The node to compare to this.
      Returns:
      true if the nodes are of the same type and the same content, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractMicroNode