Top Description Methods
org.jdom2.output.support

public Interface Walker

Known Direct Implementers
org.jdom2.output.support.WalkerPRESERVE, org.jdom2.output.support.AbstractFormattedWalker, org.jdom2.output.support.AbstractStAXStreamReader.DocumentWalker
Imports
java.util.NoSuchElementException, org.jdom2.CDATA, .Content, .EntityRef, .Text

A model for walking the (potentially formatted) content of an Element.

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.

Author
Rolf Lear

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if there is more content to be processed
hasNext
()

Behaves similarly to to a regular Iterator

public boolean

Returns:

true if there is no content, or all content is Text
isAllText
()

If all the content in this walker is empty, or if whatever content is available is Text-like.

public boolean

Returns:

true
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.

public boolean

Returns:

true if the current text() is valid, and is CDATA.
isCDATA
()

If the previous next() method returned null, then this will indicate whether the current text() value is CDATA or regular Text.

public Content

Returns:

the next content to be processed, perhaps null if the next content is re-formatted text of some sort (Text / CDATA).
next
()

Similar to an Iterator, but null return values need special treatment.

public String

Returns:

The current text value (null if the previous invocation of next() returned a non-null value).
text
()

If the previous call to next() returned null, then this will return the required text to be processed.

Method Detail

hasNextback to summary
public boolean hasNext()

Behaves similarly to to a regular Iterator

Returns:boolean

true if there is more content to be processed

isAllTextback to summary
public boolean isAllText()

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.

Returns:boolean

true if there is no content, or all content is Text

isAllWhitespaceback to summary
public 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.

Returns:boolean

true

isCDATAback to summary
public boolean isCDATA()

If the previous next() method returned null, then this will indicate whether the current text() value is CDATA or regular Text.

Returns:boolean

true if the current text() is valid, and is CDATA.

Exceptions
IllegalStateException:
if there was not previous call to next()
nextback to summary
public Content next()

Similar to an Iterator, but null return values need special treatment.

Returns:Content

the next content to be processed, perhaps null if the next content is re-formatted text of some sort (Text / CDATA).

Exceptions
NoSuchElementException:
if there is no further content.
textback to summary
public String text()

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.

Returns:String

The current text value (null if the previous invocation of next() returned a non-null value).

Exceptions
IllegalStateException:
if there was not previous call to next()