Class SAXDocumentSerializer
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- com.sun.xml.fastinfoset.Encoder
-
- com.sun.xml.fastinfoset.sax.SAXDocumentSerializer
-
- All Implemented Interfaces:
FastInfosetSerializer,EncodingAlgorithmContentHandler,ExtendedContentHandler,FastInfosetWriter,PrimitiveTypeContentHandler,RestrictedAlphabetContentHandler,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.LexicalHandler
- Direct Known Subclasses:
SAXDocumentSerializerWithPrefixMapping
public class SAXDocumentSerializer extends Encoder implements FastInfosetWriter
The Fast Infoset SAX serializer.Instantiate this serializer to serialize a fast infoset document in accordance with the SAX API.
This utilizes the SAX API in a reverse manner to that of parsing. It is the responsibility of the client to call the appropriate event methods on the SAX handlers, and to ensure that such a sequence of methods calls results in the production well-formed fast infoset documents. The SAXDocumentSerializer performs no well-formed checks.
More than one fast infoset document may be encoded to the
OutputStream.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean_charactersAsCDATAprotected boolean_elementHasNamespaces-
Fields inherited from class com.sun.xml.fastinfoset.Encoder
_b, _characterEncodingSchemeSystemDefault, _charBuffer, _markIndex, _octetBuffer, _octetBufferIndex, _s, _terminate, _v, _vData, attributeValueMapTotalCharactersConstraint, CHARACTER_ENCODING_SCHEME_SYSTEM_PROPERTY, characterContentChunkMapTotalCharactersConstraint, maxAttributeValueSize, maxCharacterContentChunkSize, minAttributeValueSize, minCharacterContentChunkSize
-
Fields inherited from interface org.jvnet.fastinfoset.FastInfosetSerializer
ATTRIBUTE_VALUE_MAP_MEMORY_CONSTRAINT, BUFFER_SIZE_PROPERTY, CHARACTER_CONTENT_CHUNK_MAP_MEMORY_CONSTRAINT, EXTERNAL_VOCABULARIES_PROPERTY, IGNORE_COMMENTS_FEATURE, IGNORE_DTD_FEATURE, IGNORE_PROCESSING_INSTRUCTIONS_FEATURE, IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE, MAX_ATTRIBUTE_VALUE_SIZE, MAX_CHARACTER_CONTENT_CHUNK_SIZE, MIN_ATTRIBUTE_VALUE_SIZE, MIN_CHARACTER_CONTENT_CHUNK_SIZE, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, UTF_16BE, UTF_8
-
-
Constructor Summary
Constructors Modifier Constructor Description SAXDocumentSerializer()protectedSAXDocumentSerializer(boolean v)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalphabetCharacters(java.lang.String alphabet, char[] ch, int start, int length)voidbooleans(boolean[] b, int start, int length)Receive notification of character data as an array of boolean.voidbytes(byte[] b, int start, int length)Receive notification of character data as an array of byte.voidcharacters(char[] ch, int start, int length)voidcharacters(char[] ch, int start, int length, boolean index)Receive notification of character data.voidcomment(char[] ch, int start, int length)protected intcountAttributes(org.xml.sax.Attributes atts)voiddateTimeCharacters(char[] ch, int start, int length)voiddoubles(double[] d, int start, int length)Receive notification of character data as an array of double.protected booleanencodeAttribute(java.lang.String namespaceURI, java.lang.String qName, java.lang.String localName)protected voidencodeAttributes(org.xml.sax.Attributes atts)protected voidencodeElement(java.lang.String namespaceURI, java.lang.String qName, java.lang.String localName)voidendCDATA()voidendDocument()voidendDTD()voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)voidendEntity(java.lang.String name)voidfloats(float[] f, int start, int length)Receive notification of character data as an array of float.voidignorableWhitespace(char[] ch, int start, int length)voidints(int[] i, int start, int length)Receive notification of character data as an array of int.voidlongs(long[] l, int start, int length)Receive notification of character data as an array of long.voidnumericCharacters(char[] ch, int start, int length)voidobject(java.lang.String URI, int id, java.lang.Object data)Receive notification of encoding algorithm data as an object.voidoctets(java.lang.String URI, int id, byte[] b, int start, int length)Receive notification of encoding algorithm data as an array of byte.voidprocessingInstruction(java.lang.String target, java.lang.String data)voidreset()Reset the encoder for reuse encoding another XML infoset.voidsetDocumentLocator(org.xml.sax.Locator locator)voidshorts(short[] s, int start, int length)Receive notification of character data as an array of short.voidskippedEntity(java.lang.String name)voidstartCDATA()voidstartDocument()voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)voidstartEntity(java.lang.String name)voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)voiduuids(long[] msblsb, int start, int length)Receive notification of character data as an two array of UUID.-
Methods inherited from class com.sun.xml.fastinfoset.Encoder
canAddAttributeToTable, canAddCharacterContentToTable, encodeAIIBuiltInAlgorithmData, encodeAIIObjectAlgorithmData, encodeAIIOctetAlgorithmData, encodeAlphabetCharacters, encodeAttributeQualifiedNameOnSecondBit, encodeCharacters, encodeCharactersNoClone, encodeCIIBuiltInAlgorithmData, encodeCIIBuiltInAlgorithmDataAsCDATA, encodeCIIObjectAlgorithmData, encodeCIIOctetAlgorithmData, encodeComment, encodeCommentNoClone, encodeDateTimeFourBitCharacters, encodeDateTimeNonIdentifyingStringOnFirstBit, encodeDocumentTermination, encodeDocumentTypeDeclaration, encodeElementQualifiedNameOnThirdBit, encodeElementTermination, encodeFourBitCharacters, encodeHeader, encodeIdentifyingNonEmptyStringOnFirstBit, encodeInitialVocabulary, encodeLiteralAttributeQualifiedNameOnSecondBit, encodeLiteralElementQualifiedNameOnThirdBit, encodeNamespaceAttribute, encodeNonEmptyCharacterStringOnFifthBit, encodeNonEmptyCharacterStringOnFifthBit, encodeNonEmptyCharacterStringOnSeventhBit, encodeNonEmptyFourBitCharacterString, encodeNonEmptyFourBitCharacterStringOnSeventhBit, encodeNonEmptyNBitCharacterStringOnSeventhBit, encodeNonEmptyOctetStringOnSecondBit, encodeNonEmptyUTF8StringAsOctetString, encodeNonEmptyUTF8StringAsOctetString, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnThirdBit, encodeNonIdentifyingStringOnThirdBit, encodeNonIdentifyingStringOnThirdBit, encodeNonZeroInteger, encodeNonZeroIntegerOnFourthBit, encodeNonZeroIntegerOnSecondBitFirstBitOne, encodeNonZeroIntegerOnSecondBitFirstBitZero, encodeNonZeroIntegerOnThirdBit, encodeNonZeroOctetStringLength, encodeNonZeroOctetStringLengthOnFifthBit, encodeNonZeroOctetStringLengthOnSecondBit, encodeNonZeroOctetStringLengthOnSenventhBit, encodeNumericFourBitCharacters, encodeNumericNonIdentifyingStringOnFirstBit, encodeProcessingInstruction, encodeTermination, encodeUtf16String, encodeUtf16String, encodeUTF8String, encodeUTF8String, getAttributeValueMapMemoryLimit, getCharacterContentChunkMapMemoryLimit, getCharacterEncodingScheme, getIgnoreComments, getIgnoreDTD, getIgnoreProcesingInstructions, getIgnoreWhiteSpaceTextContent, getMaxAttributeValueSize, getMaxCharacterContentChunkSize, getMinAttributeValueSize, getMinCharacterContentChunkSize, getPrefixFromQualifiedName, getRegisteredEncodingAlgorithms, getVocabularyApplicationData, hasMark, isAttributeValueLengthMatchesLimit, isCharacterContentChunkLengthMatchesLimit, isWhiteSpace, isWhiteSpace, mark, resetMark, setAttributeValueMapMemoryLimit, setCharacterContentChunkMapMemoryLimit, setCharacterEncodingScheme, setExternalVocabulary, setIgnoreComments, setIgnoreDTD, setIgnoreProcesingInstructions, setIgnoreWhiteSpaceTextContent, setMaxAttributeValueSize, setMaxCharacterContentChunkSize, setMinAttributeValueSize, setMinCharacterContentChunkSize, setOutputStream, setRegisteredEncodingAlgorithms, setVocabulary, setVocabularyApplicationData, write, write, write
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jvnet.fastinfoset.FastInfosetSerializer
getAttributeValueMapMemoryLimit, getCharacterContentChunkMapMemoryLimit, getCharacterEncodingScheme, getIgnoreComments, getIgnoreDTD, getIgnoreProcesingInstructions, getIgnoreWhiteSpaceTextContent, getMaxAttributeValueSize, getMaxCharacterContentChunkSize, getMinAttributeValueSize, getMinCharacterContentChunkSize, getRegisteredEncodingAlgorithms, getVocabularyApplicationData, setAttributeValueMapMemoryLimit, setCharacterContentChunkMapMemoryLimit, setCharacterEncodingScheme, setExternalVocabulary, setIgnoreComments, setIgnoreDTD, setIgnoreProcesingInstructions, setIgnoreWhiteSpaceTextContent, setMaxAttributeValueSize, setMaxCharacterContentChunkSize, setMinAttributeValueSize, setMinCharacterContentChunkSize, setOutputStream, setRegisteredEncodingAlgorithms, setVocabularyApplicationData
-
-
-
-
Method Detail
-
reset
public void reset()
Description copied from class:EncoderReset the encoder for reuse encoding another XML infoset.- Specified by:
resetin interfaceFastInfosetSerializer- Overrides:
resetin classEncoder
-
startDocument
public final void startDocument() throws org.xml.sax.SAXException- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endDocument
public final void endDocument() throws org.xml.sax.SAXException- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler- Overrides:
startPrefixMappingin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startElement
public final void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endElement
public final void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
characters
public final void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public final void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
processingInstruction
public final void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public final void setDocumentLocator(org.xml.sax.Locator locator)
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler
-
skippedEntity
public final void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler- Overrides:
skippedEntityin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
comment
public final void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
commentin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startCDATA
public final void startCDATA() throws org.xml.sax.SAXException- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endCDATA
public final void endCDATA() throws org.xml.sax.SAXException- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startDTD
public final void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endDTD
public final void endDTD() throws org.xml.sax.SAXException- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startEntity
public final void startEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endEntity
public final void endEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
octets
public final void octets(java.lang.String URI, int id, byte[] b, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:EncodingAlgorithmContentHandlerReceive notification of encoding algorithm data as an array of byte.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing encoding algorithm data.
The Parser will call the method of this interface to report each encoding algorithm data. Parsers MUST return all contiguous characters in a single chunk
Parsers may return all contiguous bytes in a single chunk, or they may split it into several chunks providing that the length of each chunk is of the required length to successfully apply the encoding algorithm to the chunk.
- Specified by:
octetsin interfaceEncodingAlgorithmContentHandler- Parameters:
URI- the URI of the encoding algorithmid- the encoding algorithm indexb- the array of bytestart- the start position in the arraylength- the number of byte to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception- See Also:
EncodingAlgorithmIndexes
-
object
public final void object(java.lang.String URI, int id, java.lang.Object data) throws org.xml.sax.SAXExceptionDescription copied from interface:EncodingAlgorithmContentHandlerReceive notification of encoding algorithm data as an object.Such notifications will occur for a Fast Infoset SAX parser when processing encoding algorithm data that is converted from an array of byte to an object more suitable for processing.
- Specified by:
objectin interfaceEncodingAlgorithmContentHandler- Parameters:
URI- the URI of the encoding algorithmid- the encoding algorithm indexdata- the encoding algorithm object- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception- See Also:
EncodingAlgorithmIndexes
-
bytes
public final void bytes(byte[] b, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of byte.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "base64" encoding algorithm, see subclause 10.3, or the "hexadecimal" encoding algorithm, see subclause 10.2.
Such a notification may occur for binary data that would normally require base 64 encoding and reported as character data using the
charactersmethod.
- Specified by:
bytesin interfacePrimitiveTypeContentHandler- Parameters:
b- the array of bytestart- the start position in the arraylength- the number of byte to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
shorts
public final void shorts(short[] s, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of short.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "short" encoding algorithm, see subclause 10.4
.
- Specified by:
shortsin interfacePrimitiveTypeContentHandler- Parameters:
s- the array of shortstart- the start position in the arraylength- the number of short to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
ints
public final void ints(int[] i, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of int.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "int" encoding algorithm, see subclause 10.5
.
- Specified by:
intsin interfacePrimitiveTypeContentHandler- Parameters:
i- the array of intstart- the start position in the arraylength- the number of int to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
longs
public final void longs(long[] l, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of long.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "long" encoding algorithm, see subclause 10.6
.
- Specified by:
longsin interfacePrimitiveTypeContentHandler- Parameters:
l- the array of longstart- the start position in the arraylength- the number of long to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
booleans
public final void booleans(boolean[] b, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of boolean.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "boolean" encoding algorithm, see subclause 10.7
.
- Specified by:
booleansin interfacePrimitiveTypeContentHandler- Parameters:
b- the array of booleanstart- the start position in the arraylength- the number of boolean to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
floats
public final void floats(float[] f, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of float.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "float" encoding algorithm, see subclause 10.8
.
- Specified by:
floatsin interfacePrimitiveTypeContentHandler- Parameters:
f- the array of floatstart- the start position in the arraylength- the number of float to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
doubles
public final void doubles(double[] d, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an array of double.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "double" encoding algorithm, see subclause 10.9
.
- Specified by:
doublesin interfacePrimitiveTypeContentHandler- Parameters:
d- the array of doublestart- the start position in the arraylength- the number of double to read from the array- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
uuids
public void uuids(long[] msblsb, int start, int length) throws org.xml.sax.SAXExceptionDescription copied from interface:PrimitiveTypeContentHandlerReceive notification of character data as an two array of UUID.The application must not attempt to read from the array outside of the specified range.
Such notifications will occur for a Fast Infoset SAX parser when processing data encoded using the "uuid" encoding algorithm, see subclause 10.10
.
- Specified by:
uuidsin interfacePrimitiveTypeContentHandler- Parameters:
msblsb- the array of long containing pairs of most signficant bits and least significant bits of the UUIDsstart- the start position in the arraylength- the number of long to read from the array. This will be twice the number of UUIDs, which are pairs of two long values- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception
-
numericCharacters
public void numericCharacters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
numericCharactersin interfaceRestrictedAlphabetContentHandler- Throws:
org.xml.sax.SAXException
-
dateTimeCharacters
public void dateTimeCharacters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
dateTimeCharactersin interfaceRestrictedAlphabetContentHandler- Throws:
org.xml.sax.SAXException
-
alphabetCharacters
public void alphabetCharacters(java.lang.String alphabet, char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
alphabetCharactersin interfaceRestrictedAlphabetContentHandler- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length, boolean index) throws org.xml.sax.SAXExceptionDescription copied from interface:ExtendedContentHandlerReceive notification of character data.- Specified by:
charactersin interfaceExtendedContentHandler- Parameters:
ch- the characters from the XML documentstart- the start position in the arraylength- the number of characters to read from the arrayindex- true if the characters are indexed, otherwise false.- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception- See Also:
ContentHandler.characters(char[], int, int)
-
countAttributes
protected final int countAttributes(org.xml.sax.Attributes atts)
-
encodeAttributes
protected void encodeAttributes(org.xml.sax.Attributes atts) throws java.io.IOException, FastInfosetException- Throws:
java.io.IOExceptionFastInfosetException
-
encodeElement
protected void encodeElement(java.lang.String namespaceURI, java.lang.String qName, java.lang.String localName) throws java.io.IOException- Throws:
java.io.IOException
-
encodeAttribute
protected boolean encodeAttribute(java.lang.String namespaceURI, java.lang.String qName, java.lang.String localName) throws java.io.IOException- Throws:
java.io.IOException
-
-