/*
* 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 int currentState;
private int savedSize;
private byte[] savedBytes;
public ByteToCharISO2022JP() {
super();
savedBytes = new byte[2];
savedSize = 0;
}
throws MalformedInputException
{
if (savedSize != 0) {
savedSize = 0;
badInputLength = 0;
throw new MalformedInputException();
}
return 0;
}
/**
* Character conversion
*/
{
int previousState = ASCII;
int inputSize = 0;
char outputChar = '\uFFFD';
// readOff keeps the actual buffer's pointer.
// byteOff keeps original buffer's pointer.
if (savedSize != 0) {
if ((savedSize == 2 &&
((savedSize == 1) &&
badInputLength = 0;
throw new MalformedInputException();
}
savedSize = 2;
byteOff++;
return 0;
}
}
for (int i = 0; i < savedSize; i++) {
newBuf[i] = savedBytes[i];
}
inOff = 0;
savedSize = 0;
}
boolean noOutput = false;
// Is there room in the output buffer for the result?
throw new ConversionBufferFullException();
}
// Get the input byte
inputSize = 1;
badInputLength = 1;
throw new MalformedInputException();
}
// Is this a escape sequence?
savedSize = 1;
} else {
savedSize = 2;
inputSize++;
}
break;
}
inputSize++;
badInputLength = 2;
throw new MalformedInputException();
}
if (byte2 == 0x28){
inputSize++;
if (byte3 == 'B'){
} else if (byte3 == 'J'){
} else if (byte3 == 'I'){
} else {
// illegal ESC sequence
badInputLength = 3;
throw new MalformedInputException();
}
} else if (byte2 == '$'){
inputSize++;
badInputLength = 3;
throw new MalformedInputException();
}
if (byte3 == '@'){
} else if (byte3 == 'B'){
} else {
// illegal ESC sequence
badInputLength = 3;
throw new MalformedInputException();
}
} else {
// illegal ESC sequence
badInputLength = 2;
throw new MalformedInputException();
}
noOutput = true;
break;
} else {
inputSize++;
}
noOutput = true;
break;
}
inputSize++;
badInputLength = 1;
throw new MalformedInputException();
}
noOutput = true;
break;
}
inputSize++;
badInputLength = 1;
throw new MalformedInputException();
}
}
}
break;
}
noOutput = false;
switch (currentState){
case ASCII:
break;
case JISX0201_1976:
switch (byte1) {
case 0x5c:
outputChar = '\u00a5';
break;
case 0x7e:
outputChar = '\u203e';
break;
default:
outputChar = (char)byte1;
break;
}
break;
case JISX0208_1978:
case JISX0208_1983:
savedSize = 1;
break;
}
inputSize++;
badInputLength = 1;
throw new MalformedInputException();
}
// jisx0208Chars table convert FULLWIDTH_REVERSE_SOLIDUS
// 0x2140 to REVERSE_SOLIDUS (BACKSLASH) 0x5c.
// This behavior causes problem because
// 0x5c is special escape character for java.
outputChar = '\uFF3C';
} else {
try {
} catch (ArrayIndexOutOfBoundsException e) {
outputChar = '\uFFFD';
}
}
break;
case JISX0201_1976_KANA:
case SHIFTOUT:
if (byte1 > 0x60) {
badInputLength = 1;
throw new MalformedInputException();
}
break;
}
if (savedSize != 0) {
break;
}
if (outputChar == '\uFFFD') {
if (subMode)
else {
throw new UnknownCharacterException();
}
}
}
}
public void reset() {
savedSize = 0;
}
return "ISO2022JP";
}
}