Class SMOutputContext

java.lang.Object
org.codehaus.staxmate.out.SMOutputContext

public final class SMOutputContext extends Object
Class that encapsulates details about context in which StaxMate output is done. The most important of the details is the stream writer to use (since that is eventually invoked to do the real output), and its properties.

Usually the process of outputting XML content with StaxMate starts by instantiating an SMOutputContext. It can then be used to create output fragments; all of which bind to that context. Context is thus what "connects" various fragments when they are buffered (when there may or may not be child/parent relationships yet defined).

Context is also used (in addition to storing output relevant settings and acting as a fragment factory) as the owner of various other objects, most notable namespaces. All local namespaces are owned by one and only one context.

  • Field Details

    • DEF_NS_STACK_SIZE

      protected static final int DEF_NS_STACK_SIZE
      See Also:
    • NS_EMPTY

      protected static final SMNamespace NS_EMPTY
    • NS_XML

      protected static final SMNamespace NS_XML
    • NS_XMLNS

      protected static final SMNamespace NS_XMLNS
    • sGlobalNsMap

      protected static final HashMap<String,SMNamespace> sGlobalNsMap
    • FALSE_VALUE

      protected static final SMOTypedValue FALSE_VALUE
    • TRUE_VALUE

      protected static final SMOTypedValue TRUE_VALUE
    • _streamWriter

      protected final org.codehaus.stax2.XMLStreamWriter2 _streamWriter
    • _rootNsContext

      protected final NamespaceContext _rootNsContext
    • _cfgRepairing

      protected final boolean _cfgRepairing
    • _nsPrefixPrefix

      protected String _nsPrefixPrefix
      Prefix to use for creating automatic namespace prefixes. For example, setting this to "ns" would result in automatic prefixes of form "ns1", "ns2" and so on.
    • _nsPrefixSeqNr

      protected int _nsPrefixSeqNr
    • _cfgPreferDefaultNs

      protected boolean _cfgPreferDefaultNs
      Configuration flag that specifies whether by default namespaces should bind as the default namespaces for elements or not. If true, all unbound namespaces are always bound as the default namespace, when elements are output: if false, more complicated logics is used (which considers preferred prefixes, past bindings etc).
    • _localNsMap

      protected HashMap<String,SMNamespace> _localNsMap
      Map that contains all local namespaces, that is, namespaces that have been created for use with documents output using this context.
    • _defaultNS

      protected SMNamespace _defaultNS
      Currently active default namespace; one that is in effect within current scope (inside currently open element, if any; if none, within root level).
    • _nsStack

      SMNamespace[] _nsStack
      Stack of bound non-default namespaces.
    • _boundNsCount

      int _boundNsCount
      Number of bound namespaces in _nsStack
    • _currElemNS

      SMNamespace _currElemNS
      Namespace of the last START_ELEMENT output.
    • _indentString

      String _indentString
      This String is null when not doing (heuristic) indentation. Otherwise it defines the longest possible indentation String to use; subset by the offset indexes as necessary.
    • _indentOffset

      int _indentOffset
      Current offset within indentation String, if indenting. Basically offset of the first character after end of indentation String.
    • _indentStep

      int _indentStep
      Number of characters to add to _indentOffset when adding a new indentation level (and conversely, subtract when closing such level).
    • _indentSuppress

      int _indentSuppress
      Counter used to suppress indentation, for levels where text has been output (indicating either pure-text or mixed content). Set to -1 when indentation is disabled. This remains 0 when no explicit text output has been done, and is set to 1 from such a state. After becoming non-zero, it will be incremented by one for each new level (start element output), and subtracted by one for close elements.

      Since this needs to be 0 for any indentation to be output, it is also used as a 'flag' to see if indentation is enabled.

    • _indentLevelEmpty

      boolean _indentLevelEmpty
      This flag is used to prevent indentation from being added for empty leaf elements, which should either be output as empty elements, or start/end tag pair, with no intervening spaces.
  • Constructor Details

    • SMOutputContext

      protected SMOutputContext(org.codehaus.stax2.XMLStreamWriter2 sw, NamespaceContext rootNsCtxt)
  • Method Details