Package org.jdom2.output.support
Class FormatStack
java.lang.Object
org.jdom2.output.support.FormatStack
FormatStack implements a mechanism where the formatting details can be
changed mid-tree, but then get reverted when that tree segment is
complete.
This class is intended as a working-class for in the various outputter implementations. It is only public so that people extending the Abstract*Processor classes can take advantage of its functionality.
The value this class adds is:
- Fast -
- Since:
- JDOM2
- Author:
- Rolf Lear
-
Constructor Summary
ConstructorsConstructorDescriptionFormatStack
(Format format) Creates a new FormatStack seeded with the specified Format -
Method Summary
Modifier and TypeMethodDescriptionboolean
The escapeOutput flag can be set or unset.Get the end-of-line indenting sequence for before the first item in an Element, as well as between subsequent items (but not after the last item)Get the end-of-line indenting sequence for after the last item in an Elementboolean
boolean
boolean
boolean
boolean
Indicate whether only those Attributes specified in the XML should be output.void
pop()
Move back a level on the stack.void
push()
Create a new depth level on the stack.void
setEscapeOutput
(boolean escape) The escapeOutput flag can be set or unset.void
setIgnoreTrAXEscapingPIs
(boolean ignoreTrAXEscapingPIs) Set the current depth'sFormat.getIgnoreTrAXEscapingPIs()
void
setLevelEOL
(String newline) Set the current depth's End-Of-Line sequencevoid
setLevelIndent
(String indent) Override the current depth's accumulated line indent.void
setTextMode
(Format.TextMode mode) Change the current level's TextMode
-
Constructor Details
-
FormatStack
Creates a new FormatStack seeded with the specified Format- Parameters:
format
- the Format instance to seed the stack with.
-
-
Method Details
-
getIndent
- Returns:
- the original
Format.getIndent()
, may be null
-
getLineSeparator
- Returns:
- the original
Format.getLineSeparator()
-
getEncoding
- Returns:
- the original
Format.getEncoding()
-
isOmitDeclaration
public boolean isOmitDeclaration()- Returns:
- the original
Format.getOmitDeclaration()
-
isSpecifiedAttributesOnly
public boolean isSpecifiedAttributesOnly()Indicate whether only those Attributes specified in the XML should be output.- Returns:
- true if only the specified Attributes should be output, false if those Attributes defaulted from the DTD or XML schema should be output too.
-
isOmitEncoding
public boolean isOmitEncoding()- Returns:
- the original
Format.getOmitEncoding()
-
isExpandEmptyElements
public boolean isExpandEmptyElements()- Returns:
- the original
Format.getExpandEmptyElements()
-
getEscapeStrategy
- Returns:
- the original
Format.getEscapeStrategy()
-
isIgnoreTrAXEscapingPIs
public boolean isIgnoreTrAXEscapingPIs()- Returns:
- the current depth's
Format.getIgnoreTrAXEscapingPIs()
-
setIgnoreTrAXEscapingPIs
public void setIgnoreTrAXEscapingPIs(boolean ignoreTrAXEscapingPIs) Set the current depth'sFormat.getIgnoreTrAXEscapingPIs()
- Parameters:
ignoreTrAXEscapingPIs
- the boolean value to set.
-
getEscapeOutput
public boolean getEscapeOutput()The escapeOutput flag can be set or unset. When set, Element text and Attribute values are 'escaped' so that the output is valid XML. When unset, the Element text and Attribute values are not escaped.- Returns:
- the current depth's escapeOutput flag.
-
setEscapeOutput
public void setEscapeOutput(boolean escape) The escapeOutput flag can be set or unset. When set, Element text and Attribute values are 'escaped' so that the output is valid XML. When unset, the Element text and Attribute values are not escaped.- Parameters:
escape
- what to set the current level's escapeOutput flag to.
-
getDefaultMode
- Returns:
- the TextMode that was originally set for this stack before any modifications.
-
getLevelIndent
- Returns:
- the current depth's accumulated/maintained indent, may be null
-
getPadBetween
Get the end-of-line indenting sequence for before the first item in an Element, as well as between subsequent items (but not after the last item)- Returns:
- the String EOL sequence followed by an indent. Null if it should be ignored
-
getPadLast
Get the end-of-line indenting sequence for after the last item in an Element- Returns:
- the String EOL sequence followed by an indent. Null if it should be ignored
-
setLevelIndent
Override the current depth's accumulated line indent.- Parameters:
indent
- the indent to set.
-
getLevelEOL
- Returns:
- the current depth's End-Of-Line sequence, may be null
-
setLevelEOL
Set the current depth's End-Of-Line sequence- Parameters:
newline
- the new End-Of-Line sequence to set.
-
getTextMode
- Returns:
- the current depth's
Format.getTextMode()
-
setTextMode
Change the current level's TextMode- Parameters:
mode
- the new mode to set.
-
push
public void push()Create a new depth level on the stack. The previous level's details are copied to this level, and the accumulated indent (if any) is indented further. -
pop
public void pop()Move back a level on the stack.
-