/*
* 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.
*/
final class CompoundTextSupport {
private static final class ControlSequence {
final int hash;
final byte[] escSequence;
final byte[] encoding;
this(escSequence, null);
}
if (escSequence == null) {
throw new NullPointerException();
}
this.escSequence = escSequence;
int hash = 0;
}
}
}
if (MAX_CONTROL_SEQUENCE_LEN < length) {
}
}
if (this == obj) {
return true;
}
if (!(obj instanceof ControlSequence)) {
return false;
}
return false;
}
return false;
}
}
}
{
return false;
}
return false;
}
}
}
return true;
}
public int hashCode() {
return hash;
}
throw new IllegalArgumentException
("cannot concatenate to a non-standard charset escape " +
"sequence");
}
byte[] newEscSequence = new byte[len];
}
}
static int MAX_CONTROL_SEQUENCE_LEN;
/**
* Maps a GL or GR escape sequence to an encoding.
*/
/**
* Indicates whether a particular encoding wants the high bit turned on
* or off.
*/
/**
* Maps an encoding to an escape sequence. Rather than manage two
* converters in CharToByteCOMPOUND_TEXT, we output escape sequences which
* modify both GL and GR if necessary. This makes the output slightly less
* efficient, but our code much simpler.
*/
/**
* The keys of 'encodingToSequenceMap', sorted in preferential order.
*/
static {
if (!(isEncodingSupported("US-ASCII") &&
isEncodingSupported("ISO-8859-1")))
{
throw new ExceptionInInitializerError
("US-ASCII and ISO-8859-1 unsupported");
}
{
}
{
}
if (isEncodingSupported("ISO-8859-2")) {
}
if (isEncodingSupported("ISO-8859-3")) {
}
if (isEncodingSupported("ISO-8859-4")) {
}
if (isEncodingSupported("ISO-8859-5")) {
}
if (isEncodingSupported("ISO-8859-6")) {
}
if (isEncodingSupported("ISO-8859-7")) {
}
if (isEncodingSupported("ISO-8859-8")) {
}
if (isEncodingSupported("ISO-8859-9")) {
}
if (isEncodingSupported("JIS_X0201")) {
}
if (isEncodingSupported("X11GB2312")) {
}
if (isEncodingSupported("x-JIS0208")) {
}
if (isEncodingSupported("X11KSC5601")) {
}
// Encodings not listed in Compound Text Encoding spec
// Esc seq: -b
if (isEncodingSupported("ISO-8859-15")) {
}
// Esc seq: -T
if (isEncodingSupported("TIS-620")) {
}
if (isEncodingSupported("JIS_X0212-1990")) {
}
if (isEncodingSupported("X11CNS11643P1")) {
}
if (isEncodingSupported("X11CNS11643P2")) {
}
if (isEncodingSupported("X11CNS11643P3")) {
}
// Esc seq: %/2??SUN-KSC5601.1992-3
if (isEncodingSupported("x-Johab")) {
// 0x32 looks wrong. It's copied from the Sun X11 Compound Text
// support code. It implies that all Johab characters comprise two
// characters from 0x21-0x7E with single-byte representations.
new byte[] { 0x1b, 0x25, 0x2f, 0x32 },
new byte[] { 0x53, 0x55, 0x4e, 0x2d, 0x4b, 0x53, 0x43, 0x35,
0x36, 0x30, 0x31, 0x2e, 0x31, 0x39, 0x39, 0x32,
0x2d, 0x33 });
}
// Esc seq: %/2??SUN-BIG5-1
if (isEncodingSupported("Big5")) {
// 0x32 looks wrong. It's copied from the Sun X11 Compound Text
// support code. It implies that all Big5 characters comprise two
// characters from 0x21-0x7E with single-byte representations.
new byte[] { 0x1b, 0x25, 0x2f, 0x32 },
new byte[] { 0x53, 0x55, 0x4e, 0x2d, 0x42, 0x49, 0x47, 0x35,
0x2d, 0x31 });
}
}
try {
return true;
} catch (IllegalArgumentException x) { }
}
// For Decoder
}
}
byte[] encoding) {
}
return null;
}
try {
} catch (IllegalArgumentException e) {
try {
} catch (ClassNotFoundException ee) {
return null;
}
try {
} catch (InstantiationException ee) {
return null;
} catch (IllegalAccessException ee) {
return null;
}
}
try {
return cs.newDecoder();
} catch (UnsupportedOperationException e) {}
return null;
}
// For Encoder
return seq.escSequence;
}
return null;
}
}
return null;
}
return encodings;
}
return null;
}
try {
} catch (IllegalArgumentException e) {
try {
} catch (ClassNotFoundException ee) {
return null;
}
try {
} catch (InstantiationException ee) {
return null;
} catch (IllegalAccessException ee) {
return null;
}
}
try {
return cs.newEncoder();
} catch (Throwable e) {}
return null;
}
// Not an instantiable class
private CompoundTextSupport() {}
}