public class Encoding
extends java.lang.Object
Modifier | Constructor | Description |
---|---|---|
protected |
Encoding(java.lang.String encoding) |
Use the charset passed as parameter.
|
Modifier and Type | Method | Description |
---|---|---|
java.lang.String |
decode(byte[] encodedString) |
Decode an array of bytes into a string.
|
java.lang.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(java.lang.String s) |
Encode a string to an array of bytes.
|
static Encoding |
getDatabaseEncoding(java.lang.String databaseEncoding) |
Construct an Encoding for a given database encoding.
|
java.io.Reader |
getDecodingReader(java.io.InputStream in) |
Get a Reader that decodes the given InputStream using this encoding.
|
java.io.Writer |
getEncodingWriter(java.io.OutputStream out) |
Get a Writer that encodes to the given OutputStream using this encoding.
|
static Encoding |
getJVMEncoding(java.lang.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.
|
java.lang.String |
name() |
Get the name of the (JVM) encoding used.
|
java.lang.String |
toString() |
protected Encoding(java.lang.String encoding)
encoding
- charset name to usepublic boolean hasAsciiNumbers()
public static Encoding getJVMEncoding(java.lang.String jvmEncoding)
jvmEncoding
- the name of the JVM encodingpublic static Encoding getDatabaseEncoding(java.lang.String databaseEncoding)
databaseEncoding
- the name of the database encodingpublic java.lang.String name()
public byte[] encode(java.lang.String s) throws java.io.IOException
s
- the string to encodejava.io.IOException
- if something goes wrongpublic java.lang.String decode(byte[] encodedString, int offset, int length) throws java.io.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 representationjava.io.IOException
- if something goes wrongpublic java.lang.String decode(byte[] encodedString) throws java.io.IOException
encodedString
- a byte array containing the string to decodejava.io.IOException
- if something goes wrongpublic java.io.Reader getDecodingReader(java.io.InputStream in) throws java.io.IOException
in
- the underlying stream to decode fromjava.io.IOException
- if something goes wrongpublic java.io.Writer getEncodingWriter(java.io.OutputStream out) throws java.io.IOException
out
- the underlying stream to encode tojava.io.IOException
- if something goes wrongpublic static Encoding defaultEncoding()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2019 PostgreSQL Global Development Group. All rights reserved.