/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A processor of a {@link XMLStreamBuffer} that that reads the XML infoset as
* {@link XMLReader}.
*/
/**
* Reference to entity resolver.
*/
/**
* Reference to dtd handler.
*/
/**
* Reference to content handler.
*/
/**
* Reference to error handler.
*/
/**
* Reference to lexical handler.
*/
/**
* SAX Namespace attributes features
*/
protected boolean _namespacePrefixesFeature = false;
protected int _namespacePrefixesIndex;
protected int _namespaceAttributesStackIndex;
public SAXBufferProcessor() {
}
/**
* @deprecated
* Use {@link #SAXBufferProcessor(XMLStreamBuffer, boolean)}
*/
}
/**
* @param produceFragmentEvent
* True to generate fragment SAX events without start/endDocument.
* False to generate a full document SAX events.
*/
}
return true;
return _namespacePrefixesFeature;
return true;
return true;
return _stringInterningFeature;
} else {
throw new SAXNotRecognizedException(
"Feature not supported: " + name);
}
}
if (!value) {
}
// ignore
// ignore
if (value != _stringInterningFeature) {
}
} else {
throw new SAXNotRecognizedException(
"Feature not supported: " + name);
}
}
return getLexicalHandler();
} else {
}
}
if (value instanceof LexicalHandler) {
} else {
}
} else {
}
}
}
return _entityResolver;
}
}
return _dtdHandler;
}
}
return _contentHandler;
}
}
return _errorHandler;
}
}
return _lexicalHandler;
}
// InputSource is ignored
process();
}
// systemId is ignored
process();
}
/**
* Short-hand for {@link #setXMLStreamBuffer(XMLStreamBuffer)} then {@link #process()}.
*
* @deprecated
* Use {@link #process(XMLStreamBuffer, boolean)}
*/
process();
}
/**
* Short-hand for {@link #setXMLStreamBuffer(XMLStreamBuffer,boolean)} then {@link #process()}.
*
* @param produceFragmentEvent
* True to generate fragment SAX events without start/endDocument.
* False to generate a full document SAX events.
*/
public final void process(XMLStreamBuffer buffer, boolean produceFragmentEvent) throws SAXException {
process();
}
/**
* Resets the parser to read from the beginning of the given {@link XMLStreamBuffer}.
*
* @deprecated
* Use {@link #setXMLStreamBuffer(XMLStreamBuffer, boolean)}.
*/
}
/**
* Resets the parser to read from the beginning of the given {@link XMLStreamBuffer}.
*
* @param produceFragmentEvent
* True to generate fragment SAX events without start/endDocument.
* False to generate a full document SAX events.
*/
throw new IllegalStateException("Can't write a forest to a full XML infoset");
}
/**
* Parse the sub-tree (or a whole document) that {@link XMLStreamBuffer}
* points to, and sends events to handlers.
*
* <p>
* 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 SAXException
* Follow the same semantics as {@link XMLReader#parse(InputSource)}.
*/
if(!_fragmentMode) {
// TODO: if we are writing a fragment stream buffer as a full XML document,
// we need to declare in-scope namespaces as if they are on the root element.
}
while (_treeCount>0) {
final int item = readEiiState();
switch(item) {
case STATE_DOCUMENT:
_treeCount--;
break;
case STATE_END:
// Empty buffer
return;
case STATE_ELEMENT_U_LN_QN:
_treeCount--;
break;
case STATE_ELEMENT_P_U_LN:
{
_treeCount--;
break;
}
case STATE_ELEMENT_U_LN: {
_treeCount--;
break;
}
case STATE_ELEMENT_LN:
{
_treeCount--;
break;
}
break;
break;
break;
case STATE_COMMENT_AS_STRING:
break;
break;
default:
}
}
if(!_fragmentMode)
}
final int length = readStructure();
}
/**
* Report a fatal error and abort.
*
* This is necessary to follow the SAX semantics of error handling.
*/
if(_errorHandler!=null)
return spe;
}
while(true) {
int item = readEiiState();
switch(item) {
case STATE_ELEMENT_U_LN_QN:
break;
case STATE_ELEMENT_P_U_LN:
{
break;
}
case STATE_ELEMENT_U_LN: {
break;
}
case STATE_ELEMENT_LN:
{
break;
}
break;
break;
break;
case STATE_COMMENT_AS_STRING:
break;
break;
case STATE_END:
return;
default:
}
}
}
boolean hasAttributes = false;
boolean hasNamespaceAttributes = false;
int item = peekStructure();
hasNamespaceAttributes = true;
}
hasAttributes = true;
}
if (hasAttributes) {
_attributes.clear();
}
do {
item = readEiiState();
switch(item) {
case STATE_ELEMENT_U_LN_QN:
break;
case STATE_ELEMENT_P_U_LN:
{
final String p = readStructureString();
final String u = readStructureString();
break;
}
case STATE_ELEMENT_U_LN: {
final String u = readStructureString();
break;
}
case STATE_ELEMENT_LN: {
break;
}
{
final int length = readStructure();
break;
}
{
final int length = readStructure16();
break;
}
{
final char[] ch = readContentCharactersCopy();
break;
}
case STATE_TEXT_AS_STRING:
{
final String s = readContentString();
break;
}
case STATE_TEXT_AS_OBJECT:
{
break;
}
break;
break;
break;
case T_COMMENT_AS_STRING:
break;
break;
case STATE_END:
break;
default:
}
if (hasNamespaceAttributes) {
}
}
final char[] ch = readContentCharactersCopy();
}
final int length = readStructure16();
}
final int start = (_namespaceAttributesStackIndex > 0) ? _namespaceAttributesStack[_namespaceAttributesStackIndex] : 0;
}
}
do {
switch(getNIIState(item)) {
// Undeclaration of default namespace
break;
// Undeclaration of namespace
break;
// Declaration with prefix
break;
// Default declaration
break;
default:
}
item = peekStructure();
return item;
}
do {
switch(getAIIState(item)) {
case STATE_ATTRIBUTE_U_LN_QN:
_attributes.addAttributeWithQName(readStructureString(), readStructureString(), readStructureString(), readStructureString(), readContentString());
break;
case STATE_ATTRIBUTE_P_U_LN:
{
final String p = readStructureString();
final String u = readStructureString();
_attributes.addAttributeWithQName(u, ln, getQName(p, ln), readStructureString(), readContentString());
break;
}
case STATE_ATTRIBUTE_U_LN: {
final String u = readStructureString();
break;
}
case STATE_ATTRIBUTE_LN: {
break;
}
default:
}
item = peekStructure();
}
if (_namespacePrefixesFeature) {
// Add the namespace delcaration as an attribute
if (prefix != "") {
"CDATA", uri);
} else {
_attributes.addAttributeWithQName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE,
"CDATA", uri);
}
}
}
}
}
private void cacheNamespacePrefixIndex() {
System.arraycopy(_namespaceAttributesStack, 0, namespaceAttributesStack, 0, _namespaceAttributesStackIndex);
}
}
}
}
}
private static final DefaultWithLexicalHandler DEFAULT_LEXICAL_HANDLER = new DefaultWithLexicalHandler();
}