ch = b0;
} else {
//
// REVISIT - optimize this with in-buffer lookahead.
//
UTF8DataChunk saveChunk = fCurrentChunk;
int saveIndex = fCurrentIndex;
int saveOffset = fCurrentOffset;
if (!fCalledCharPropInit) {
XMLCharacterProperties.initCharFlags();
fCalledCharPropInit = true;
}
int b1;
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
b1 = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
b1 = fMostRecentData[fCurrentIndex] & 0xFF;
} catch (ArrayIndexOutOfBoundsException ex) {
b1 = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
b1 = slowLoadNextByte();
else
b1 = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
if ((0xe0 & b0) == 0xc0) { // 110yyyyy 10xxxxxx
ch = ((0x1f & b0)<<6) + (0x3f & b1);
if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_InitialNameCharFlag) == 0) { // yyy yyxx xxxx (0x80 to 0x7ff)
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = saveChunk.toByteArray();
fMostRecentByte = b0;
return -1;
}
} else {
int b2;
if (USE_OUT_OF_LINE_LOAD_NEXT_BYTE) {
b2 = loadNextByte();
} else {
fCurrentOffset++;
if (USE_TRY_CATCH_FOR_LOAD_NEXT_BYTE) {
fCurrentIndex++;
try {
b2 = fMostRecentData[fCurrentIndex] & 0xFF;
} catch (ArrayIndexOutOfBoundsException ex) {
b2 = slowLoadNextByte();
}
} else {
if (++fCurrentIndex == UTF8DataChunk.CHUNK_SIZE)
b2 = slowLoadNextByte();
else
b2 = (fMostRecentByte = fMostRecentData[fCurrentIndex] & 0xFF);
}
}
if ((0xf0 & b0) == 0xe0) { // 1110zzzz 10yyyyyy 10xxxxxx
// if ((ch >= 0xD800 && ch <= 0xDFFF) || ch >= 0xFFFE)
if ((b0 == 0xED && b1 >= 0xA0) || (b0 == 0xEF && b1 == 0xBF && b2 >= 0xBE)) {
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = saveChunk.toByteArray();
fMostRecentByte = b0;
return -1;
}
ch = ((0x0f & b0)<<12) + ((0x3f & b1)<<6) + (0x3f & b2);
if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_InitialNameCharFlag) == 0) { // zzzz yyyy yyxx xxxx (0x800 to 0xffff)
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = saveChunk.toByteArray();
fMostRecentByte = b0;
return -1;
}
} else { // 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
fCurrentChunk = saveChunk;
fCurrentIndex = saveIndex;
fCurrentOffset = saveOffset;
fMostRecentData = saveChunk.toByteArray();
fMostRecentByte = b0;
return -1;
}
}
}