if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
if (fCurrentIndex + 1 == UTF8DataChunk.CHUNK_SIZE) {
UTF8DataChunk saveChunk = fCurrentChunk;
int saveIndex = fCurrentIndex;
int saveOffset = fCurrentOffset;
if (loadNextByte() != '>') {
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = fCurrentChunk.toByteArray();
fMostRecentByte = ']';
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
} else {
if (fMostRecentData[fCurrentIndex + 1] != '>') {
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
fCurrentIndex++;
fCurrentOffset++;
}
loadNextByte();
fCharacterCounter += 2;
return XMLEntityHandler.CONTENT_RESULT_END_OF_CDSECT;
case 4: // invalid char
if (ch == 0 && atEOF(fCurrentOffset + 1)) {
changeReaders();
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR; // REVISIT - not quite...
}
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
case 5:
do {
if (ch == 0x0A) {
fLinefeedCounter++;
fCharacterCounter = 1;
} else if (ch == 0x0D) {
fCarriageReturnCounter++;
fCharacterCounter = 1;
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
ch = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
} catch (ArrayIndexOutOfBoundsException ex) {
ch = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
ch = slowLoadNextByte();
else
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
if (ch != 0x0A) {
if (fSendCharDataAsCharArray)
appendCharData(0x0A);
if (ch == 0x20 || ch == 0x09 || ch == 0x0D)
continue;
break;
}
fLinefeedCounter++;
} else {
fCharacterCounter++;
}
if (fSendCharDataAsCharArray) {
try {
fCharacters[fCharDataLength] = (char)ch;
fCharDataLength++;
} catch (ArrayIndexOutOfBoundsException ex) {
slowAppendCharData(ch);
}
}
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
ch = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
} catch (ArrayIndexOutOfBoundsException ex) {
ch = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
ch = slowLoadNextByte();
else
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
} while (ch == 0x20 || ch == 0x09 || ch == 0x0A || ch == 0x0D);
if (ch < 0x80) {
switch (XMLCharacterProperties.fgAsciiCharData[ch]) {
case 0:
if (fSendCharDataAsCharArray)
appendCharData(ch);
fCharacterCounter++;
ch = loadNextByte();
break;
case 1: // '<'
if (!fInCDSect) {
if (fSendCharDataAsCharArray) {
fCharDataHandler.processWhitespace(fCharacters, 0, fCharDataLength);
} else {
int stringIndex = addString(charDataOffset, fCurrentOffset - charDataOffset);
fCharDataHandler.processWhitespace(stringIndex);
}
fCharacterCounter++;
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
ch = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
} catch (ArrayIndexOutOfBoundsException ex) {
ch = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
ch = slowLoadNextByte();
else
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
return recognizeMarkup(ch, element);
}
if (fSendCharDataAsCharArray)
appendCharData('<');
fCharacterCounter++;
ch = loadNextByte();
break;
case 2: // '&'
if (!fInCDSect) {
whitespace(charDataOffset, fCurrentOffset);
fCharacterCounter++;
ch = loadNextByte();
return recognizeReference(ch);
}
if (fSendCharDataAsCharArray)
appendCharData('&');
fCharacterCounter++;
ch = loadNextByte();
break;
case 3: // ']'
int endOffset = fCurrentOffset;
ch = loadNextByte();
if (ch != ']') {
fCharacterCounter++;
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
if (fCurrentIndex + 1 == UTF8DataChunk.CHUNK_SIZE) {
UTF8DataChunk saveChunk = fCurrentChunk;
int saveIndex = fCurrentIndex;
int saveOffset = fCurrentOffset;
if (loadNextByte() != '>') {
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = fCurrentChunk.toByteArray();
fMostRecentByte = ']';
fCharacterCounter++;
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
} else {
if (fMostRecentData[fCurrentIndex + 1] != '>') {
fCharacterCounter++;
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
fCurrentIndex++;
fCurrentOffset++;
}
loadNextByte();
whitespace(charDataOffset, endOffset);
fCharacterCounter += 3;
return XMLEntityHandler.CONTENT_RESULT_END_OF_CDSECT;
case 4: // invalid char
whitespace(charDataOffset, fCurrentOffset);
if (ch == 0 && atEOF(fCurrentOffset + 1)) {
changeReaders();
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR; // REVISIT - not quite...
}
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
}
} else {
if (fSendCharDataAsCharArray) {
if (!copyMultiByteCharData(ch)) {
whitespace(charDataOffset, fCurrentOffset);
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
}
} else if (!skipMultiByteCharData(ch)) {
whitespace(charDataOffset, fCurrentOffset);
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
}
}
break;
}
} else {
if (fSendCharDataAsCharArray) {
if (!copyMultiByteCharData(ch)) {
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
}
} else {
if (!skipMultiByteCharData(ch)) {
return XMLEntityHandler.CONTENT_RESULT_INVALID_CHAR;
}
}
}
if (fSendCharDataAsCharArray)
ch = copyAsciiCharData();
else
ch = skipAsciiCharData();
while (true) {
if (ch < 0x80) {
switch (XMLCharacterProperties.fgAsciiCharData[ch]) {
case 0:
if (fSendCharDataAsCharArray)
appendCharData(ch);
fCharacterCounter++;
ch = loadNextByte();
break;
case 1: // '<'
if (!fInCDSect) {
if (fSendCharDataAsCharArray) {
fCharDataHandler.processCharacters(fCharacters, 0, fCharDataLength);
} else {
int stringIndex = addString(charDataOffset, fCurrentOffset - charDataOffset);
fCharDataHandler.processCharacters(stringIndex);
}
fCharacterCounter++;
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
ch = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
} catch (ArrayIndexOutOfBoundsException ex) {
ch = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
ch = slowLoadNextByte();
else
ch = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
return recognizeMarkup(ch, element);
}
if (fSendCharDataAsCharArray)
appendCharData('<');
fCharacterCounter++;
ch = loadNextByte();
break;
case 2: // '&'
if (!fInCDSect) {
characters(charDataOffset, fCurrentOffset);
fCharacterCounter++;
ch = loadNextByte();
return recognizeReference(ch);
}
if (fSendCharDataAsCharArray)
appendCharData('&');
fCharacterCounter++;
ch = loadNextByte();
break;
case 3: // ']'
int endOffset = fCurrentOffset;
ch = loadNextByte();
if (ch != ']') {
fCharacterCounter++;
if (fSendCharDataAsCharArray)
appendCharData(']');
break;
}
if (fCurrentIndex + 1 == UTF8DataChunk.CHUNK_SIZE) {
UTF8DataChunk saveChunk = fCurrentChunk;
int saveIndex = fCurrentIndex;
int saveOffset = fCurrentOffset;
if (loadNextByte() != '>') {
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;