Class XmlSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>

Direct Known Subclasses:
HtmlSerializer.Builder, SoapXmlSerializer.Builder, XmlSerializer.DefaultBuilder
Enclosing class:
XmlSerializer

public abstract static class XmlSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>> extends WriterSerializer.Builder<SELF>
Builder class.
  • Constructor Details

    • Builder

      protected Builder()
      Constructor, default settings.
    • Builder

      protected Builder(XmlSerializer.Builder<?> copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The builder to copy from.
      Cannot be null.
    • Builder

      protected Builder(XmlSerializer copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The bean to copy from.
      Cannot be null.
  • Method Details

    • addBeanTypesXml

      Add "_type" properties when needed.

      If true, then "_type" properties will be added to beans if their type cannot be inferred through reflection.

      When present, this value overrides the Serializer.Builder#addBeanTypes() setting and is provided to customize the behavior of specific serializers in a SerializerSet.

      Returns:
      This object.
    • addBeanTypesXml

      public SELF addBeanTypesXml(boolean value)
      Same as addBeanTypesXml() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • addNamespaceUrisToRoot

      Add namespace URLs to the root element.

      Use this setting to add xmlns:x attributes to the root element for the default and all mapped namespaces.

      This setting is ignored if enableNamespaces() is not enabled.

      See Also:
      Returns:
      This object.
    • addNamespaceUrisToRoot

      public SELF addNamespaceUrisToRoot(boolean value)
      Same as addNamespaceUrisToRoot() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • build

      public XmlSerializer build()
      Description copied from class: Context.Builder
      Build the object.
      Overrides:
      build in class WriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>
      Returns:
      The built object.
    • copy

      public abstract SELF copy()
      Description copied from class: Context.Builder
      Copy creator.
      Specified by:
      copy in class WriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>
      Returns:
      A new mutable copy of this builder.
    • defaultNamespace

      Default namespace.

      Specifies the default namespace URI for this document.

      See Also:
      Parameters:
      value - The new value for this property.
      The default is "juneau: http://www.apache.org/2013/Juneau".
      Can be null to specify no namespace.
      Returns:
      This object.
    • disableAutoDetectNamespaces

      Don't auto-detect namespace usage.

      Don't detect namespace usage before serialization.

      Used in conjunction with addNamespaceUrisToRoot() to reduce the list of namespace URLs appended to the root element to only those that will be used in the resulting document.

      If disabled, then the data structure will first be crawled looking for namespaces that will be encountered before the root element is serialized.

      This setting is ignored if enableNamespaces() is not enabled.

      Notes:
      • Auto-detection of namespaces can be costly performance-wise.
        In high-performance environments, it's recommended that namespace detection be disabled, and that namespaces be manually defined through the namespaces(Namespace...) property.
      See Also:
      Returns:
      This object.
    • disableAutoDetectNamespaces

      public SELF disableAutoDetectNamespaces(boolean value)
      Same as disableAutoDetectNamespaces() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • disableJsonTags

      XmlSerializer configuration property:  Disable use of JSON type identifier tags.

      When enabled, JSON type tags (e.g. "<string>") tags and attributes will not be added to the output. Note that JSON type tags are used to ensure parsers are able to recreate the original data types passed into the serializer. Disabling JSON tags can cause different data to be parsed (e.g. strings instead of numbers).

      Returns:
      This object.
    • disableJsonTags

      public SELF disableJsonTags(boolean value)
      Same as disableJsonTags() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • enableNamespaces

      Enable support for XML namespaces.

      If not enabled, XML output will not contain any namespaces regardless of any other settings.

      See Also:
      Returns:
      This object.
    • enableNamespaces

      public SELF enableNamespaces(boolean value)
      Same as enableNamespaces() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • hashKey

      public HashKey hashKey()
      Description copied from class: Context.Builder
      Returns the hashkey of this builder.

      Used to return previously instantiated context beans that have matching hashkeys. The HashKey object is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if the HashKey.equals(Object) method is the same.

      Overrides:
      hashKey in class WriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>
      Returns:
      The hashkey of this builder.
    • namespaces

      public SELF namespaces(Namespace... values)
      Default namespaces.

      The default list of namespaces associated with this serializer.

      Parameters:
      values - The new value for this property.
      Cannot contain null values.
      Returns:
      This object.
    • ns

      public SELF ns()
      Enable support for XML namespaces.

      Shortcut for calling enableNamespaces(true).

      Returns:
      This object.
    • textNodeDelimiter

      public SELF textNodeDelimiter(String value)
      Text node delimiter.

      Specifies the delimiter string to insert between consecutive text nodes. This is useful for adding spacing between text elements to improve readability.

      The default value is an empty string (no delimiter).

      Example:

      XmlSerializer.create() .textNodeDelimiter(" ") .build();

      With this setting, serializing:

      new Audio().children("a", "b", new Strong("c"));

      Will produce: <audio>a b<strong>c</strong></audio>
      Instead of: <audio>ab<strong>c</strong></audio>

      Parameters:
      value - The delimiter string.
      Can be null (interpreted as empty string).
      Returns:
      This object.