protected final void processDII() throws FastInfosetException, IOException {
try {
_contentHandler.startDocument();
} catch (SAXException e) {
throw new FastInfosetException("processDII", e);
}
_b = read();
if (_b > 0) {
processDIIOptionalProperties();
}
// Decode one Document Type II, Comment IIs, PI IIs and one EII
boolean firstElementHasOccured = false;
boolean documentTypeDeclarationOccured = false;
while(!_terminate || !firstElementHasOccured) {
_b = read();
switch(DecoderStateTables.DII(_b)) {
case DecoderStateTables.EII_NO_AIIS_INDEX_SMALL:
processEII(_elementNameTable._array[_b], false);
firstElementHasOccured = true;
break;
case DecoderStateTables.EII_AIIS_INDEX_SMALL:
processEII(_elementNameTable._array[_b & EncodingConstants.INTEGER_3RD_BIT_SMALL_MASK], true);
firstElementHasOccured = true;
break;
case DecoderStateTables.EII_INDEX_MEDIUM:
processEII(decodeEIIIndexMedium(), (_b & EncodingConstants.ELEMENT_ATTRIBUTE_FLAG) > 0);
firstElementHasOccured = true;
break;
case DecoderStateTables.EII_INDEX_LARGE:
processEII(decodeEIIIndexLarge(), (_b & EncodingConstants.ELEMENT_ATTRIBUTE_FLAG) > 0);
firstElementHasOccured = true;
break;
case DecoderStateTables.EII_LITERAL:
{
final QualifiedName qn = decodeLiteralQualifiedName(
_b & EncodingConstants.LITERAL_QNAME_PREFIX_NAMESPACE_NAME_MASK,
_elementNameTable.getNext());
_elementNameTable.add(qn);
processEII(qn, (_b & EncodingConstants.ELEMENT_ATTRIBUTE_FLAG) > 0);
firstElementHasOccured = true;
break;
}
case DecoderStateTables.EII_NAMESPACES:
processEIIWithNamespaces();
firstElementHasOccured = true;
break;
case DecoderStateTables.DOCUMENT_TYPE_DECLARATION_II:
{
if (documentTypeDeclarationOccured) {
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.secondOccurenceOfDTDII"));
}
documentTypeDeclarationOccured = true;
String system_identifier = ((_b & EncodingConstants.DOCUMENT_TYPE_SYSTEM_IDENTIFIER_FLAG) > 0)
? decodeIdentifyingNonEmptyStringOnFirstBit(_v.otherURI) : "";
String public_identifier = ((_b & EncodingConstants.DOCUMENT_TYPE_PUBLIC_IDENTIFIER_FLAG) > 0)
? decodeIdentifyingNonEmptyStringOnFirstBit(_v.otherURI) : "";
_b = read();
while (_b == EncodingConstants.PROCESSING_INSTRUCTION) {
switch(decodeNonIdentifyingStringOnFirstBit()) {
case NISTRING_STRING:
if (_addToTable) {
_v.otherString.add(new CharArray(_charBuffer, 0, _charBufferLength, true));
}
break;
case NISTRING_ENCODING_ALGORITHM:
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.processingIIWithEncodingAlgorithm"));
case NISTRING_INDEX:
break;
case NISTRING_EMPTY_STRING:
break;
}
_b = read();
}
if ((_b & EncodingConstants.TERMINATOR) != EncodingConstants.TERMINATOR) {
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.processingInstructionIIsNotTerminatedCorrectly"));
}
if (_b == EncodingConstants.DOUBLE_TERMINATOR) {
_terminate = true;
}
if (_notations != null) _notations.clear();
if (_unparsedEntities != null) _unparsedEntities.clear();
/*
* TODO
* Report All events associated with DTD, PIs, notations etc
*/
break;
}
case DecoderStateTables.COMMENT_II:
processCommentII();
break;
case DecoderStateTables.PROCESSING_INSTRUCTION_II:
processProcessingII();
break;
case DecoderStateTables.TERMINATOR_DOUBLE:
_doubleTerminate = true;
case DecoderStateTables.TERMINATOR_SINGLE:
_terminate = true;
break;
default:
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.IllegalStateDecodingDII"));
}
}
// Decode any remaining Comment IIs, PI IIs
while(!_terminate) {
_b = read();
switch(DecoderStateTables.DII(_b)) {
case DecoderStateTables.COMMENT_II:
processCommentII();
break;
case DecoderStateTables.PROCESSING_INSTRUCTION_II:
processProcessingII();
break;
case DecoderStateTables.TERMINATOR_DOUBLE:
_doubleTerminate = true;
case DecoderStateTables.TERMINATOR_SINGLE:
_terminate = true;
break;
default:
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.IllegalStateDecodingDII"));
}
}
try {
_contentHandler.endDocument();
} catch (SAXException e) {
throw new FastInfosetException("processDII", e);
}
}