gnu.gcj.convert

Class UnicodeToBytes

Known Direct Subclasses:
CharsetToBytesAdaptor, Output_8859_1, Output_ASCII, Output_EUCJIS, Output_iconv, Output_JavaSrc, Output_SJIS, Output_UnicodeLittleUnmarked, Output_UTF8

public abstract class UnicodeToBytes
extends IOConverter

Field Summary

byte[]
buf
Buffer to emit bytes to.
int
count

Fields inherited from class gnu.gcj.convert.IOConverter

iconv_byte_swap

Method Summary

void
done()
Indicate that the converter is resuable.
static UnicodeToBytes
getDefaultEncoder()
static UnicodeToBytes
getEncoder(String encoding)
Get a char-stream->byte-stream converter given an encoding name.
abstract String
getName()
boolean
havePendingBytes()
Returns true when the converter has consumed some bytes that are not yet converted to characters because further continuation bytes are needed.
void
setFinished()
Users should call this method when the input is coming to an end.
void
setOutput(byte[] buffer, int count)
abstract int
write(char[] inbuffer, int inpos, int inlength)
Convert chars to bytes.
int
write(String str, int inpos, int inlength, char[] work)
Convert chars to bytes.

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

buf

public byte[] buf
Buffer to emit bytes to. The locations buf[count] ... buf[buf.length-1] are available.

count

public int count

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.

getDefaultEncoder

public static UnicodeToBytes getDefaultEncoder()

getEncoder

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

getName

public abstract String getName()

havePendingBytes

public boolean havePendingBytes()
Returns true when the converter has consumed some bytes that are not yet converted to characters because further continuation bytes are needed. Defaults to false, should be overridden by decoders that internally store some bytes.

setFinished

public void setFinished()
Users should call this method when the input is coming to an end. This signals that the next write (which might be zero-length) ought to flush any internal state.

setOutput

public final void setOutput(byte[] buffer,
                            int count)

write

public abstract int write(char[] inbuffer,
                          int inpos,
                          int inlength)
Convert chars to bytes. Converted bytes are written to buf, starting at count.
Parameters:
inbuffer - source of characters to convert
inpos - index of initial character in inbuffer to convert
inlength - number of characters to convert
Returns:
number of chars converted Also, this.count is increment by the number of bytes converted.

write

public int write(String str,
                 int inpos,
                 int inlength,
                 char[] work)
Convert chars to bytes. Converted bytes are written to buf, starting at count.
Parameters:
str - source of characters to convert
inpos - index of initial character in str to convert
inlength - number of characters to convert
work - if non-null, a buffer than can be used
Returns:
number of chars converted Also, this.count is increment by the number of bytes converted.

Copyright (C) 1999, 2000, 2001, 2003, 2005, 2006 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.