The JDOM content can be loosely categorised in to 'Text-like' content (consisting of Text, CDATA, and EntityRef), and everything else. This distinction is significant for for this class and its sub-classes.
There will be text manipulation, and some (but not necessarily all) Text-like content will be returned as text() instead of next().
The trick in this class is that it deals with the regular content, and delegates the Text-like content to the sub-classes.
Subclasses are tasked with analysing chunks of Text-like content in the
analyzeMultiText(MultiText, int, int) method. The subclasses are
responsible for adding the relevant text content to the suppliedMultiText
instance in such a way as to result in the correct format.
The Subclass needs to concern itself with only the text portion because this abstract class will ensure the Text-like content is appropriately indented.
| Modifier and Type | Class and Description |
|---|---|
| protected class | AbstractFormattedWalker.MultiText
Collect together the items that constitute formatted Text-like content. |
| protected static enum | AbstractFormattedWalker.Trim
Indicate how text content should be added |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final boolean | |
| private static final CDATA | |
| private final Iterator | |
| private static final Iterator | |
| private final String | |
| private final EscapeStrategy | |
| private final FormatStack | |
| private boolean | |
| private final AbstractFormattedWalker. | |
| private final StringBuilder | |
| private Content[] | |
| private boolean | |
| private int | |
| private boolean | |
| private int | |
| private Content[] | |
| private int | |
| private String[] | |
| private Boolean | |
| private AbstractFormattedWalker. | |
| private final String | |
| private Content | |
| private AbstractFormattedWalker. |
| Access | Constructor and Description |
|---|---|
| public | AbstractFormattedWalker(final List<? extends Content>
the content to walk. xx, final FormatStack the current FormatStack fstack, final boolean Whether Text values should be escaped. doescape)Create a Walker that preserves all content in its raw state. |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract void | analyzeMultiText(AbstractFormattedWalker.
the MultiText to append to. mtext,The first Text-like content to add to the MultiText offset, int The number of Text-like content items to add. len)Add the content at the specified indices to the provided MultiText. |
| private final AbstractFormattedWalker. | Returns: The updated MultiText containing the correct sequence of Text-like contentThis method was changed in 2.0.5 It now is only called when building the content of the variable pendingmt This is important, because only pendingmt can be referenced when analyzing the MultiText content. |
| protected final Content | Returns: the content at the index.the index to get the content at. index)Get the content at a position in the input content. |
| public final boolean | hasNext()
Implements org. |
| public final boolean | isAllText()
Implements org. |
| public final boolean | isAllWhitespace()
Implements org. 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 final boolean | isCDATA()
Implements org. |
| private final boolean | |
| public final Content | next()
Implements org. |
| private void | |
| public final String | text()
Implements org. |
| alltext | back to summary |
|---|---|
| private final boolean alltext | |
| allwhite | back to summary |
|---|---|
| private final boolean allwhite | |
| CDATATOKEN | back to summary |
|---|---|
| private static final CDATA CDATATOKEN | |
| content | back to summary |
|---|---|
| private final Iterator<? extends Content> content | |
| EMPTYIT | back to summary |
|---|---|
| private static final Iterator<Content> EMPTYIT | |
| endofline | back to summary |
|---|---|
| private final String endofline | |
| escape | back to summary |
|---|---|
| private final EscapeStrategy escape | |
| fstack | back to summary |
|---|---|
| private final FormatStack fstack | |
| hasnext | back to summary |
|---|---|
| private boolean hasnext | |
| holdingmt | back to summary |
|---|---|
| private final AbstractFormattedWalker. | |
| mtbuffer | back to summary |
|---|---|
| private final StringBuilder mtbuffer | |
| mtdata | back to summary |
|---|---|
| private Content[] mtdata | |
| mtgottext | back to summary |
|---|---|
| private boolean mtgottext | |
| mtpos | back to summary |
|---|---|
| private int mtpos | |
| mtpostpad | back to summary |
|---|---|
| private boolean mtpostpad | |
| mtsize | back to summary |
|---|---|
| private int mtsize | |
| mtsource | back to summary |
|---|---|
| private Content[] mtsource | |
| mtsourcesize | back to summary |
|---|---|
| private int mtsourcesize | |
| mttext | back to summary |
|---|---|
| private String[] mttext | |
| mtwasescape | back to summary |
|---|---|
| private Boolean mtwasescape | |
| multitext | back to summary |
|---|---|
| private AbstractFormattedWalker. | |
| newlineindent | back to summary |
|---|---|
| private final String newlineindent | |
| pending | back to summary |
|---|---|
| private Content pending | |
| pendingmt | back to summary |
|---|---|
| private AbstractFormattedWalker. | |
| AbstractFormattedWalker | back to summary |
|---|---|
| public AbstractFormattedWalker(final List<? extends Content> xx, final FormatStack fstack, final boolean doescape) Create a Walker that preserves all content in its raw state.
| |
| analyzeMultiText | back to summary |
|---|---|
| protected abstract void analyzeMultiText(AbstractFormattedWalker. Add the content at the specified indices to the provided MultiText.
| |
| buildMultiText | back to summary |
|---|---|
| private final AbstractFormattedWalker. This method was changed in 2.0.5 It now is only called when building the content of the variable pendingmt This is important, because only pendingmt can be referenced when analyzing the MultiText content.
| |
| get | back to summary |
|---|---|
| protected final Content get(final int index) Get the content at a position in the input content. Useful for subclasses
in their
| |
| hasNext | back to summary |
|---|---|
| public final boolean hasNext() Implements org. Doc from org. Behaves similarly to to a regular Iterator
| |
| isAllText | back to summary |
|---|---|
| public final boolean isAllText() Implements org. Doc from org. 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
| |
| isAllWhitespace | back to summary |
|---|---|
| public final boolean isAllWhitespace() Implements org. Doc from org. If all the content is Text-like (
| |
| isCDATA | back to summary |
|---|---|
| public final boolean isCDATA() Implements org. Doc from org. If the previous next() method returned null, then this will indicate whether the current text() value is CDATA or regular Text.
| |
| isTextLike | back to summary |
|---|---|
| private final boolean isTextLike(final Content c) | |
| next | back to summary |
|---|---|
| public final Content next() Implements org. Doc from org. Similar to an Iterator, but null return values need special treatment. | |
| resetMultiText | back to summary |
|---|---|
| private void resetMultiText() | |
| text | back to summary |
|---|---|
| public final String text() Implements org. Doc from org. 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. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | appendCDATA(final AbstractFormattedWalker.
How to prepare the CDATA content trim,The actual CDATA content. text)Append some text to the text-like sequence that will be treated as CDATA. |
| public void | |
| public void | appendText(final AbstractFormattedWalker.
How to prepare the Text content trim,The actual Text content. text)Append some text to the text-like sequence that will be treated as plain XML text (PCDATA). |
| private void | closeText()
Handle the case where we have been accumulating true text content, and the next item is not more text. |
| public void | |
| private void | |
| private String | |
| private String | |
| private void | forceAppend(final String text)
Simple method that ensures the text is processed, regardless of content, and is never escaped. |
| MultiText | back to summary |
|---|---|
| private MultiText() This is private so only this abstract class can create instances. | |
| appendCDATA | back to summary |
|---|---|
| public void appendCDATA(final AbstractFormattedWalker. Append some text to the text-like sequence that will be treated as CDATA.
| |
| appendRaw | back to summary |
|---|---|
| public void appendRaw(final Content c) Add some JDOM Content (typically an EntityRef) that will be treated as part of the Text-like sequence.
| |
| appendText | back to summary |
|---|---|
| public void appendText(final AbstractFormattedWalker. Append some text to the text-like sequence that will be treated as plain XML text (PCDATA). If the last content added to this text-like sequence then this new text will be appended directly to the previous text.
| |
| closeText | back to summary |
|---|---|
| private void closeText() Handle the case where we have been accumulating true text content, and the next item is not more text. | |
| done | back to summary |
|---|---|
| public void done() Indicate that there is no further content to be added to the text-like sequence. | |
| ensurespace | back to summary |
|---|---|
| private void ensurespace() Ensure we have space for at least one more text-like item. | |
| escapeCDATA | back to summary |
|---|---|
| private String escapeCDATA(final String text) | |
| escapeText | back to summary |
|---|---|
| private String escapeText(final String text) | |
| forceAppend | back to summary |
|---|---|
| private void forceAppend(final String text) Simple method that ensures the text is processed, regardless of content, and is never escaped. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final AbstractFormattedWalker. | BOTH
Both Trim |
| public static final AbstractFormattedWalker. | COMPACT
Trim Both and replace all internal whitespace with a single space |
| public static final AbstractFormattedWalker. | LEFT
Left Trim |
| public static final AbstractFormattedWalker. | NONE
No Trimming at all |
| public static final AbstractFormattedWalker. | RIGHT
Right Trim |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static AbstractFormattedWalker. | |
| public static AbstractFormattedWalker. |
| BOTH | back to summary |
|---|---|
| public static final AbstractFormattedWalker. Both Trim | |
| COMPACT | back to summary |
|---|---|
| public static final AbstractFormattedWalker. Trim Both and replace all internal whitespace with a single space | |
| LEFT | back to summary |
|---|---|
| public static final AbstractFormattedWalker. Left Trim | |
| NONE | back to summary |
|---|---|
| public static final AbstractFormattedWalker. No Trimming at all | |
| RIGHT | back to summary |
|---|---|
| public static final AbstractFormattedWalker. Right Trim | |
| Trim | back to summary |
|---|---|
| private Trim() | |
| valueOf | back to summary |
|---|---|
| public static AbstractFormattedWalker. | |
| values | back to summary |
|---|---|
| public static AbstractFormattedWalker. | |