org.apache.cayenne.util

## Class XMLEncoder

- java.lang.Object
- - org.apache.cayenne.util.XMLEncoder

-     public class XMLEncoder
      extends Object

  A helper class to encode objects to XML.
  Since:
    1.1

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `indent`
    `protected boolean` | `indentLine`
    `protected int` | `indentTimes`
    `protected PrintWriter` | `out`
    `protected String` | `projectVersion`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLEncoder(PrintWriter out)`
    `XMLEncoder(PrintWriter out, String indent)`
    `XMLEncoder(PrintWriter out, String indent, String projectVersion)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PrintWriter` | `getPrintWriter()`
    `void` | `indent(int i)`
    `void` | `print(boolean b)`
    `void` | `print(char c)`
    `void` | `print(Collection<? extends XMLSerializable> c)` Utility method that prints all map values, assuming they are XMLSerializable objects.
    `void` | `print(int i)`
    `void` | `print(Map<?,? extends XMLSerializable> map)` Utility method that prints all map values, assuming they are XMLSerializable objects.
    `void` | `print(String text)`
    `void` | `printAttribute(String name, String value)` Prints an XML attribute.
    `void` | `println()`
    `void` | `println(char c)`
    `void` | `println(String text)`
    `void` | `printlnAttribute(String name, String value)`
    `void` | `printProjectVersion()` Inserts an optional project version attribute in the output.
    `void` | `printProperty(String name, boolean b)` Prints a common XML element - property with name and value.
    `void` | `printProperty(String name, int i)` Prints a common XML element - property with name and value.
    `void` | `printProperty(String name, String value)` Prints a common XML element - property with name and value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### projectVersion

          protected String projectVersion

    - #### indent

          protected String indent

    - #### out

          protected PrintWriter out

    - #### indentLine

          protected boolean indentLine

    - #### indentTimes

          protected int indentTimes

  - ### Constructor Detail

    - #### XMLEncoder

          public XMLEncoder(PrintWriter out)

    - #### XMLEncoder

          public XMLEncoder(PrintWriter out,
                    String indent)

    - #### XMLEncoder

          public XMLEncoder(PrintWriter out,
                    String indent,
                    String projectVersion)

      Since:
        3.1

  - ### Method Detail

    - #### getPrintWriter

          public PrintWriter getPrintWriter()

    - #### indent

          public void indent(int i)

    - #### print

          public void print(Map<?,? extends XMLSerializable> map)

      Utility method that prints all map values, assuming they are XMLSerializable objects.

    - #### print

          public void print(Collection<? extends XMLSerializable> c)

      Utility method that prints all map values, assuming they are XMLSerializable objects.

    - #### printProjectVersion

          public void printProjectVersion()

      Inserts an optional project version attribute in the output. If the project version is not initialized for encoder, will do nothing.
      Since:
        3.1

    - #### printAttribute

          public void printAttribute(String name,
                            String value)

      Prints an XML attribute. The value is trimmed (so leading and following spaces are lost) and then encoded to be a proper XML attribute value. E.g. "&" becomes "&", etc.
      Since:
        3.1

    - #### printlnAttribute

          public void printlnAttribute(String name,
                              String value)

      Since:
        3.1

    - #### printProperty

          public void printProperty(String name,
                           String value)

      Prints a common XML element - property with name and value.

    - #### printProperty

          public void printProperty(String name,
                           boolean b)

      Prints a common XML element - property with name and value.

    - #### printProperty

          public void printProperty(String name,
                           int i)

      Prints a common XML element - property with name and value.

    - #### print

          public void print(String text)

    - #### print

          public void print(char c)

    - #### print

          public void print(boolean b)

    - #### print

          public void print(int i)

    - #### println

          public void println(String text)

    - #### println

          public void println()

      Since:
        3.1

    - #### println

          public void println(char c)

Copyright © 2001–2014 Apache Cayenne. All rights reserved.