|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pfsw.text.CheckedCharsetName
public class CheckedCharsetName
This is a helper class that represents a character encoding name that has already been checked if it is supported by the platform.
It helps to avoid the annoying try-catch code-pollution every time you use a valid encoding, but the API requires the handling of UnsupportedEncodingException even if it cannot occur at all.
| Field Summary | |
|---|---|
static CheckedCharsetName |
DEFAULT
The platform default file encoding. |
static CheckedCharsetName |
ISO_8859_1
The pre-defined constant for Java standard charset ISO-8859-1. |
static CheckedCharsetName |
US_ASCII
The pre-defined constant for Java standard charset US-ASCII. |
static CheckedCharsetName |
UTF_16
The pre-defined constant for Java standard charset UTF-16. |
static CheckedCharsetName |
UTF_16BE
The pre-defined constant for Java standard charset UTF-16BE. |
static CheckedCharsetName |
UTF_16LE
The pre-defined constant for Java standard charset UTF-16LE. |
static CheckedCharsetName |
UTF_8
The pre-defined constant for Java standard charset UTF-8. |
| Constructor Summary | |
|---|---|
CheckedCharsetName(java.lang.String encodingName)
Initialize the new instance with an encoding name (e.g. |
|
| Method Summary | |
|---|---|
static void |
checkEncoding(java.lang.String charsetName)
Checks whether or not the given encoding is supported. |
static CheckedCharsetName |
create(java.lang.String encodingName)
Creates a new instance based on the given encoding name. |
boolean |
equals(java.lang.Object obj)
|
byte[] |
getBytes(java.lang.String string)
Returns the bytes of the given string as array encoded to the charset this instance represents, avoiding the unnecessary exception handling (UnsupportedEncodingException). |
java.nio.charset.Charset |
getCharset()
Returns the corresponding charset object. |
java.lang.String |
getName()
Returns the pure upper case encoding name (e.g. |
int |
hashCode()
|
java.lang.String |
newString(byte[] bytes)
Returns a new String initialized with the given bytes which are expected to be encoded according to the character set this instance represents, avoiding the unnecessary exception handling (UnsupportedEncodingException). |
java.lang.String |
toString()
Returns the pure upper case encoding name (e.g. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final CheckedCharsetName US_ASCII
public static final CheckedCharsetName ISO_8859_1
public static final CheckedCharsetName UTF_8
public static final CheckedCharsetName UTF_16
public static final CheckedCharsetName UTF_16BE
public static final CheckedCharsetName UTF_16LE
public static final CheckedCharsetName DEFAULT
| Constructor Detail |
|---|
public CheckedCharsetName(java.lang.String encodingName)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException| Method Detail |
|---|
public static void checkEncoding(java.lang.String charsetName)
throws java.io.UnsupportedEncodingException
charsetName - The name of the encoding to check (e.g. "UTF-16")
java.io.UnsupportedEncodingException - Will be thrown if the encoding is not supported.
public static CheckedCharsetName create(java.lang.String encodingName)
throws java.io.UnsupportedEncodingException
encodingName - The name of the encoding to check (e.g. "UTF-16")
java.io.UnsupportedEncodingException - Will be thrown if the encoding is not supported.public java.lang.String getName()
getName in interface org.pfsw.bif.text.ICheckedCharsetpublic java.nio.charset.Charset getCharset()
getCharset in interface org.pfsw.bif.text.ICheckedCharsetpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String newString(byte[] bytes)
It is the same like: new String(bytes, checkedCharsetName.toString());
newString in interface org.pfsw.bif.text.ICheckedCharsetbytes - The byte to create a string from.
public byte[] getBytes(java.lang.String string)
getBytes in interface org.pfsw.bif.text.ICheckedCharsetstring - The string to be converted to a byte array using this instance's charset.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||