gnu.gcj.convert

Class CharsetToBytesAdaptor


public class CharsetToBytesAdaptor
extends UnicodeToBytes

Adaptor class that allow any Charset to be used as a UnicodeToBytes converter.

Field Summary

Fields inherited from class gnu.gcj.convert.UnicodeToBytes

buf, count

Fields inherited from class gnu.gcj.convert.IOConverter

iconv_byte_swap

Constructor Summary

CharsetToBytesAdaptor(Charset cs)
Create a new CharsetToBytesAdaptor for the given Charset.
CharsetToBytesAdaptor(CharsetEncoder enc)
Create a new CharsetToBytesAdaptor for the given CharsetEncoder.

Method Summary

void
done()
Indicate that the converter is resuable.
String
getName()
Return the encoder's name.
boolean
havePendingBytes()
Check for cached output in the converter.
void
setFinished()
Users should call this method when the input is coming to an end.
int
write(char[] inbuffer, int inpos, int inlength)
Convert chars to bytes.
int
write(String str, int inpos, int inlength, char work)

Methods inherited from class gnu.gcj.convert.UnicodeToBytes

done, getDefaultEncoder, getEncoder, getName, havePendingBytes, setFinished, setOutput, write, write

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

Constructor Details

CharsetToBytesAdaptor

public CharsetToBytesAdaptor(Charset cs)
Create a new CharsetToBytesAdaptor for the given Charset.
Parameters:
cs - The Charset.

CharsetToBytesAdaptor

public CharsetToBytesAdaptor(CharsetEncoder enc)
Create a new CharsetToBytesAdaptor for the given CharsetEncoder.
Parameters:
enc - The CharsetEncoder.

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.
Overrides:
done in interface UnicodeToBytes

getName

public String getName()
Return the encoder's name. The backing Charset's name is returned.
Overrides:
getName in interface UnicodeToBytes
Returns:
The name.

havePendingBytes

public boolean havePendingBytes()
Check for cached output in the converter.
Overrides:
havePendingBytes in interface UnicodeToBytes
Returns:
true if there is cached output that has not been written to buf.

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.
Overrides:
setFinished in interface UnicodeToBytes

write

public int write(char[] inbuffer,
                 int inpos,
                 int inlength)
Convert chars to bytes. Converted bytes are written to buf, starting at count.
Overrides:
write in interface UnicodeToBytes
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)

Copyright (C) 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.