- All Implemented Interfaces:
FastInfosetSerializer
,EncodingAlgorithmContentHandler
,ExtendedContentHandler
,FastInfosetWriter
,PrimitiveTypeContentHandler
,RestrictedAlphabetContentHandler
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,LexicalHandler
- Direct Known Subclasses:
SAXDocumentSerializerWithPrefixMapping
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
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
alphabetCharacters
(String alphabet, char[] ch, int start, int length) final void
booleans
(boolean[] b, int start, int length) Receive notification of character data as an array of boolean.final void
bytes
(byte[] b, int start, int length) Receive notification of character data as an array of byte.final void
characters
(char[] ch, int start, int length) void
characters
(char[] ch, int start, int length, boolean index) Receive notification of character data.final void
comment
(char[] ch, int start, int length) protected final int
countAttributes
(Attributes atts) void
dateTimeCharacters
(char[] ch, int start, int length) final void
doubles
(double[] d, int start, int length) Receive notification of character data as an array of double.protected boolean
encodeAttribute
(String namespaceURI, String qName, String localName) protected void
encodeAttributes
(Attributes atts) protected void
encodeElement
(String namespaceURI, String qName, String localName) final void
endCDATA()
final void
final void
endDTD()
final void
endElement
(String namespaceURI, String localName, String qName) final void
final void
floats
(float[] f, int start, int length) Receive notification of character data as an array of float.final void
ignorableWhitespace
(char[] ch, int start, int length) final void
ints
(int[] i, int start, int length) Receive notification of character data as an array of int.final void
longs
(long[] l, int start, int length) Receive notification of character data as an array of long.void
numericCharacters
(char[] ch, int start, int length) final void
Receive notification of encoding algorithm data as an object.final void
Receive notification of encoding algorithm data as an array of byte.final void
processingInstruction
(String target, String data) void
reset()
Reset the encoder for reuse encoding another XML infoset.final void
setDocumentLocator
(Locator locator) final void
shorts
(short[] s, int start, int length) Receive notification of character data as an array of short.final void
skippedEntity
(String name) final void
final void
final void
final void
startElement
(String namespaceURI, String localName, String qName, Attributes atts) final void
startEntity
(String name) void
startPrefixMapping
(String prefix, String uri) void
uuids
(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.xml.sax.ContentHandler
endPrefixMapping
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
-
Field Details
-
_elementHasNamespaces
protected boolean _elementHasNamespaces -
_charactersAsCDATA
protected boolean _charactersAsCDATA
-
-
Constructor Details
-
SAXDocumentSerializer
protected SAXDocumentSerializer(boolean v) -
SAXDocumentSerializer
public SAXDocumentSerializer()
-
-
Method Details
-
reset
public void reset()Description copied from class:Encoder
Reset the encoder for reuse encoding another XML infoset.- Specified by:
reset
in interfaceFastInfosetSerializer
- Overrides:
reset
in classEncoder
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startElement
public final void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
public final void endElement(String namespaceURI, String localName, String qName) throws SAXException - Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Overrides:
skippedEntity
in classDefaultHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
octets
Description copied from interface:EncodingAlgorithmContentHandler
Receive 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:
octets
in 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:
SAXException
- any SAX exception, possibly wrapping another exception- See Also:
-
object
Description copied from interface:EncodingAlgorithmContentHandler
Receive 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:
object
in interfaceEncodingAlgorithmContentHandler
- Parameters:
URI
- the URI of the encoding algorithmid
- the encoding algorithm indexdata
- the encoding algorithm object- Throws:
SAXException
- any SAX exception, possibly wrapping another exception- See Also:
-
bytes
Description copied from interface:PrimitiveTypeContentHandler
Receive 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
characters
method.
- Specified by:
bytes
in interfacePrimitiveTypeContentHandler
- Parameters:
b
- the array of bytestart
- the start position in the arraylength
- the number of byte to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
shorts
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
shorts
in interfacePrimitiveTypeContentHandler
- Parameters:
s
- the array of shortstart
- the start position in the arraylength
- the number of short to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
ints
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
ints
in interfacePrimitiveTypeContentHandler
- Parameters:
i
- the array of intstart
- the start position in the arraylength
- the number of int to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
longs
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
longs
in interfacePrimitiveTypeContentHandler
- Parameters:
l
- the array of longstart
- the start position in the arraylength
- the number of long to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
booleans
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
booleans
in interfacePrimitiveTypeContentHandler
- Parameters:
b
- the array of booleanstart
- the start position in the arraylength
- the number of boolean to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
floats
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
floats
in interfacePrimitiveTypeContentHandler
- Parameters:
f
- the array of floatstart
- the start position in the arraylength
- the number of float to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
doubles
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
doubles
in interfacePrimitiveTypeContentHandler
- Parameters:
d
- the array of doublestart
- the start position in the arraylength
- the number of double to read from the array- Throws:
SAXException
- any SAX exception, possibly wrapping another exception
-
uuids
Description copied from interface:PrimitiveTypeContentHandler
Receive 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:
uuids
in 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:
SAXException
- any SAX exception, possibly wrapping another exception
-
numericCharacters
- Specified by:
numericCharacters
in interfaceRestrictedAlphabetContentHandler
- Throws:
SAXException
-
dateTimeCharacters
- Specified by:
dateTimeCharacters
in interfaceRestrictedAlphabetContentHandler
- Throws:
SAXException
-
alphabetCharacters
public void alphabetCharacters(String alphabet, char[] ch, int start, int length) throws SAXException - Specified by:
alphabetCharacters
in interfaceRestrictedAlphabetContentHandler
- Throws:
SAXException
-
characters
Description copied from interface:ExtendedContentHandler
Receive notification of character data.- Specified by:
characters
in 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:
SAXException
- any SAX exception, possibly wrapping another exception- See Also:
-
countAttributes
-
encodeAttributes
- Throws:
IOException
FastInfosetException
-
encodeElement
protected void encodeElement(String namespaceURI, String qName, String localName) throws IOException - Throws:
IOException
-
encodeAttribute
protected boolean encodeAttribute(String namespaceURI, String qName, String localName) throws IOException - Throws:
IOException
-