/*
* 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.
*/
/*
*/
private static short[] decoderIndex1;
private int currentState;
private int savedSize;
private byte[] savedBytes;
public ByteToCharGB18030() {
super();
savedBytes = new byte[3];
savedSize = 0;
}
public short[] getOuter() {
return(index1);
}
return(index2);
}
public short[] getDBIndex1() {
return(super.index1);
}
return(super.index2);
}
throws MalformedInputException
{
if (savedSize != 0) {
savedSize = 0;
badInputLength = 0;
throw new MalformedInputException();
}
return 0;
}
/**
* Character conversion
*/
{
int inputSize = 0;
char outputChar = '\uFFFD';
// readOff keeps the actual buffer's pointer.
// byteOff keeps original buffer's pointer.
if (savedSize != 0) {
// Filter illegal bytes when they are detected in saved
// partial input from a previous conversion attempt.
(savedSize > 1 &&
(savedSize > 2 &&
badInputLength = 0;
throw new MalformedInputException();
}
for (int i = 0; i < savedSize; i++) {
newBuf[i] = savedBytes[i];
}
inOff = 0;
savedSize = 0;
}
// Is there room in the output buffer for the result?
throw new ConversionBufferFullException();
}
// Get the input byte
inputSize = 1;
outputChar = (char)byte1;
}
if (subMode)
else {
badInputLength = 1;
throw new UnknownCharacterException();
}
}
else {
// Either 2 or 4 byte sequence follows
// If an underrun is detected save for later
// replay.
savedSize = 1;
break;
}
inputSize = 2;
if (byte2 < 0x30) {
badInputLength = 1;
throw new MalformedInputException();
}
inputSize = 4;
savedSize = 2;
}
else {
savedSize = 3;
}
break;
}
badInputLength = 3;
throw new MalformedInputException();
}
badInputLength = 4;
throw new MalformedInputException();
}
}
(byte2 < 0x40 )) {
badInputLength = 2;
throw new MalformedInputException();
}
else
}
switch (currentState){
case GB18030_SINGLE_BYTE:
break;
case GB18030_DOUBLE_BYTE:
break;
case GB18030_FOUR_BYTE:
// Mixture of table lookups and algorithmic calculation
// of character values.
// BMP Ranges
if (offset <= 0x4A62)
// Supplemental UCS planes handled via surrogates
if (offset >= 0x12E248) {
if (subMode)
return subChars[0];
else {
badInputLength = 4;
throw new UnknownCharacterException();
}
}
throw new ConversionBufferFullException();
}
offset -= 0x1e248;
}
else {
badInputLength = 4;
throw new MalformedInputException();
}
break;
}
}
}
public void reset() {
savedSize = 0;
}
return "GB18030";
}
if (subMode)
return subChars[0];
else {
badInputLength = 1;
throw new UnknownCharacterException();
}
}
}
}