/*
* 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 boolean savedBytePresent;
private int savedByte;
super();
currentState = SBCS;
savedBytePresent = false;
}
char decodeSingle(int b) {
return dec.decodeSingle(b);
}
}
throws MalformedInputException
{
if (savedBytePresent) {
reset();
badInputLength = 0;
throw new MalformedInputException();
}
reset();
return 0;
}
/**
* Character conversion
*/
{
int inputSize;
char outputChar = UNMAPPABLE_DECODING;
if (!savedBytePresent) {
inputSize = 1;
} else {
savedBytePresent = false;
inputSize = 0;
}
// For SO characters - simply validate the state and if OK
// update the state and go to the next byte
if (currentState != SBCS) {
badInputLength = 1;
throw new MalformedInputException();
} else {
currentState = DBCS;
}
}
else
// For SI characters - simply validate the state and if OK
// update the state and go to the next byte
if (currentState != DBCS) {
badInputLength = 1;
throw new MalformedInputException();
} else {
currentState = SBCS;
}
} else {
// Process the real data characters
if (currentState == SBCS) {
} else {
// for a DBCS character - architecture dictates the
// valid range of 1st bytes
badInputLength = 1;
throw new MalformedInputException();
}
// We have been split in the middle if a character
// save the first byte for next time around
savedBytePresent = true;
break;
}
inputSize++;
// validate the pair of bytes meet the architecture
badInputLength = 2;
throw new MalformedInputException();
}
}
if (outputChar == UNMAPPABLE_DECODING) {
if (subMode)
else {
throw new UnknownCharacterException();
}
}
throw new ConversionBufferFullException();
}
}
}
/**
* Resets the converter.
*/
public void reset() {
currentState = SBCS;
savedBytePresent = false;
}
}