public interface Walker
Implementations of this class restructure the content to a particular format and expose the restructured content in this 'Walker' which is a loose equivalent to an iterator.
The next() method will return a Content instance (perhaps null) if there is more content. If the returned content is null, then there will be some formatted characters available in the text() method. These characters may need to be represented as CDATA (check the isCDATA() method).
Not all CDATA and Text nodes need to be reformatted, and as a result they may be returned as their original CDATA or Text instances instead of using the formatted text() / isCDATA() mechanism.
The 'Rules' for the walkers are that no padding is done before the first content step, and no padding is done after the last content step (but the first/last content items may be trimmed to the correct format). Any required padding will be done in plain text (not CDATA) content. Consecutive CDATA sections may be separated by whitespace text for example.
Modifier and Type | Method and 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 (
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.
|
java.lang.String |
text()
If the previous call to next() returned null, then this will return the
required text to be processed.
|
boolean isAllText()
Text-like content is considered to be Text
, CDATA
,
EntityRef
, or any (potentially mixed) sequence of these types,
but no other types.
boolean isAllWhitespace()
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 hasNext()
Content next()
java.util.NoSuchElementException
- if there is no further content.java.lang.String text()
java.lang.IllegalStateException
- if there was not previous call to next()boolean isCDATA()
java.lang.IllegalStateException
- if there was not previous call to next()Copyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.