Class XMLSerializer
java.lang.Object
com.twelvemonkeys.xml.XMLSerializer
XMLSerializer
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/xml/XMLSerializer.java#1 $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final XMLSerializer.SerializationContextprivate final Charsetprivate final OutputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intappendAndEscape(String pString, int pStart, int pEnd, StringBuilder pBuilder, String pEntity) final XMLSerializerindentation(String pIndent) private static voidindentToLevel(PrintWriter pOut, XMLSerializer.SerializationContext pContext) static voidprivate static StringmaybeEscapeAttributeValue(String pValue) (package private) static StringmaybeEscapeElementValue(String pValue) Returns an escaped version of the input string.private static intneedsEscapeAttribute(String pString) Returns an the first index from the input string that should be escaped if escaping is needed, otherwise-1.private static intneedsEscapeElement(String pString) Returns an the first index from the input string that should be escaped if escaping is needed, otherwise-1.voidSerializes the entire document, along with the XML declaration (<?xml version="1.0" encoding="..."?>).voidSerializes the entire sub tree starting atpRootNode, along with an optional XML declaration (<?xml version="1.0" encoding="..."?>).final XMLSerializerstripComments(boolean pStrip) private static voidupdatePreserveSpace(Node pNode, XMLSerializer.SerializationContext pContext) private static StringvalidateCDataValue(String pValue) private static StringvalidateCommentValue(String pValue) private voidwriteCData(PrintWriter pOut, Node pNode) private voidwriteComment(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) private voidwriteDoctype(PrintWriter pOut, DocumentType pDoctype) private voidwriteDocument(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) private voidwriteElement(PrintWriter pOut, Element pNode, XMLSerializer.SerializationContext pContext) private voidwriteNodeRecursive(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) private voidwriteProcessingInstruction(PrintWriter pOut, ProcessingInstruction pNode) private voidwriteText(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) private voidwriteXML(PrintWriter pOut, Node pDocument, XMLSerializer.SerializationContext pContext) private void
-
Field Details
-
output
-
encoding
-
context
-
-
Constructor Details
-
XMLSerializer
-
-
Method Details
-
indentation
-
stripComments
-
serialize
Serializes the entire document, along with the XML declaration (<?xml version="1.0" encoding="..."?>).- Parameters:
pDocument- the document to serialize.
-
serialize
Serializes the entire sub tree starting atpRootNode, along with an optional XML declaration (<?xml version="1.0" encoding="..."?>).- Parameters:
pRootNode- the root node to serialize.pWriteXMLDeclaration-trueif the XML declaration should be included, otherwisefalse.
-
writeXMLDeclaration
-
writeXML
private void writeXML(PrintWriter pOut, Node pDocument, XMLSerializer.SerializationContext pContext) -
writeNodeRecursive
private void writeNodeRecursive(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) -
writeProcessingInstruction
-
writeText
-
writeCData
-
updatePreserveSpace
-
indentToLevel
-
writeComment
private void writeComment(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) -
maybeEscapeElementValue
Returns an escaped version of the input string. The string is guaranteed to not contain illegal XML characters (&<>). If no escaping is needed, the input string is returned as is.- Parameters:
pValue- the input string that might need escaping.- Returns:
- an escaped version of the input string.
-
appendAndEscape
private static int appendAndEscape(String pString, int pStart, int pEnd, StringBuilder pBuilder, String pEntity) -
needsEscapeElement
Returns an the first index from the input string that should be escaped if escaping is needed, otherwise-1.- Parameters:
pString- the input string that might need escaping.- Returns:
- the first index from the input string that should be escaped,
or
-1.
-
maybeEscapeAttributeValue
-
needsEscapeAttribute
Returns an the first index from the input string that should be escaped if escaping is needed, otherwise-1.- Parameters:
pString- the input string that might need escaping.- Returns:
- the first index from the input string that should be escaped,
or
-1.
-
validateCDataValue
-
validateCommentValue
-
writeDocument
private void writeDocument(PrintWriter pOut, Node pNode, XMLSerializer.SerializationContext pContext) -
writeElement
private void writeElement(PrintWriter pOut, Element pNode, XMLSerializer.SerializationContext pContext) -
writeDoctype
-
main
- Throws:
IOExceptionSAXException
-