Class FormatStack

java.lang.Object
org.jdom2.output.support.FormatStack

public final class FormatStack extends 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 Details

    • 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 Details

    • getIndent

      public String getIndent()
      Returns:
      the original Format.getIndent(), may be null
    • getLineSeparator

      public String getLineSeparator()
      Returns:
      the original Format.getLineSeparator()
    • getEncoding

      public 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 String getLevelIndent()
      Returns:
      the current depth's accumulated/maintained indent, may be null
    • getPadBetween

      public 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 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(String indent)
      Override the current depth's accumulated line indent.
      Parameters:
      indent - the indent to set.
    • getLevelEOL

      public String getLevelEOL()
      Returns:
      the current depth's End-Of-Line sequence, may be null
    • setLevelEOL

      public void setLevelEOL(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.