Class XmlDeclaration

java.lang.Object
tools.jackson.dataformat.xml.ser.XmlDeclaration
All Implemented Interfaces:
XmlGeneratorWritable

public class XmlDeclaration extends Object implements XmlGeneratorWritable
Immutable entity representing an XML Declaration to write (e.g. <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>).

Normal entry point is XmlGeneratorInitializer.addXmlDeclaration(String, String) (and its overloads) rather than constructing this class directly.

Since:
3.2
  • Constructor Details

    • XmlDeclaration

      public XmlDeclaration(String version, String encoding, Boolean standalone)
      Parameters:
      version - XML version: must be non-null, typically "1.0" or "1.1"
      encoding - Encoding to declare; may be null (or empty, treated as null) to omit the encoding pseudo-attribute. Note: when standalone is non-null, a null encoding will be silently substituted with "UTF-8" since the underlying Stax writeStartDocument(version, encoding, standalone) overload requires a non-null encoding.
      standalone - standalone pseudo-attribute value; null means omit the attribute
  • Method Details

    • write

      public void write(ToXmlGenerator xmlGen, org.codehaus.stax2.XMLStreamWriter2 sw) throws XMLStreamException
      Description copied from interface: XmlGeneratorWritable
      Method to call to actually write out the entity using given XMLStreamWriter2. ToXmlGenerator is only passed in case access to configuration was needed.
      Specified by:
      write in interface XmlGeneratorWritable
      Parameters:
      xmlGen - Generator that called this method: MUST NOT call its output methods, only to be used for configuration access
      sw - Writer to use for actual output of XML event
      Throws:
      XMLStreamException