/*
* 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 char highHalfZoneCode;
private boolean flushed = true;
// JIS is state full encoding, so currentMode keep the
// current codeset
/**
* Bytes for substitute for unmappable input.
*/
// XXX: Assumes subBytes are ASCII string. Need to change Escape sequence
// for other character sets.
{
if (highHalfZoneCode != 0) {
highHalfZoneCode = 0;
badInputLength = 0;
throw new MalformedInputException();
}
throw new ConversionBufferFullException();
}
byteOff += 3;
flushed = true;
currentMode = ASCII;
return 3;
}
return 0;
}
{
char inputChar; // Input character to be converted
int inputSize; // Size of the input
int outputSize; // Size of the output
// Buffer for output bytes
byte[] tmpArray = new byte[6];
byte[] outputByte;
flushed = false;
// Make copies of input and output indexes
if (highHalfZoneCode != 0) {
highHalfZoneCode = 0;
// This is legal UTF16 sequence.
badInputLength = 1;
throw new UnknownCharacterException();
} else {
// This is illegal UTF16 sequence.
badInputLength = 0;
throw new MalformedInputException();
}
}
// Loop until we run out of input
// Get the input character
inputSize = 1;
outputSize = 1;
// Is this a high surrogate?
// Is this the last character of the input?
break;
}
// Is there a low surrogate following?
// We have a valid surrogate pair. Too bad we don't do
// surrogates. Is substitution enabled?
if (subMode) {
if (currentMode != subBytesMode) {
} else {
}
inputSize = 2;
} else {
badInputLength = 2;
throw new UnknownCharacterException();
}
} else {
// We have a malformed surrogate pair
badInputLength = 1;
throw new MalformedInputException();
}
}
// Is this an unaccompanied low surrogate?
badInputLength = 1;
throw new MalformedInputException();
} else {
// Not part of a surrogate
// Does this map to the Roman range?
if (inputChar <= '\u007F') {
if (currentMode != ASCII) {
outputSize = 4;
} else {
outputSize = 1;
}
}
// Is it a single byte kana?
if (currentMode != JISX0201_1976_KANA) {
outputSize = 4;
} else {
outputSize = 1;
}
}
// Is it a yen sign?
else if (inputChar == '\u00A5') {
if (currentMode != JISX0201_1976) {
outputSize = 4;
} else {
outputSize = 1;
}
}
// Is it a tilde?
else if (inputChar == '\u203E')
{
if (currentMode != JISX0201_1976) {
outputSize = 4;
} else {
outputSize = 1;
}
}
// Is it a JIS-X-0208 character?
else {
if (index != 0) {
if (currentMode != JISX0208_1983) {
outputSize = 5;
} else {
outputSize = 2;
}
}
// It doesn't map to JIS-0208!
else {
if (subMode) {
if (currentMode != subBytesMode) {
} else {
}
} else {
badInputLength = 1;
throw new UnknownCharacterException();
}
}
}
}
// Is there room in the output buffer?
// XXX: The code assumes output buffer can hold at least 5 bytes,
// in this coverter case. However, there is no way for apps to
// see how many bytes will be necessary for next call.
// getMaxBytesPerChar() should be overriden in every subclass of
// CharToByteConverter and reflect real value (5 for this).
throw new ConversionBufferFullException();
// Put the output into the buffer
for ( int i = 0 ; i < outputSize ; i++ )
// Advance the input pointer
// We can successfuly output the characters, changes
// current mode. Fix for 4251646.
}
// return mode ASCII at the end
if (currentMode != ASCII){
throw new ConversionBufferFullException();
currentMode = ASCII;
}
// Return the length written to the output buffer
}
// Reset
public void reset() {
highHalfZoneCode = 0;
currentMode = ASCII;
}
/**
* returns the maximum number of bytes needed to convert a char
*/
public int getMaxBytesPerChar() {
return 8;
}
// Return the character set ID
return "ISO2022JP";
}
}