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

    The value this class adds is:

    • Fast -
    Since:
    JDOM2
    • 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

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