Package org.jdom2.output.support
Class FormatStack
- java.lang.Object
-
- org.jdom2.output.support.FormatStack
-
public final class FormatStack extends java.lang.Object
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
Constructors Constructor Description FormatStack(Format format)
Creates a new FormatStack seeded with the specified Format
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Format.TextMode
getDefaultMode()
java.lang.String
getEncoding()
boolean
getEscapeOutput()
The escapeOutput flag can be set or unset.EscapeStrategy
getEscapeStrategy()
java.lang.String
getIndent()
java.lang.String
getLevelEOL()
java.lang.String
getLevelIndent()
java.lang.String
getLineSeparator()
java.lang.String
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)java.lang.String
getPadLast()
Get the end-of-line indenting sequence for after the last item in an ElementFormat.TextMode
getTextMode()
boolean
isExpandEmptyElements()
boolean
isIgnoreTrAXEscapingPIs()
boolean
isOmitDeclaration()
boolean
isOmitEncoding()
boolean
isSpecifiedAttributesOnly()
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(java.lang.String newline)
Set the current depth's End-Of-Line sequencevoid
setLevelIndent(java.lang.String indent)
Override the current depth's accumulated line indent.void
setTextMode(Format.TextMode mode)
Change the current level's TextMode
-
-
-
Constructor Detail
-
FormatStack
public FormatStack(Format format)
Creates a new FormatStack seeded with the specified Format- Parameters:
format
- the Format instance to seed the stack with.
-
-
Method Detail
-
getIndent
public java.lang.String getIndent()
- Returns:
- the original
Format.getIndent()
, may be null
-
getLineSeparator
public java.lang.String getLineSeparator()
- Returns:
- the original
Format.getLineSeparator()
-
getEncoding
public java.lang.String 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
public EscapeStrategy 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
public Format.TextMode getDefaultMode()
- Returns:
- the TextMode that was originally set for this stack before any modifications.
-
getLevelIndent
public java.lang.String getLevelIndent()
- Returns:
- the current depth's accumulated/maintained indent, may be null
-
getPadBetween
public java.lang.String 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
public java.lang.String 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
public void setLevelIndent(java.lang.String indent)
Override the current depth's accumulated line indent.- Parameters:
indent
- the indent to set.
-
getLevelEOL
public java.lang.String getLevelEOL()
- Returns:
- the current depth's End-Of-Line sequence, may be null
-
setLevelEOL
public void setLevelEOL(java.lang.String newline)
Set the current depth's End-Of-Line sequence- Parameters:
newline
- the new End-Of-Line sequence to set.
-
getTextMode
public Format.TextMode getTextMode()
- Returns:
- the current depth's
Format.getTextMode()
-
setTextMode
public void setTextMode(Format.TextMode mode)
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.
-
-