Returns the next encoded code point value from the normalized input
string. The methods of the NormalizationTable
class can be
used to inspect the returned value. Returns EOF_ELEMENT
if
the end of string is reached.
if (decOffset < decLength) {
return decomposition[decOffset++];
}
int value = nextUTF32();
if (value == EOF_ELEMENT) {
return EOF_ELEMENT;
}
value = table.getCanonicalDecomposition(decomposition, 0,
value);
if (NormalizationTable.isSingleCodePoint(value)) {
if (NormalizationTable.isStable(value)) {
return value;
}
decomposition[0] = value;
decLength = 1;
} else {
decLength = value;
}
decOffset = 0;
// decompose till we get a stable code point
value = nextUTF32();
while (value != -1) {
if ((decLength + maxDecomposition) > decomposition.length) {
int[] newDecomposition = new int[decomposition.length +
CAPACITY_INCREMENT];
System.arraycopy(decomposition, 0, newDecomposition, 0,
decLength);
decomposition = newDecomposition;
}
value = table.getCanonicalDecomposition(decomposition, decLength,
value);
if (NormalizationTable.isSingleCodePoint(value)) {
decomposition[decLength++] = value;
if (NormalizationTable.isStable(value)) {
break;
}
} else {
decLength += value;
}
value = nextUTF32();
}
// order the code points according to their combining classes
boolean checkOrder;
do {
checkOrder = false;
for (int i = 1; i < decLength; ++i) {
int cp1 = decomposition[i - 1];
int cp2 = decomposition[i];
int cc1 = NormalizationTable.getCombiningClass(cp1);
int cc2 = NormalizationTable.getCombiningClass(cp2);
if ((cc1 > cc2) && (cc2 != 0)) {
decomposition[i - 1] = cp2;
decomposition[i] = cp1;
checkOrder = true;
}
}
} while (checkOrder);
if (decLength > 0) {
return decomposition[decOffset++];
}
return EOF_ELEMENT;