- java.lang.Object
-
- com.sun.xml.stream.buffer.AbstractCreatorProcessor
-
- com.sun.xml.stream.buffer.AbstractProcessor
-
- com.sun.xml.stream.buffer.sax.SAXBufferProcessor
-
- All Implemented Interfaces:
org.xml.sax.XMLReader
public class SAXBufferProcessor extends AbstractProcessor implements org.xml.sax.XMLReader
A processor of aXMLStreamBuffer
that that reads the XML infoset asXMLReader
.
-
-
Field Summary
Fields Modifier and Type Field Description protected AttributesHolder
_attributes
protected org.xml.sax.ContentHandler
_contentHandler
Reference to content handler.protected org.xml.sax.DTDHandler
_dtdHandler
Reference to dtd handler.protected org.xml.sax.EntityResolver
_entityResolver
Reference to entity resolver.protected org.xml.sax.ErrorHandler
_errorHandler
Reference to error handler.protected org.xml.sax.ext.LexicalHandler
_lexicalHandler
Reference to lexical handler.protected int[]
_namespaceAttributesStack
protected int
_namespaceAttributesStackIndex
protected int[]
_namespaceAttributesStartingStack
protected java.lang.String[]
_namespacePrefixes
protected boolean
_namespacePrefixesFeature
SAX Namespace attributes featuresprotected int
_namespacePrefixesIndex
private static DefaultWithLexicalHandler
DEFAULT_LEXICAL_HANDLER
-
Fields inherited from class com.sun.xml.stream.buffer.AbstractProcessor
_buffer, _fragmentMode, _qNameBuffer, _stringInterningFeature, _treeCount, STATE_ATTRIBUTE_LN, STATE_ATTRIBUTE_LN_OBJECT, STATE_ATTRIBUTE_P_U_LN, STATE_ATTRIBUTE_P_U_LN_OBJECT, STATE_ATTRIBUTE_U_LN, STATE_ATTRIBUTE_U_LN_OBJECT, STATE_ATTRIBUTE_U_LN_QN, STATE_ATTRIBUTE_U_LN_QN_OBJECT, STATE_COMMENT_AS_CHAR_ARRAY_COPY, STATE_COMMENT_AS_CHAR_ARRAY_MEDIUM, STATE_COMMENT_AS_CHAR_ARRAY_SMALL, STATE_COMMENT_AS_STRING, STATE_DOCUMENT, STATE_DOCUMENT_FRAGMENT, STATE_ELEMENT_LN, STATE_ELEMENT_P_U_LN, STATE_ELEMENT_U_LN, STATE_ELEMENT_U_LN_QN, STATE_END, STATE_ILLEGAL, STATE_NAMESPACE_ATTRIBUTE, STATE_NAMESPACE_ATTRIBUTE_P, STATE_NAMESPACE_ATTRIBUTE_P_U, STATE_NAMESPACE_ATTRIBUTE_U, STATE_PROCESSING_INSTRUCTION, STATE_TEXT_AS_CHAR_ARRAY_COPY, STATE_TEXT_AS_CHAR_ARRAY_MEDIUM, STATE_TEXT_AS_CHAR_ARRAY_SMALL, STATE_TEXT_AS_OBJECT, STATE_TEXT_AS_STRING
-
Fields inherited from class com.sun.xml.stream.buffer.AbstractCreatorProcessor
_contentCharactersBuffer, _contentCharactersBufferPtr, _contentObjects, _contentObjectsPtr, _currentContentCharactersBufferFragment, _currentContentObjectFragment, _currentStructureFragment, _currentStructureStringFragment, _structure, _structurePtr, _structureStrings, _structureStringsPtr, CHAR_ARRAY_LENGTH_MEDIUM, CHAR_ARRAY_LENGTH_MEDIUM_SIZE, CHAR_ARRAY_LENGTH_SMALL, CHAR_ARRAY_LENGTH_SMALL_SIZE, CONTENT_TYPE_CHAR_ARRAY, CONTENT_TYPE_CHAR_ARRAY_COPY, CONTENT_TYPE_OBJECT, CONTENT_TYPE_STRING, FLAG_DOCUMENT_FRAGMENT, FLAG_PREFIX, FLAG_QUALIFIED_NAME, FLAG_URI, T_ATTRIBUTE, T_ATTRIBUTE_LN, T_ATTRIBUTE_LN_OBJECT, T_ATTRIBUTE_P_U_LN, T_ATTRIBUTE_P_U_LN_OBJECT, T_ATTRIBUTE_U_LN, T_ATTRIBUTE_U_LN_OBJECT, T_ATTRIBUTE_U_LN_QN, T_ATTRIBUTE_U_LN_QN_OBJECT, T_COMMENT, T_COMMENT_AS_CHAR_ARRAY, T_COMMENT_AS_CHAR_ARRAY_COPY, T_COMMENT_AS_CHAR_ARRAY_MEDIUM, T_COMMENT_AS_CHAR_ARRAY_SMALL, T_COMMENT_AS_STRING, T_DOCUMENT, T_DOCUMENT_FRAGMENT, T_ELEMENT, T_ELEMENT_LN, T_ELEMENT_P_U_LN, T_ELEMENT_U_LN, T_ELEMENT_U_LN_QN, T_END, T_END_OF_BUFFER, T_NAMESPACE_ATTRIBUTE, T_NAMESPACE_ATTRIBUTE_P, T_NAMESPACE_ATTRIBUTE_P_U, T_NAMESPACE_ATTRIBUTE_U, T_PROCESSING_INSTRUCTION, T_TEXT, T_TEXT_AS_CHAR_ARRAY, T_TEXT_AS_CHAR_ARRAY_COPY, T_TEXT_AS_CHAR_ARRAY_MEDIUM, T_TEXT_AS_CHAR_ARRAY_SMALL, T_TEXT_AS_OBJECT, T_TEXT_AS_STRING, T_UNEXPANDED_ENTITY_REFERENCE, TYPE_MASK, VALUE_TYPE_OBJECT, VALUE_TYPE_STRING
-
-
Constructor Summary
Constructors Constructor Description SAXBufferProcessor()
SAXBufferProcessor(XMLStreamBuffer buffer)
Deprecated.SAXBufferProcessor(XMLStreamBuffer buffer, boolean produceFragmentEvent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
cacheNamespacePrefix(java.lang.String prefix)
private void
cacheNamespacePrefixIndex()
private void
cacheNamespacePrefixStartingIndex()
private static java.lang.String
fixNull(java.lang.String s)
org.xml.sax.ContentHandler
getContentHandler()
org.xml.sax.DTDHandler
getDTDHandler()
org.xml.sax.EntityResolver
getEntityResolver()
org.xml.sax.ErrorHandler
getErrorHandler()
boolean
getFeature(java.lang.String name)
org.xml.sax.ext.LexicalHandler
getLexicalHandler()
java.lang.Object
getProperty(java.lang.String name)
private boolean
isInscope()
void
parse(java.lang.String systemId)
void
parse(org.xml.sax.InputSource input)
void
process()
Parse the sub-tree (or a whole document) thatXMLStreamBuffer
points to, and sends events to handlers.void
process(XMLStreamBuffer buffer)
Deprecated.void
process(XMLStreamBuffer buffer, boolean produceFragmentEvent)
Short-hand forsetXMLStreamBuffer(XMLStreamBuffer,boolean)
thenprocess()
.private void
processAttributes(int item)
private void
processComment(char[] ch, int start, int length)
private void
processComment(java.lang.String s)
private void
processCommentAsCharArrayCopy()
private void
processCommentAsCharArrayMedium()
private void
processCommentAsCharArraySmall()
private void
processDocument()
protected void
processElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, boolean inscope)
private void
processEndPrefixMapping()
private void
processNamespaceAttribute(java.lang.String prefix, java.lang.String uri)
private int
processNamespaceAttributes(int item, boolean collectPrefixes, java.util.Set<java.lang.String> prefixSet)
private void
processProcessingInstruction(java.lang.String target, java.lang.String data)
private void
readInscopeNamespaces(java.util.Set<java.lang.String> prefixSet)
private org.xml.sax.SAXParseException
reportFatalError(java.lang.String msg)
Report a fatal error and abort.void
setContentHandler(org.xml.sax.ContentHandler handler)
void
setDTDHandler(org.xml.sax.DTDHandler handler)
void
setEntityResolver(org.xml.sax.EntityResolver resolver)
void
setErrorHandler(org.xml.sax.ErrorHandler handler)
void
setFeature(java.lang.String name, boolean value)
void
setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
void
setProperty(java.lang.String name, java.lang.Object value)
void
setXMLStreamBuffer(XMLStreamBuffer buffer)
Deprecated.void
setXMLStreamBuffer(XMLStreamBuffer buffer, boolean produceFragmentEvent)
Resets the parser to read from the beginning of the givenXMLStreamBuffer
.-
Methods inherited from class com.sun.xml.stream.buffer.AbstractProcessor
getAIIState, getEIIState, getNIIState, getPrefixFromQName, getQName, peekStructure, readContentCharactersBuffer, readContentCharactersCopy, readContentObject, readContentString, readEiiState, readStructure, readStructure16, readStructureString, setBuffer, setBuffer
-
-
-
-
Field Detail
-
_entityResolver
protected org.xml.sax.EntityResolver _entityResolver
Reference to entity resolver.
-
_dtdHandler
protected org.xml.sax.DTDHandler _dtdHandler
Reference to dtd handler.
-
_contentHandler
protected org.xml.sax.ContentHandler _contentHandler
Reference to content handler.
-
_errorHandler
protected org.xml.sax.ErrorHandler _errorHandler
Reference to error handler.
-
_lexicalHandler
protected org.xml.sax.ext.LexicalHandler _lexicalHandler
Reference to lexical handler.
-
_namespacePrefixesFeature
protected boolean _namespacePrefixesFeature
SAX Namespace attributes features
-
_attributes
protected AttributesHolder _attributes
-
_namespacePrefixes
protected java.lang.String[] _namespacePrefixes
-
_namespacePrefixesIndex
protected int _namespacePrefixesIndex
-
_namespaceAttributesStartingStack
protected int[] _namespaceAttributesStartingStack
-
_namespaceAttributesStack
protected int[] _namespaceAttributesStack
-
_namespaceAttributesStackIndex
protected int _namespaceAttributesStackIndex
-
DEFAULT_LEXICAL_HANDLER
private static final DefaultWithLexicalHandler DEFAULT_LEXICAL_HANDLER
-
-
Constructor Detail
-
SAXBufferProcessor
public SAXBufferProcessor()
-
SAXBufferProcessor
@Deprecated public SAXBufferProcessor(XMLStreamBuffer buffer)
Deprecated.
-
SAXBufferProcessor
public SAXBufferProcessor(XMLStreamBuffer buffer, boolean produceFragmentEvent)
- Parameters:
produceFragmentEvent
- True to generate fragment SAX events without start/endDocument. False to generate a full document SAX events.
-
-
Method Detail
-
getFeature
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
- Specified by:
getFeature
in interfaceorg.xml.sax.XMLReader
- Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
setFeature
public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
- Specified by:
setFeature
in interfaceorg.xml.sax.XMLReader
- Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
- Specified by:
getProperty
in interfaceorg.xml.sax.XMLReader
- Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
- Specified by:
setProperty
in interfaceorg.xml.sax.XMLReader
- Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
- Specified by:
setEntityResolver
in interfaceorg.xml.sax.XMLReader
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
- Specified by:
getEntityResolver
in interfaceorg.xml.sax.XMLReader
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
- Specified by:
setDTDHandler
in interfaceorg.xml.sax.XMLReader
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
- Specified by:
getDTDHandler
in interfaceorg.xml.sax.XMLReader
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler handler)
- Specified by:
setContentHandler
in interfaceorg.xml.sax.XMLReader
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
- Specified by:
getContentHandler
in interfaceorg.xml.sax.XMLReader
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
- Specified by:
setErrorHandler
in interfaceorg.xml.sax.XMLReader
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
- Specified by:
getErrorHandler
in interfaceorg.xml.sax.XMLReader
-
setLexicalHandler
public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
-
getLexicalHandler
public org.xml.sax.ext.LexicalHandler getLexicalHandler()
-
parse
public void parse(org.xml.sax.InputSource input) throws java.io.IOException, org.xml.sax.SAXException
- Specified by:
parse
in interfaceorg.xml.sax.XMLReader
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
parse
public void parse(java.lang.String systemId) throws java.io.IOException, org.xml.sax.SAXException
- Specified by:
parse
in interfaceorg.xml.sax.XMLReader
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
process
@Deprecated public final void process(XMLStreamBuffer buffer) throws org.xml.sax.SAXException
Deprecated.Short-hand forsetXMLStreamBuffer(XMLStreamBuffer)
thenprocess()
.- Throws:
org.xml.sax.SAXException
-
process
public final void process(XMLStreamBuffer buffer, boolean produceFragmentEvent) throws org.xml.sax.SAXException
Short-hand forsetXMLStreamBuffer(XMLStreamBuffer,boolean)
thenprocess()
.- Parameters:
produceFragmentEvent
- True to generate fragment SAX events without start/endDocument. False to generate a full document SAX events.- Throws:
org.xml.sax.SAXException
-
setXMLStreamBuffer
@Deprecated public void setXMLStreamBuffer(XMLStreamBuffer buffer)
Deprecated.Resets the parser to read from the beginning of the givenXMLStreamBuffer
.
-
setXMLStreamBuffer
public void setXMLStreamBuffer(XMLStreamBuffer buffer, boolean produceFragmentEvent)
Resets the parser to read from the beginning of the givenXMLStreamBuffer
.- Parameters:
produceFragmentEvent
- True to generate fragment SAX events without start/endDocument. False to generate a full document SAX events.
-
process
public final void process() throws org.xml.sax.SAXException
Parse the sub-tree (or a whole document) thatXMLStreamBuffer
points to, and sends events to handlers.TODO: We probably need two modes for a sub-tree event generation. One for firing a sub-tree as if it's a whole document (in which case start/endDocument and appropriate additional namespace bindings are necessary), and the other mode for firing a subtree as a subtree, like it does today. A stream buffer SAX feature could be used to specify this.
- Throws:
org.xml.sax.SAXException
- Follow the same semantics asXMLReader.parse(InputSource)
.
-
processCommentAsCharArraySmall
private void processCommentAsCharArraySmall() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
reportFatalError
private org.xml.sax.SAXParseException reportFatalError(java.lang.String msg) throws org.xml.sax.SAXException
Report a fatal error and abort. This is necessary to follow the SAX semantics of error handling.- Throws:
org.xml.sax.SAXException
-
isInscope
private boolean isInscope()
-
processDocument
private void processDocument() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processElement
protected void processElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, boolean inscope) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
readInscopeNamespaces
private void readInscopeNamespaces(java.util.Set<java.lang.String> prefixSet) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
fixNull
private static java.lang.String fixNull(java.lang.String s)
-
processCommentAsCharArrayCopy
private void processCommentAsCharArrayCopy() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processCommentAsCharArrayMedium
private void processCommentAsCharArrayMedium() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processEndPrefixMapping
private void processEndPrefixMapping() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processNamespaceAttributes
private int processNamespaceAttributes(int item, boolean collectPrefixes, java.util.Set<java.lang.String> prefixSet) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processAttributes
private void processAttributes(int item) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processNamespaceAttribute
private void processNamespaceAttribute(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
cacheNamespacePrefix
private void cacheNamespacePrefix(java.lang.String prefix)
-
cacheNamespacePrefixIndex
private void cacheNamespacePrefixIndex()
-
cacheNamespacePrefixStartingIndex
private void cacheNamespacePrefixStartingIndex()
-
processComment
private void processComment(java.lang.String s) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processComment
private void processComment(char[] ch, int start, int length) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
processProcessingInstruction
private void processProcessingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
-