Package org.apache.commons.io
Class ByteOrderMark
- java.lang.Object
-
- org.apache.commons.io.ByteOrderMark
-
- All Implemented Interfaces:
java.io.Serializable
public class ByteOrderMark extends java.lang.Object implements java.io.Serializable
Byte Order Mark (BOM) representation - seeBOMInputStream
.
-
-
Field Summary
Fields Modifier and Type Field Description static ByteOrderMark
UTF_16BE
UTF-16BE BOM (Big-Endian).static ByteOrderMark
UTF_16LE
UTF-16LE BOM (Little-Endian).static ByteOrderMark
UTF_32BE
UTF-32BE BOM (Big-Endian).static ByteOrderMark
UTF_32LE
UTF-32LE BOM (Little-Endian).static ByteOrderMark
UTF_8
UTF-8 BOM.static char
UTF_BOM
Unicode BOM character; external form depends on the encoding.
-
Constructor Summary
Constructors Constructor Description ByteOrderMark(java.lang.String charsetName, int... bytes)
Constructs a new BOM.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Indicates if this BOM's bytes equals another.int
get(int pos)
Gets the byte at the specified position.byte[]
getBytes()
Gets a copy of the BOM's bytes.java.lang.String
getCharsetName()
Gets the name of theCharset
the BOM represents.int
hashCode()
Computes the hashcode for this BOM.int
length()
Gets the length of the BOM's bytes.java.lang.String
toString()
Converts this instance to a String representation of the BOM.
-
-
-
Field Detail
-
UTF_8
public static final ByteOrderMark UTF_8
UTF-8 BOM.
-
UTF_16BE
public static final ByteOrderMark UTF_16BE
UTF-16BE BOM (Big-Endian).
-
UTF_16LE
public static final ByteOrderMark UTF_16LE
UTF-16LE BOM (Little-Endian).
-
UTF_32BE
public static final ByteOrderMark UTF_32BE
UTF-32BE BOM (Big-Endian).- Since:
- 2.2
-
UTF_32LE
public static final ByteOrderMark UTF_32LE
UTF-32LE BOM (Little-Endian).- Since:
- 2.2
-
UTF_BOM
public static final char UTF_BOM
Unicode BOM character; external form depends on the encoding.- Since:
- 2.5
- See Also:
- Byte Order Mark (BOM) FAQ, Constant Field Values
-
-
Constructor Detail
-
ByteOrderMark
public ByteOrderMark(java.lang.String charsetName, int... bytes)
Constructs a new BOM.- Parameters:
charsetName
- The name of the charset the BOM representsbytes
- The BOM's bytes- Throws:
java.lang.IllegalArgumentException
- if the charsetName is null or zero lengthjava.lang.IllegalArgumentException
- if the bytes are null or zero length
-
-
Method Detail
-
getCharsetName
public java.lang.String getCharsetName()
Gets the name of theCharset
the BOM represents.- Returns:
- the character set name
-
length
public int length()
Gets the length of the BOM's bytes.- Returns:
- the length of the BOM's bytes
-
get
public int get(int pos)
Gets the byte at the specified position.- Parameters:
pos
- The position- Returns:
- The specified byte
-
getBytes
public byte[] getBytes()
Gets a copy of the BOM's bytes.- Returns:
- a copy of the BOM's bytes
-
equals
public boolean equals(java.lang.Object obj)
Indicates if this BOM's bytes equals another.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to compare to- Returns:
- true if the bom's bytes are equal, otherwise false
-
hashCode
public int hashCode()
Computes the hashcode for this BOM.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashcode for this BOM.
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
Converts this instance to a String representation of the BOM.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the length of the BOM's bytes
-
-