Gen_Writerpublic class Gen_Writer extends StreamWriter Generic interface for stream conversion writing of
specific character encoded input streams.
. |
Fields Summary |
---|
private String | encSaved encoding string from construction. | private int | idNative handle for conversion routines. | private byte[] | bufLocal buffer to write converted characters. | private int | maxByteLenMaximum length of characters in local buffer. |
Constructors Summary |
---|
Gen_Writer(String inp_enc)Constructor for generic writer.
id = Conv.getHandler(inp_enc);
if (id == -1) {
throw new ClassNotFoundException();
}
enc = inp_enc;
maxByteLen = Conv.getMaxByteLength(id);
buf = new byte[maxByteLen];
|
Methods Summary |
---|
public java.io.Writer | open(java.io.OutputStream out, java.lang.String open_enc)Generic routine to open an OutputStream with a specific
character encoding.
if (!open_enc.equals(enc)) {
throw new UnsupportedEncodingException();
}
return super.open(out, open_enc);
| public int | sizeOf(char[] cbuf, int off, int len)Get the size of the converted bytes as a Unicode
byte array.
return Conv.sizeOfUnicodeInByte(id, cbuf, off, len);
| public synchronized void | write(int c)Write a single converted character.
char cbuf[] = {(char)c};
int len = Conv.charToByte(id, cbuf, 0, 1, buf, 0, buf.length);
if (len > 0) {
out.write(buf, 0, len);
}
| public synchronized void | write(char[] cbuf, int off, int len)Write a block of converted characters.
int maxlen = len * maxByteLen;
if (buf.length < maxlen) {
buf = new byte[maxlen];
}
len = Conv.charToByte(id, cbuf, off, len, buf, 0, buf.length);
if (len > 0) {
out.write(buf, 0, len);
}
if (buf.length > maxByteLen) {
buf = new byte[maxByteLen];
}
| public synchronized void | write(java.lang.String str, int off, int len)Write a block of converted characters from a string.
for (int i = 0; i < len; i++) {
write(str.charAt(off + i));
}
|
|