Class WalkerPRESERVE

  • All Implemented Interfaces:
    Walker

    public class WalkerPRESERVE
    extends Object
    implements Walker
    This Walker implementation walks a list of Content in it's original RAW format. There is no text manipulation, and all content will be returned as the input type. In other words, next() will never be null, and text() will always be null.
    • Constructor Summary

      Constructors 
      Constructor Description
      WalkerPRESERVE​(List<? extends Content> content)
      Create a Walker that preserves all content in its raw state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Behaves similarly to to a regular Iterator
      boolean isAllText()
      If all the content in this walker is empty, or if whatever content is available is Text-like.
      boolean isAllWhitespace()
      If all the content is Text-like (Walker.isAllText() returns true), and additionally that any content is either Text or CDATA, and that the values of these Text/CDATA members are all XML Whitespace.
      boolean isCDATA()
      If the previous next() method returned null, then this will indicate whether the current text() value is CDATA or regular Text.
      Content next()
      Similar to an Iterator, but null return values need special treatment.
      String text()
      If the previous call to next() returned null, then this will return the required text to be processed.
    • Constructor Detail

      • WalkerPRESERVE

        public WalkerPRESERVE​(List<? extends Content> content)
        Create a Walker that preserves all content in its raw state.
        Parameters:
        content - the content to walk.
    • Method Detail

      • isAllText

        public boolean isAllText()
        Description copied from interface: Walker
        If all the content in this walker is empty, or if whatever content is available is Text-like.

        Text-like content is considered to be Text, CDATA, EntityRef, or any (potentially mixed) sequence of these types, but no other types.

        Specified by:
        isAllText in interface Walker
        Returns:
        true if there is no content, or all content is Text
      • hasNext

        public boolean hasNext()
        Description copied from interface: Walker
        Behaves similarly to to a regular Iterator
        Specified by:
        hasNext in interface Walker
        Returns:
        true if there is more content to be processed
      • next

        public Content next()
        Description copied from interface: Walker
        Similar to an Iterator, but null return values need special treatment.
        Specified by:
        next in interface Walker
        Returns:
        the next content to be processed, perhaps null if the next content is re-formatted text of some sort (Text / CDATA).
      • text

        public String text()
        Description copied from interface: Walker
        If the previous call to next() returned null, then this will return the required text to be processed. Check to see whether this text is CDATA by calling the isCDATA() method.
        Specified by:
        text in interface Walker
        Returns:
        The current text value (null if the previous invocation of next() returned a non-null value).
      • isCDATA

        public boolean isCDATA()
        Description copied from interface: Walker
        If the previous next() method returned null, then this will indicate whether the current text() value is CDATA or regular Text.
        Specified by:
        isCDATA in interface Walker
        Returns:
        true if the current text() is valid, and is CDATA.
      • isAllWhitespace

        public boolean isAllWhitespace()
        Description copied from interface: Walker
        If all the content is Text-like (Walker.isAllText() returns true), and additionally that any content is either Text or CDATA, and that the values of these Text/CDATA members are all XML Whitespace.
        Specified by:
        isAllWhitespace in interface Walker
        Returns:
        true