public class Encoding extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
Encoding(Charset encoding)
Use the charset passed as parameter and tests at creation time whether the specified encoding
is compatible with ASCII numbers.
|
protected |
Encoding(Charset encoding,
boolean fastASCIINumbers)
Subclasses may use this constructor if they know in advance of their ASCII number
compatibility.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
canonicalize(String string)
Indicates that string should be staged as a canonicalized value.
|
String |
decode(byte[] encodedString)
Decode an array of bytes into a string.
|
String |
decode(byte[] encodedString,
int offset,
int length)
Decode an array of bytes into a string.
|
String |
decodeCanonicalized(byte[] encodedString)
Decode an array of bytes possibly into a canonicalized string.
|
String |
decodeCanonicalized(byte[] encodedString,
int offset,
int length)
Decode an array of bytes possibly into a canonicalized string.
|
String |
decodeCanonicalizedIfPresent(byte[] encodedString,
int offset,
int length) |
static Encoding |
defaultEncoding()
Get an Encoding using the default encoding for the JVM.
|
byte[] |
encode(@PolyNull String s)
Encode a string to an array of bytes.
|
static Encoding |
getDatabaseEncoding(String databaseEncoding)
Construct an Encoding for a given database encoding.
|
Reader |
getDecodingReader(InputStream in)
Get a Reader that decodes the given InputStream using this encoding.
|
Writer |
getEncodingWriter(OutputStream out)
Get a Writer that encodes to the given OutputStream using this encoding.
|
static Encoding |
getJVMEncoding(String jvmEncoding)
Construct an Encoding for a given JVM encoding.
|
boolean |
hasAsciiNumbers()
Returns true if this encoding has characters '-' and '0'..'9' in exactly same posision as
ascii.
|
String |
name()
Get the name of the (JVM) encoding used.
|
String |
toString() |
protected Encoding(Charset encoding, boolean fastASCIINumbers)
encoding - charset to usefastASCIINumbers - whether this encoding is compatible with ASCII numbers.protected Encoding(Charset encoding)
encoding - charset to usepublic boolean hasAsciiNumbers()
public static Encoding getJVMEncoding(String jvmEncoding)
jvmEncoding - the name of the JVM encodingpublic static Encoding getDatabaseEncoding(String databaseEncoding)
databaseEncoding - the name of the database encodingpublic static void canonicalize(String string)
This is intended for use with String constants.
string - The string to maintain canonicalized reference to. Must not be null.decodeCanonicalized(byte[], int, int)public String name()
public byte[] encode(@PolyNull String s) throws IOException
s - the string to encodeIOException - if something goes wrongpublic String decodeCanonicalized(byte[] encodedString, int offset, int length) throws IOException
Only ascii compatible encoding support canonicalization and only ascii String values are eligible
to be canonicalized.
encodedString - a byte array containing the string to decodeoffset - the offset in encodedString of the first byte of the encoded
representationlength - the length, in bytes, of the encoded representationIOException - if something goes wrongpublic String decodeCanonicalizedIfPresent(byte[] encodedString, int offset, int length) throws IOException
IOExceptionpublic String decodeCanonicalized(byte[] encodedString) throws IOException
Only ascii compatible encoding support canonicalization and only ascii String values are eligible
to be canonicalized.
encodedString - a byte array containing the string to decodeIOException - if something goes wrongpublic String decode(byte[] encodedString, int offset, int length) throws IOException
encodedString - a byte array containing the string to decodeoffset - the offset in encodedString of the first byte of the encoded
representationlength - the length, in bytes, of the encoded representationIOException - if something goes wrongpublic String decode(byte[] encodedString) throws IOException
encodedString - a byte array containing the string to decodeIOException - if something goes wrongpublic Reader getDecodingReader(InputStream in) throws IOException
in - the underlying stream to decode fromIOException - if something goes wrongpublic Writer getEncodingWriter(OutputStream out) throws IOException
out - the underlying stream to encode toIOException - if something goes wrongpublic static Encoding defaultEncoding()
Copyright © 1997-2020 PostgreSQL Global Development Group. All Rights Reserved.