| java.lang.Object uk.org.ponder.stringutil.ByteToCharConverter
All known Subclasses: uk.org.ponder.stringutil.ByteToCharUTF8,
ByteToCharConverter | abstract public class ByteToCharConverter (Code) | | This abstract class forms part of the fast and better instrumented
uk.org.ponder.streamutil.DirectInputStreamReader architecture. It is
intended as a base class for specific byte to character decoders
(such as ByteToCharUTF8), and abstracts away the non-stream and
non-encoding specific tasks of working out whether anything needs
doing or not, and if so how much and where it is.
|
Method Summary | |
public void | blastState() Destroy all the state stored in this converter, so it holds no resources
and is ready to begin conversion again. | abstract public int | convert() Convert as many bytes from inbuffer to characters in outbuffer
as possible. | public void | ensureInputBuffer(int buffersize) Ensure that the current input buffer is big enough to accommodate the specified
number of input bytes, by reallocating it if necessary. | abstract public String | getCharacterEncoding() | public byte[] | getInputBuffer() | public int | getInputBufferLimit() | abstract public int | getMaxOutput(int inputsize) Returns the maximum possible number of characters that could be decoded from
an input byte sequence of the specified length. | public int | getOutputBufferPos() | public void | handleEncodingError(String errortype) Trigger an encoding error to be delivered to any registered EncodingErrorHandler.
There is one sort of error that can only be detected from the
outside of this class, namely an incomplete input sequence but no
further input available. | public void | increaseInputBufferLimit(int bytesread) | public int | missing_bytes() Returns the number of bytes needed to complete the current input sequence. | public void | setEncodingErrorHandler(EncodingErrorHandler errorhandler) Sets the error handler that will be used to report errors encountered in the
byte encoding of the data. | public void | setOutputBuffer(char[] outbuffer, int outbufferpos, int outbufferlimit) Sets the output buffer to which decoded character data should be written.
Parameters: outbuffer - A character buffer to which character data can be written. Parameters: outbufferpos - The position within the buffer to which the character datacan be written. Parameters: outbufferlimit - The index of the logical end of the buffer. | public void | swizzInputBuffer() |
STOP_INPUT_EXHAUSTED | final public static int STOP_INPUT_EXHAUSTED(Code) | | Return code from convert() indicating conversion stopped because
there was no space left in the input buffer.
|
STOP_INPUT_EXHAUSTED_EXACTLY | final public static int STOP_INPUT_EXHAUSTED_EXACTLY(Code) | | Return code from convert() indicating conversion stopped because
there was no input left in the input buffer, but also that no partial input sequence
was left in it.
|
STOP_OUTPUT_EXHAUSTED | final public static int STOP_OUTPUT_EXHAUSTED(Code) | | Return code from convert() indicating conversion stopped because
there was no space left in the output buffer.
|
inbuffer | protected byte[] inbuffer(Code) | | |
inbufferlimit | protected int inbufferlimit(Code) | | |
inbufferpos | protected int inbufferpos(Code) | | |
input_sequence_length | protected int input_sequence_length(Code) | | |
linenumber | protected int linenumber(Code) | | |
outbuffer | protected char[] outbuffer(Code) | | |
outbufferlimit | protected int outbufferlimit(Code) | | |
outbufferpos | protected int outbufferpos(Code) | | |
output_sequence_length | protected int output_sequence_length(Code) | | |
totalbytesin | protected int totalbytesin(Code) | | |
ByteToCharConverter | public ByteToCharConverter()(Code) | | |
blastState | public void blastState()(Code) | | Destroy all the state stored in this converter, so it holds no resources
and is ready to begin conversion again.
|
convert | abstract public int convert()(Code) | | Convert as many bytes from inbuffer to characters in outbuffer
as possible. The return codes from this method are listed above, indicating
which out of the input and the output was actually exhausted.
|
ensureInputBuffer | public void ensureInputBuffer(int buffersize)(Code) | | Ensure that the current input buffer is big enough to accommodate the specified
number of input bytes, by reallocating it if necessary. This method does not
preserve the buffer contents.
Parameters: buffersize - The required input buffer size. |
getCharacterEncoding | abstract public String getCharacterEncoding()(Code) | | Returns the name of the byte to character (UTF-16) encoding performed by this
converter
|
getInputBuffer | public byte[] getInputBuffer()(Code) | | |
getInputBufferLimit | public int getInputBufferLimit()(Code) | | |
getMaxOutput | abstract public int getMaxOutput(int inputsize)(Code) | | Returns the maximum possible number of characters that could be decoded from
an input byte sequence of the specified length. Currently disused.
Parameters: inputsize - The number of input bytes for which the maximum decoded charactersare required. |
getOutputBufferPos | public int getOutputBufferPos()(Code) | | |
handleEncodingError | public void handleEncodingError(String errortype)(Code) | | Trigger an encoding error to be delivered to any registered EncodingErrorHandler.
There is one sort of error that can only be detected from the
outside of this class, namely an incomplete input sequence but no
further input available. For this reason this method has been
given public access to allow an error report to be triggered
externally
Parameters: errortype - A String reprenting the type of the error that has occurred.This string will be passed on via the EncodingErrorHandler interface. |
increaseInputBufferLimit | public void increaseInputBufferLimit(int bytesread)(Code) | | |
missing_bytes | public int missing_bytes()(Code) | | Returns the number of bytes needed to complete the current input sequence.
the number of bytes needed toc complete the current input sequence.positive if we need more bytes to complete the current sequence, zero if we have exactlyused up all input, negative if there is more input remaining. |
setEncodingErrorHandler | public void setEncodingErrorHandler(EncodingErrorHandler errorhandler)(Code) | | Sets the error handler that will be used to report errors encountered in the
byte encoding of the data.
Parameters: errorhandler - An interface through which decoding errors may be reported. |
setOutputBuffer | public void setOutputBuffer(char[] outbuffer, int outbufferpos, int outbufferlimit)(Code) | | Sets the output buffer to which decoded character data should be written.
Parameters: outbuffer - A character buffer to which character data can be written. Parameters: outbufferpos - The position within the buffer to which the character datacan be written. Parameters: outbufferlimit - The index of the logical end of the buffer. If datais written exactly up to this point, the buffer will be considered full anddecoding will stop until another buffer is supplied. |
swizzInputBuffer | public void swizzInputBuffer()(Code) | | Reorganise the input buffer by rotating the current input point to the beginning,
ready to receive more input after inbufferlimit
|
|
|