Package org.apache.cayenne.util
Class XMLEncoder
java.lang.Object
org.apache.cayenne.util.XMLEncoder
A helper class to encode objects to XML.
Usage:
      XMLEncoder encoder = new XMLEncoder(writer);
      encoder
          .start("tag").attribute("name", "tag_name_attribute")
          .start("nested_tag").attribute("name", "nested_tag_name).cdata("tag text element").end()
          .end();
 - Since:
- 1.1, 4.1 API is greatly reworked to be more usable
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected Stringprotected booleanprotected intprotected intprotected PrintWriterprotected Stringprotected boolean
- 
Constructor SummaryConstructorsConstructorDescriptionXMLEncoder(PrintWriter out) XMLEncoder(PrintWriter out, String indent) XMLEncoder(PrintWriter out, String indent, String projectVersion) 
- 
Method SummaryModifier and TypeMethodDescriptionend()This method will track presence of nested tags and print closure accordinglyindent(int i) nested(Collection<? extends XMLSerializable> collection, ConfigurationNodeVisitor delegate) nested(Map<?, ? extends XMLSerializable> map, ConfigurationNodeVisitor delegate) nested(XMLSerializable object, ConfigurationNodeVisitor delegate) println()Inserts an optional project version attribute in the output.Prints a common XML element - property with name and value.Prints a common XML element - property with name and value.Prints a common XML element - property with name and value.Prints common XML element - tag with name and text value (<tag>value</tag>) If value is empty, nothing will be printed.
- 
Field Details- 
projectVersion
- 
indent
- 
out
- 
indentLineprotected boolean indentLine
- 
indentTimesprotected int indentTimes
- 
tagOpenedprotected boolean tagOpened
- 
cdataprotected boolean cdata
- 
currentTagLevelprotected int currentTagLevel
- 
lastTagLevelprotected int lastTagLevel
- 
openTags
 
- 
- 
Constructor Details- 
XMLEncoder
- 
XMLEncoder
- 
XMLEncoder- Since:
- 3.1
 
 
- 
- 
Method Details- 
indent
- 
print
- 
println
- 
println- Since:
- 3.1
 
- 
start- Parameters:
- tag- to start
- Returns:
- this
- Since:
- 4.1
 
- 
endThis method will track presence of nested tags and print closure accordingly- Returns:
- this
- Since:
- 4.1
 
- 
attribute- Parameters:
- name- of the attribute
- value- of the attribute
- Returns:
- this
- Since:
- 4.1
 
- 
attribute- Parameters:
- name- of the attribute
- value- of the attribute
- newLine- should this attribute be printed on new line
- Returns:
- this
- Since:
- 4.1
 
- 
attribute- Parameters:
- name- of the attribute
- value- of the attribute
- Returns:
- this
- Since:
- 4.1
 
- 
attribute- Parameters:
- name- of the attribute
- value- of the attribute
- Returns:
- this
- Since:
- 4.1
 
- 
cdata- Parameters:
- data- char data
- Returns:
- this
- Since:
- 4.1
 
- 
cdata- Parameters:
- data- char data
- escape- does this data need to be enclosed into <![CDATA[ ... ]]>
- Returns:
- this
- Since:
- 4.1
 
- 
nested- Parameters:
- object- nested object to serialize
- delegate- visitor
- Returns:
- this
- Since:
- 4.1
 
- 
nestedpublic XMLEncoder nested(Collection<? extends XMLSerializable> collection, ConfigurationNodeVisitor delegate) - Parameters:
- collection- of nested objects
- delegate- visitor
- Returns:
- this
- Since:
- 4.1
 
- 
nested- Parameters:
- map- of nested objects
- delegate- visitor
- Returns:
- this
- Since:
- 4.1
 
- 
propertyPrints a common XML element - property with name and value.- Since:
- 4.1
 
- 
propertyPrints a common XML element - property with name and value.- Since:
- 4.1
 
- 
propertyPrints a common XML element - property with name and value.- Since:
- 4.1
 
- 
simpleTagPrints common XML element - tag with name and text value (<tag>value</tag>) If value is empty, nothing will be printed.- Since:
- 4.1
 
- 
projectVersionInserts an optional project version attribute in the output. If the project version is not initialized for encoder, will do nothing.- Since:
- 4.1
 
 
-