JDOM
2.0.5

org.jdom2.output.support
Class FormatStack

java.lang.Object
  extended by 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 inly public so that people extending the Abstract*Processor classes can take advantage of it's functionality.

The value this class adds is:

Since:
JDOM2
Author:
Rolf Lear

Constructor Summary
FormatStack(Format format)
          Creates a new FormatStack seeded with the specified Format
 
Method Summary
 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 Element
 Format.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's Format.getIgnoreTrAXEscapingPIs()
 void setLevelEOL(java.lang.String newline)
          Set the current depth's End-Of-Line sequence
 void setLevelIndent(java.lang.String indent)
          Override the current depth's accumulated line indent.
 void setTextMode(Format.TextMode mode)
          Change the current level's TextMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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's Format.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.


JDOM
2.0.5

Copyright � 2013 Jason Hunter, Brett McLaughlin. All Rights Reserved.