Class Format

java.lang.Object
org.simpleframework.xml.stream.Format

public class Format extends Object
The Format object is used to provide information on how a generated XML document should be structured. The information provided tells the formatter whether an XML prolog is required and the number of spaces that should be used for indenting. The prolog specified will be written directly before the XML document.

Should a Format be created with an indent of zero or less then no indentation is done, and the generated XML will be on the same line. The prolog can contain any legal XML heading, which can domain a DTD declaration and XML comments if required.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Represents the indent size to use for the generated XML.
    private final String
    Represents the prolog that appears in the generated XML.
    private final Style
    This is the style that is used internally by the format.
    private final Verbosity
    This is used to determine the verbosity preference of XML.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Format object.
    Format(int indent)
    Constructor for the Format object.
    Format(int indent, String prolog)
    Constructor for the Format object.
    Format(int indent, String prolog, Style style)
    Constructor for the Format object.
    Format(int indent, String prolog, Style style, Verbosity verbosity)
    Constructor for the Format object.
    Format(int indent, Style style)
    Constructor for the Format object.
    Format(int indent, Style style, Verbosity verbosity)
    Constructor for the Format object.
    Format(int indent, Verbosity verbosity)
    Constructor for the Format object.
    Format(String prolog)
    Constructor for the Format object.
    Format(Style style)
    Constructor for the Format object.
    Format(Style style, Verbosity verbosity)
    Constructor for the Format object.
    Format(Verbosity verbosity)
    Constructor for the Format object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This method returns the size of the indent to use for the XML generated.
    This method returns the prolog that is to be used at the start of the generated XML document.
    This is used to acquire the Style for the format.
    This method is used to indicate the preference of verbosity for the resulting XML.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • verbosity

      private final Verbosity verbosity
      This is used to determine the verbosity preference of XML.
    • prolog

      private final String prolog
      Represents the prolog that appears in the generated XML.
    • style

      private final Style style
      This is the style that is used internally by the format.
    • indent

      private final int indent
      Represents the indent size to use for the generated XML.
  • Constructor Details

    • Format

      public Format()
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses an indent size of three.
    • Format

      public Format(int indent)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and a null prolog, which means no prolog is generated.
      Parameters:
      indent - this is the number of spaces used in the indent
    • Format

      public Format(String prolog)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified prolog that is to be inserted at the start of the XML document.
      Parameters:
      prolog - this is the prolog for the generated XML document
    • Format

      public Format(int indent, String prolog)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and the text to use in the generated prolog.
      Parameters:
      indent - this is the number of spaces used in the indent
      prolog - this is the prolog for the generated XML document
    • Format

      public Format(Verbosity verbosity)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified style to style the attributes and elements of the XML document.
      Parameters:
      verbosity - this indicates the verbosity of the format
    • Format

      public Format(int indent, Verbosity verbosity)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified style to style the attributes and elements of the XML document.
      Parameters:
      indent - this is the number of spaces used in the indent
      verbosity - this indicates the verbosity of the format
    • Format

      public Format(Style style)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified style to style the attributes and elements of the XML document.
      Parameters:
      style - this is the style to apply to the format object
    • Format

      public Format(Style style, Verbosity verbosity)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified style to style the attributes and elements of the XML document.
      Parameters:
      style - this is the style to apply to the format object
      verbosity - this indicates the verbosity of the format
    • Format

      public Format(int indent, Style style)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and the style provided to style the XML document.
      Parameters:
      indent - this is the number of spaces used in the indent
      style - this is the style to apply to the format object
    • Format

      public Format(int indent, Style style, Verbosity verbosity)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and the style provided to style the XML document.
      Parameters:
      indent - this is the number of spaces used in the indent
      style - this is the style to apply to the format object
      verbosity - this indicates the verbosity of the format
    • Format

      public Format(int indent, String prolog, Style style)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and the text to use in the generated prolog.
      Parameters:
      indent - this is the number of spaces used in the indent
      prolog - this is the prolog for the generated XML document
      style - this is the style to apply to the format object
    • Format

      public Format(int indent, String prolog, Style style, Verbosity verbosity)
      Constructor for the Format object. This creates an object that is used to describe how the formatter should create the XML document. This constructor uses the specified indent size and the text to use in the generated prolog.
      Parameters:
      indent - this is the number of spaces used in the indent
      prolog - this is the prolog for the generated XML document
      style - this is the style to apply to the format object
      verbosity - this indicates the verbosity of the format
  • Method Details

    • getIndent

      public int getIndent()
      This method returns the size of the indent to use for the XML generated. The indent size represents the number of spaces that are used for the indent, and indent of zero means no indenting.
      Returns:
      returns the number of spaces to used for indenting
    • getProlog

      public String getProlog()
      This method returns the prolog that is to be used at the start of the generated XML document. This allows a DTD or a version to be specified at the start of a document. If this returns null then no prolog is written to the start of the XML document.
      Returns:
      this returns the prolog for the start of the document
    • getStyle

      public Style getStyle()
      This is used to acquire the Style for the format. If no style has been set a default style is used, which does not modify the attributes and elements that are used to build the resulting XML document.
      Returns:
      this returns the style used for this format object
    • getVerbosity

      public Verbosity getVerbosity()
      This method is used to indicate the preference of verbosity for the resulting XML. This is typically used when default serialization is used. It ensures that the various types that are serialized are of either high or low verbosity.
      Returns:
      this returns the verbosity preference for the XML