UCDecoder.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 1999-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* Copyright 1996 Active Software Inc.
*/
// Referenced classes of package sunsoft.jws.visual.rt.encoding:
// CEStreamExhausted, CRC16
public class UCDecoder
{
protected int bytesPerAtom()
{
return 2;
}
protected int bytesPerLine()
{
return 48;
}
OutputStream outStream, int l)
throws IOException
{
byte a = -1;
byte b = -1;
byte c = -1;
byte tmp[] = new byte[3];
if (i != 3)
throw new CEStreamExhausted();
for (i = 0; i < 64 && (a == -1 || b == -1 || c == -1); i++)
{
a = (byte)i;
b = (byte)i;
c = (byte)i;
}
int p1 = 0;
int p2 = 0;
for (i = 1; i < 256; i *= 2)
{
if ((high_byte & i) != 0)
p1++;
if ((low_byte & i) != 0)
p2++;
}
throw new IOException("UCDecoder: High byte parity error.");
throw new IOException("UCDecoder: Low byte parity error.");
if (l == 2)
{
}
}
{
sequence = 0;
}
throws IOException
{
do
{
if (c == -1)
throw new CEStreamExhausted();
}
lineAndSeq.reset();
{
throw new IOException("UCDecoder: Out of sequence line.");
}
else
{
return nLen;
}
}
throws IOException
{
lineAndSeq.reset();
throw new IOException("UCDecoder: CRC check failed.");
else
return;
}
throws IOException
{
int totalBytes = 0;
try
{
do
{
int i;
i += bytesPerAtom())
{
totalBytes += bytesPerAtom();
}
if (i + bytesPerAtom() == length)
{
totalBytes += bytesPerAtom();
}
else
{
totalBytes += length - i;
}
}
while (true);
}
catch (CEStreamExhausted ex)
{
}
}
throws IOException
{
return outStream.toByteArray();
}
throws IOException
{
}
public UCDecoder()
{
super();
tmp = new byte[2];
}
private static final byte map_array[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 40, 41
};
private int sequence;
private byte tmp[];
private ByteArrayOutputStream lineAndSeq;
}