Package com.sforce.ws.parser
Class MXSerializer
- java.lang.Object
-
- com.sforce.ws.parser.MXSerializer
-
public class MXSerializer extends Object
Implementation of XmlSerializer interface from XmlPull V1 API. This implementation is optimzied for performance and low memory footprint.Implemented features:
- FEATURE_NAMES_INTERNED - when enabled all returned names (namespaces, prefixes) will be interned and it is required that all names passed as arguments MUST be interned
- FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE
Implemented properties:
- PROPERTY_SERIALIZER_INDENTATION
- PROPERTY_SERIALIZER_LINE_SEPARATOR
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanattributeUseApostropheprotected intautoDeclaredPrefixesprotected char[]bufprotected intdepthprotected booleandoIndentprotected String[]elNameprotected String[]elNamespaceprotected int[]elNamespaceCountprotected StringFEATURE_NAMES_INTERNEDprotected StringFEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHEprotected booleanfinishedprotected char[]indentationBufprotected intindentationJumpprotected StringindentationStringprotected StringlineSeparatorprotected Stringlocationprotected intmaxIndentLevelprotected booleannamesInternedprotected intnamespaceEndprotected String[]namespacePrefixprotected String[]namespaceUriprotected intoffsetNewLineprotected Writeroutprotected booleanpastRootprotected static String[]precomputedPrefixesprotected static StringPROPERTY_LOCATIONprotected StringPROPERTY_SERIALIZER_INDENTATIONprotected StringPROPERTY_SERIALIZER_LINE_SEPARATORprotected booleanseenBracketprotected booleanseenBracketBracketprotected booleanseenTagprotected booleansetPrefixCalledprotected booleanstartTagIncompleteprotected booleanwriteIndentationprotected booleanwriteLineSepartorprotected static StringXML_URIprotected static StringXMLNS_URI
-
Constructor Summary
Constructors Constructor Description MXSerializer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MXSerializerattribute(String namespace, String name, String value)voidcdsect(String text)protected voidcloseStartTag()voidcomment(String text)voiddocdecl(String text)voidendDocument()MXSerializerendTag(String namespace, String name)protected voidensureElementsCapacity()protected voidensureNamespacesCapacity()voidentityRef(String text)voidflush()intgetDepth()booleangetFeature(String name)StringgetName()StringgetNamespace()StringgetPrefix(String namespace, boolean generatePrefix)ObjectgetProperty(String name)WritergetWriter()voidignorableWhitespace(String text)protected StringlookupOrDeclarePrefix(String namespace)protected static Stringprintable(char ch)protected static Stringprintable(String s)simple utility method -- good for debuggingvoidprocessingInstruction(String text)protected voidrebuildIndentationBuf()For maximum efficiency when writing indents the required output is pre-computed This is internal function that recomputes buffer after user requested chnages.protected voidreset()voidsetFeature(String name, boolean state)voidsetOutput(OutputStream os, String encoding)voidsetOutput(Writer writer)voidsetPrefix(String prefix, String namespace)voidsetProperty(String name, Object value)voidstartDocument(String encoding, Boolean standalone)MXSerializerstartTag(String namespace, String name)MXSerializertext(char[] buf, int start, int len)MXSerializertext(String text)protected voidwriteAttributeValue(String value, Writer out)protected voidwriteElementContent(char[] buf, int off, int len, Writer out)protected voidwriteElementContent(String text, Writer out)protected voidwriteIndent()
-
-
-
Field Detail
-
XML_URI
protected static final String XML_URI
- See Also:
- Constant Field Values
-
XMLNS_URI
protected static final String XMLNS_URI
- See Also:
- Constant Field Values
-
FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE
protected final String FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE
- See Also:
- Constant Field Values
-
FEATURE_NAMES_INTERNED
protected final String FEATURE_NAMES_INTERNED
- See Also:
- Constant Field Values
-
PROPERTY_SERIALIZER_INDENTATION
protected final String PROPERTY_SERIALIZER_INDENTATION
- See Also:
- Constant Field Values
-
PROPERTY_SERIALIZER_LINE_SEPARATOR
protected final String PROPERTY_SERIALIZER_LINE_SEPARATOR
- See Also:
- Constant Field Values
-
PROPERTY_LOCATION
protected static final String PROPERTY_LOCATION
- See Also:
- Constant Field Values
-
namesInterned
protected boolean namesInterned
-
attributeUseApostrophe
protected boolean attributeUseApostrophe
-
indentationString
protected String indentationString
-
lineSeparator
protected String lineSeparator
-
location
protected String location
-
out
protected Writer out
-
autoDeclaredPrefixes
protected int autoDeclaredPrefixes
-
depth
protected int depth
-
elNamespace
protected String[] elNamespace
-
elName
protected String[] elName
-
elNamespaceCount
protected int[] elNamespaceCount
-
namespaceEnd
protected int namespaceEnd
-
namespacePrefix
protected String[] namespacePrefix
-
namespaceUri
protected String[] namespaceUri
-
finished
protected boolean finished
-
pastRoot
protected boolean pastRoot
-
setPrefixCalled
protected boolean setPrefixCalled
-
startTagIncomplete
protected boolean startTagIncomplete
-
doIndent
protected boolean doIndent
-
seenTag
protected boolean seenTag
-
seenBracket
protected boolean seenBracket
-
seenBracketBracket
protected boolean seenBracketBracket
-
buf
protected char[] buf
-
precomputedPrefixes
protected static final String[] precomputedPrefixes
-
offsetNewLine
protected int offsetNewLine
-
indentationJump
protected int indentationJump
-
indentationBuf
protected char[] indentationBuf
-
maxIndentLevel
protected int maxIndentLevel
-
writeLineSepartor
protected boolean writeLineSepartor
-
writeIndentation
protected boolean writeIndentation
-
-
Method Detail
-
reset
protected void reset()
-
ensureElementsCapacity
protected void ensureElementsCapacity()
-
ensureNamespacesCapacity
protected void ensureNamespacesCapacity()
-
setFeature
public void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException
-
getFeature
public boolean getFeature(String name) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
rebuildIndentationBuf
protected void rebuildIndentationBuf()
For maximum efficiency when writing indents the required output is pre-computed This is internal function that recomputes buffer after user requested chnages.
-
writeIndent
protected void writeIndent() throws IOException- Throws:
IOException
-
setProperty
public void setProperty(String name, Object value) throws IllegalArgumentException, IllegalStateException
-
getProperty
public Object getProperty(String name) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getWriter
public Writer getWriter()
-
setOutput
public void setOutput(Writer writer)
-
setOutput
public void setOutput(OutputStream os, String encoding) throws IOException
- Throws:
IOException
-
startDocument
public void startDocument(String encoding, Boolean standalone) throws IOException
- Throws:
IOException
-
endDocument
public void endDocument() throws IOException- Throws:
IOException
-
setPrefix
public void setPrefix(String prefix, String namespace) throws IOException
- Throws:
IOException
-
getDepth
public int getDepth()
-
getNamespace
public String getNamespace()
-
getName
public String getName()
-
startTag
public MXSerializer startTag(String namespace, String name) throws IOException
- Throws:
IOException
-
attribute
public MXSerializer attribute(String namespace, String name, String value) throws IOException
- Throws:
IOException
-
closeStartTag
protected void closeStartTag() throws IOException- Throws:
IOException
-
endTag
public MXSerializer endTag(String namespace, String name) throws IOException
- Throws:
IOException
-
text
public MXSerializer text(String text) throws IOException
- Throws:
IOException
-
text
public MXSerializer text(char[] buf, int start, int len) throws IOException
- Throws:
IOException
-
cdsect
public void cdsect(String text) throws IOException
- Throws:
IOException
-
entityRef
public void entityRef(String text) throws IOException
- Throws:
IOException
-
processingInstruction
public void processingInstruction(String text) throws IOException
- Throws:
IOException
-
comment
public void comment(String text) throws IOException
- Throws:
IOException
-
docdecl
public void docdecl(String text) throws IOException
- Throws:
IOException
-
ignorableWhitespace
public void ignorableWhitespace(String text) throws IOException
- Throws:
IOException
-
flush
public void flush() throws IOException- Throws:
IOException
-
writeAttributeValue
protected void writeAttributeValue(String value, Writer out) throws IOException
- Throws:
IOException
-
writeElementContent
protected void writeElementContent(String text, Writer out) throws IOException
- Throws:
IOException
-
writeElementContent
protected void writeElementContent(char[] buf, int off, int len, Writer out) throws IOException- Throws:
IOException
-
printable
protected static String printable(char ch)
-
-