-
- All Superinterfaces:
FastInfosetParser
,XMLReader
- All Known Implementing Classes:
SAXDocumentParser
public interface FastInfosetReader extends XMLReader, FastInfosetParser
Interface for reading an Fast Infoset document using callbacks.FastInfosetReader is the interface that a Fast Infoset parser's SAX2 driver must implement. This interface allows an application to to register Fast Infoset specific event handlers for encoding algorithms.
The reception of encoding algorithm events is determined by the registration of:
- A
PrimitiveTypeContentHandler
, for the recieving of events, associated with built-in encoding algorithms, for decoded data that can be reported as Java primitive types. - A
EncodingAlgorithmContentHandler
, for the recieving of events, associated with built-in and application-defined encoding algorithms, for decoded data that can be reported as an array of octets or as a Java Object. EncodingAlgorithm
implementations, for the receiving of events, associated with application defined algorithms. for decoded data that shall be reported as a Java Object by way of the registered EncodingAlgorithmContentHandler.
The reporting of element content events for built-in algorithms is determimed by the following:
- If a PrimitiveContentHandler is registered then decoded data is reported as Java primitive types using the corresponding methods on the PrimitiveContentHandler interface.
- If a PrimitiveContentHandler is not registered and a
EncodingAlgorithmContentHandler is registered then decoded data is reported
as Java Objects using
EncodingAlgorithmContentHandler.object(String, int, Object)
. An Object shall correspond to the Java primitive type that would otherwise be reported using the PrimitiveContentHandler. - If neither is registered then then decoded data is reported as characters.
The reporting of element content events for application-defined algorithms is determimed by the following:
- If an EncodingAlgorithmContentHandler is registered and there is no
EncodingAlgorithm registered for an application-defined encoding algorithm
then decoded data for such an algoroithm is reported as an array of octets
using
EncodingAlgorithmContentHandler.octets(String, int, byte[], int, int)
; otherwise - If there is an EncodingAlgorithm registered for the application-defined
encoding algorithm then the decoded data is reported as a Java Object,
returned by decoding according to the EncodingAlgorithm, using
EncodingAlgorithmContentHandler.object(String, int, Object)
.
The reporting of attribute values for encoding algorithms is achieved using
EncodingAlgorithmAttributes
that extendsAttributes
. The registered ContentHandler may cast the attr paramter of theContentHandler.startElement(String, String, String, org.xml.sax.Attributes)
to the EncodingAlgorithmAttributes interface to access to encoding algorithm information.The reporting of attribute values for built-in algorithms is determimed by the following:
- If a PrimitiveContentHandler or EncodingAlgorithmContentHandler is
registered then decoded data is reported as Java Objects corresponding
to the Java primitive types. The Java Objects may be obtained using
EncodingAlgorithmAttributes.getAlgorithmData(int)
. - If neither is registered then then decoded data is reported as characters.
The reporting of attribute values for application-defined algorithms is determimed by the following:
- If an EncodingAlgorithmContentHandler is registered and there is no
EncodingAlgorithm registered for an application-defined encoding algorithm
then decoded data for such an algoroithm is reported as Java Object,
that is an instance of
byte[]
, usingEncodingAlgorithmAttributes.getAlgorithmData(int)
; otherwise - If there is an EncodingAlgorithm registered for the application-defined
encoding algorithm then the decoded data is reported as a Java Object,
returned by decoding according to the EncodingAlgorithm, using
EncodingAlgorithmAttributes.getAlgorithmData(int)
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENCODING_ALGORITHM_CONTENT_HANDLER_PROPERTY
The property name to be used for getting and setting the EncodingAlgorithmContentHandler.static String
PRIMITIVE_TYPE_CONTENT_HANDLER_PROPERTY
The property name to be used for getting and setting the PrimtiveTypeContentHandler.-
Fields inherited from interface org.jvnet.fastinfoset.FastInfosetParser
BUFFER_SIZE_PROPERTY, EXTERNAL_VOCABULARIES_PROPERTY, FORCE_STREAM_CLOSE_PROPERTY, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, STRING_INTERNING_PROPERTY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DeclHandler
getDeclHandler()
Return the current DTD declaration handler.EncodingAlgorithmContentHandler
getEncodingAlgorithmContentHandler()
Return the current encoding algorithm handler.LexicalHandler
getLexicalHandler()
Return the current lexical handler.PrimitiveTypeContentHandler
getPrimitiveTypeContentHandler()
Return the current primitive type handler.void
parse(InputStream s)
Parse a fast infoset document from an InputStream.void
setDeclHandler(DeclHandler handler)
Allow an application to register a DTD declaration handler.void
setEncodingAlgorithmContentHandler(EncodingAlgorithmContentHandler handler)
Allow an application to register an encoding algorithm handler.void
setLexicalHandler(LexicalHandler handler)
Allow an application to register a lexical handler.void
setPrimitiveTypeContentHandler(PrimitiveTypeContentHandler handler)
Allow an application to register a primitive type handler.-
Methods inherited from interface org.jvnet.fastinfoset.FastInfosetParser
getBufferSize, getExternalVocabularies, getForceStreamClose, getParseFragments, getRegisteredEncodingAlgorithms, getStringInterning, setBufferSize, setExternalVocabularies, setForceStreamClose, setParseFragments, setRegisteredEncodingAlgorithms, setStringInterning
-
Methods inherited from interface org.xml.sax.XMLReader
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getProperty, parse, parse, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setProperty
-
-
-
-
Field Detail
-
ENCODING_ALGORITHM_CONTENT_HANDLER_PROPERTY
static final String ENCODING_ALGORITHM_CONTENT_HANDLER_PROPERTY
The property name to be used for getting and setting the EncodingAlgorithmContentHandler.- See Also:
- Constant Field Values
-
PRIMITIVE_TYPE_CONTENT_HANDLER_PROPERTY
static final String PRIMITIVE_TYPE_CONTENT_HANDLER_PROPERTY
The property name to be used for getting and setting the PrimtiveTypeContentHandler.- See Also:
- Constant Field Values
-
-
Method Detail
-
parse
void parse(InputStream s) throws IOException, FastInfosetException, SAXException
Parse a fast infoset document from an InputStream.The application can use this method to instruct the Fast Infoset reader to begin parsing a fast infoset document from a byte stream.
Applications may not invoke this method while a parse is in progress (they should create a new XMLReader instead for each nested XML document). Once a parse is complete, an application may reuse the same FastInfosetReader object, possibly with a different byte stream.
During the parse, the FastInfosetReader will provide information about the fast infoset document through the registered event handlers.
This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.
- Parameters:
s
- The byte stream to parse from.- Throws:
IOException
FastInfosetException
SAXException
-
setLexicalHandler
void setLexicalHandler(LexicalHandler handler)
Allow an application to register a lexical handler.Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler
- The lexical handler.- See Also:
getLexicalHandler()
-
getLexicalHandler
LexicalHandler getLexicalHandler()
Return the current lexical handler.- Returns:
- The current lexical handler, or null if none has been registered.
- See Also:
setLexicalHandler(org.xml.sax.ext.LexicalHandler)
-
setDeclHandler
void setDeclHandler(DeclHandler handler)
Allow an application to register a DTD declaration handler.Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler
- The DTD declaration handler.- See Also:
getLexicalHandler()
-
getDeclHandler
DeclHandler getDeclHandler()
Return the current DTD declaration handler.- Returns:
- The current DTD declaration handler, or null if none has been registered.
- See Also:
setLexicalHandler(org.xml.sax.ext.LexicalHandler)
-
setEncodingAlgorithmContentHandler
void setEncodingAlgorithmContentHandler(EncodingAlgorithmContentHandler handler)
Allow an application to register an encoding algorithm handler.Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler
- The encoding algorithm handler.- See Also:
getEncodingAlgorithmContentHandler()
-
getEncodingAlgorithmContentHandler
EncodingAlgorithmContentHandler getEncodingAlgorithmContentHandler()
Return the current encoding algorithm handler.- Returns:
- The current encoding algorithm handler, or null if none has been registered.
- See Also:
setEncodingAlgorithmContentHandler(org.jvnet.fastinfoset.sax.EncodingAlgorithmContentHandler)
-
setPrimitiveTypeContentHandler
void setPrimitiveTypeContentHandler(PrimitiveTypeContentHandler handler)
Allow an application to register a primitive type handler.Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler
- The primitive type handler.- See Also:
getPrimitiveTypeContentHandler()
-
getPrimitiveTypeContentHandler
PrimitiveTypeContentHandler getPrimitiveTypeContentHandler()
Return the current primitive type handler.- Returns:
- The current primitive type handler, or null if none has been registered.
- See Also:
setPrimitiveTypeContentHandler(org.jvnet.fastinfoset.sax.PrimitiveTypeContentHandler)
-
-