public class CharsetConverter extends Object
Constructor and Description |
---|
CharsetConverter(Charset fromCharset,
Charset toCharset)
Creates a new charset converted that decodes/encodes bytes in the
specified non-null from/to charset objects specified.
|
CharsetConverter(Charset fromCharset,
Charset toCharset,
boolean ignoreBOM)
Creates a new charset converted that decodes/encodes bytes in the
specified non-null from/to charset objects specified.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
clearUnderflow()
Get and clear the current converted underflow byte array.
|
ByteBuffer |
convert(ByteBuffer from)
Convert a byte buffer by decoding using the fromCharset and encoding
using the toCharset.
|
ByteBuffer |
convert(ByteBuffer from,
ILookahead lookahead)
Convert a byte buffer by decoding using the fromCharset and encoding
using the toCharset.
|
ByteBuffer |
convert(CharBuffer from)
Converts a char buffer to a byte buffer using the toCharset.
|
String |
getFromCharsetName()
Get charset name of from charset used to decode
|
String |
getToCharsetName()
Get charset name of to charset used to encode
|
public CharsetConverter(Charset fromCharset, Charset toCharset, boolean ignoreBOM)
fromCharset
- toCharset
- ignoreBOM
- - true to ignore any byte order marks written by the UTF-16
charset and omit them from all return byte bufferspublic String getFromCharsetName()
public String getToCharsetName()
public byte[] clearUnderflow()
ByteBuffer
and specified as
the from buffer on a call to convert(ByteBuffer)
to try convert
any remaining bytes.convert(ByteBuffer)
did not have underflow.public ByteBuffer convert(CharBuffer from) throws FileEncoderException
from
- Buffer.position()
for starting
array offset, Buffer.limit()
for number of bytes to
read, and ByteBuffer.array()
for the byte[] itself.FileEncoderException
public ByteBuffer convert(ByteBuffer from, ILookahead lookahead) throws FileDecoderException, FileEncoderException
convert(ByteBuffer)
. The from buffer specified
will be joined with the underflow from a previous call on subsequent
calls to convert(ByteBuffer)
.from
- - byte buffer to convertlookahead
- - lookahead callbackBuffer.position()
for starting
array offset, Buffer.limit()
for number of bytes to
read, and ByteBuffer.array()
for the byte[] itself.FileDecoderException
FileEncoderException
public ByteBuffer convert(ByteBuffer from) throws FileDecoderException, FileEncoderException
convert(ByteBuffer)
. The from buffer specified
will be joined with the underflow from a previous call on subsequent
calls to convert(ByteBuffer)
.from
- - byte buffer to convertBuffer.position()
for starting
array offset, Buffer.limit()
for number of bytes to
read, and ByteBuffer.array()
for the byte[] itself.FileEncoderException
FileDecoderException
Copyright © 2017 Perforce Software. All Rights Reserved.