gnu.gcj.convert

Class BytesToUnicode

Known Direct Subclasses:
BytesToCharsetAdaptor, Input_8859_1, Input_ASCII, Input_EUCJIS, Input_iconv, Input_JavaSrc, Input_SJIS, Input_UnicodeBig, Input_UnicodeLittle, Input_UTF8

public abstract class BytesToUnicode
extends IOConverter

Field Summary

byte[]
inbuffer
Buffer to read bytes from.
int
inlength
End of valid bytes in buffer.
int
inpos
Starting index in buffer to read bytes from.

Fields inherited from class gnu.gcj.convert.IOConverter

iconv_byte_swap

Method Summary

void
done()
Indicate that the converter is resuable.
static BytesToUnicode
getDecoder(String encoding)
Get a byte-stream->char-stream converter given an encoding name.
static BytesToUnicode
getDefaultDecoder()
abstract String
getName()
abstract int
read(char[] outbuffer, int outpos, int count)
Convert bytes to chars.
void
setInput(byte[] buffer, int pos, int length)
Make input bytes available to the conversion.

Methods inherited from class gnu.gcj.convert.IOConverter

canonicalize

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

inbuffer

public byte[] inbuffer
Buffer to read bytes from. The characters inbuffer[inpos] ... inbuffer[inlength-1] are available.

inlength

public int inlength
End of valid bytes in buffer.

inpos

public int inpos
Starting index in buffer to read bytes from.

Method Details

done

public void done()
Indicate that the converter is resuable. This class keeps track of converters on a per-encoding basis. When done with an encoder you may call this method to indicate that it can be reused later.

getDecoder

public static BytesToUnicode getDecoder(String encoding)
            throws UnsupportedEncodingException
Get a byte-stream->char-stream converter given an encoding name.

getDefaultDecoder

public static BytesToUnicode getDefaultDecoder()

getName

public abstract String getName()

read

public abstract int read(char[] outbuffer,
                         int outpos,
                         int count)
Convert bytes to chars. Input bytes are taken from this.inbuffer. The available input bytes start at inbuffer[inpos], and end at inbuffer[inlength-1].
Parameters:
outbuffer - buffer for the converted character
outpos - position in buffer to start putting converted characters
count - the maximum number of characters to convert
Returns:
number of chars placed in outbuffer. Also, this.inpos is incremented by the number of bytes consumed. (Note the asymmetry in that the input upper bound is inbuffer[inlength-1], while the output upper bound is outbuffer[outpos+count-1]. The justification is that inlength is like the count field of a BufferedInputStream, while the count parameter is like the length parameter of a read request.) The count parameter is also defined to be <= outbuffer.length - outpos (per the specification of the length parameter for a read request).

setInput

public final void setInput(byte[] buffer,
                           int pos,
                           int length)
Make input bytes available to the conversion.
Parameters:
buffer - source of input bytes
pos - index of first available byte
length - one more than index of last available byte

Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation This file is part of libgcj. This software is copyrighted work licensed under the terms of the Libgcj License. Please consult the file "LIBGCJ_LICENSE" for details.