Package chemaxon.marvin.io
Class Encoding
java.lang.Object
chemaxon.marvin.io.Encoding
- All Implemented Interfaces:
Externalizable,Serializable
File encoding information.
- Since:
- Marvin 5.0, 11/10/2007
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcanonicalName(String enc) Standardize a Java encoding.convert(byte[] buf, int offset, int numbytes) Converts a byte array to a string.booleanTests whether two encodings are equal.booleanTests whether two encodings are equal.static EncodingCreates an Encoding for the specified name, withendianness.invalid reference
#UNKNOWNinthashCode()name()Gets the name of the encoding.order()Gets the endianness.static Encodingread(ObjectInput in) Reads an externalized encoding object.voidRestores object state.static Encodingrecognize(byte[] buf, int off, int len) Tries to recognize the encoding of a byte array.static EncodingrecognizeByBOM(byte[] buf, int off, int len) Tries to recognize the encoding of a byte array by the byte order mark.toString()Converts the encoding object to string.intGets the word length in bytes.voidSaves object state.
-
Field Details
-
DEFAULT
The system's default encoding.
-
-
Constructor Details
-
Encoding
Creates an Encoding for the specified name, word length and byte order.- Parameters:
name- the encoding namewordLength- the word lengthorder- the byte order
-
-
Method Details
-
forName
Creates an Encoding for the specified name, withendianness.invalid reference
#UNKNOWN- Parameters:
name- the encoding name ornull- Returns:
- the encoding or
null - Throws:
IllegalCharsetNameException- if the encoding is illegalUnsupportedCharsetException- if the encoding is unsupported
-
recognize
Tries to recognize the encoding of a byte array.- Parameters:
buf- the byte arrayoff- array offsetlen- length- Returns:
- the encoding of
nullif not recognized - Since:
- Marvin 5.1.3, 10/20/2008
-
recognizeByBOM
Tries to recognize the encoding of a byte array by the byte order mark.- Parameters:
buf- the byte arrayoff- array offsetlen- length- Returns:
- the encoding of
nullif not recognized - Since:
- Marvin 5.1.3, 10/18/2008
-
name
Gets the name of the encoding.- Returns:
- the name
-
wordLength
public int wordLength()Gets the word length in bytes.- Returns:
- the word length
-
order
Gets the endianness.- Returns:
- the byte order
-
convert
Converts a byte array to a string.- Parameters:
buf- the byte arrayoffset- offset in the arraynumbytes- number of bytes to convert- Throws:
UnsupportedEncodingException- Since:
- Marvin 5.1.3, 10/18/2008
-
toString
Converts the encoding object to string. -
equals
Tests whether two encodings are equal.- Returns:
trueif the name, the word length and the byte order are the same
-
hashCode
public int hashCode() -
equals
Tests whether two encodings are equal. -
canonicalName
Standardize a Java encoding.- Parameters:
enc- the encoding name ornull- Returns:
- the standard encoding name or
null - Throws:
IllegalCharsetNameException- if the encoding is illegalUnsupportedCharsetException- if the encoding is unsupported
-
writeExternal
Saves object state.- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- the stream to write the object to- Throws:
IOException- Includes any I/O exceptions that may occur
-
readExternal
Restores object state. For internal use only!- Specified by:
readExternalin interfaceExternalizable- Parameters:
in- the stream to read data from in order to restore the object- Throws:
IOException- if I/O errors occur
-
read
Reads an externalized encoding object.- Parameters:
in- the stream to read data from in order to restore the object- Returns:
- the encoding object
- Throws:
IOException- if I/O errors occur
-