public class Encoding extends Object
Modifier | Constructor and Description |
---|---|
protected |
Encoding(String encoding)
Use the charset passed as parameter.
|
Modifier and Type | Method and Description |
---|---|
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.
|
static Encoding |
defaultEncoding()
Get an Encoding using the default encoding for the JVM.
|
byte[] |
encode(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()
Returns a string representation of the object.
|
protected Encoding(String encoding)
encoding
- charset name 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 String name()
public byte[] encode(String s) throws IOException
s
- the string to encodeIOException
- 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()
public String toString()
java.lang.Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Copyright © 2018 PostgreSQL Global Development Group. All rights reserved.