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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
canonicalName
(String enc) Standardize a Java encoding.convert
(byte[] buf, int offset, int numbytes) Converts a byte array to a string.boolean
Tests whether two encodings are equal.boolean
Tests whether two encodings are equal.static Encoding
Creates an Encoding for the specified name, with#UNKNOWN
endianness.int
hashCode()
name()
Gets the name of the encoding.order()
Gets the endianness.static Encoding
read
(ObjectInput in) Reads an externalized encoding object.void
Restores object state.static Encoding
recognize
(byte[] buf, int off, int len) Tries to recognize the encoding of a byte array.static Encoding
recognizeByBOM
(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.int
Gets the word length in bytes.void
Saves 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, with#UNKNOWN
endianness.- 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
null
if 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
null
if 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:
true
if 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:
writeExternal
in 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:
readExternal
in 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
-