public enum EByteOrderMark extends java.lang.Enum<EByteOrderMark>
The order of the values in this enum is chosen such that BOMs that are a prefix of other BOMs are at the end, i.e. UTF-32 is before UTF-16. This way we can check the BOM prefix in the order of the enum values' appearance.
Enum Constant and Description |
---|
UTF_16BE
UTF-16 with big endian encoding.
|
UTF_16LE
UTF-16 with little endian encoding.
|
UTF_32BE
UTF-32 with big endian encoding.
|
UTF_32LE
UTF-32 with little endian encoding.
|
UTF_8_BOM
UTF-8.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_BOM_LENGTH
The maximal length of a BOM.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Optional<EByteOrderMark> |
determineBOM(byte[] data)
This method checks the start of the provided data array to find a BOM.
|
byte[] |
getBOM()
Returns the byte order mark.
|
int |
getBOMLength()
Returns the size of the BOM in bytes.
|
java.nio.charset.Charset |
getEncoding() |
static java.util.Optional<EByteOrderMark> |
skipBOM(java.io.InputStream data)
This method determines which BOM, if any, the given stream starts with and
skips it.
|
static EByteOrderMark |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static EByteOrderMark[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final EByteOrderMark UTF_32BE
public static final EByteOrderMark UTF_32LE
public static final EByteOrderMark UTF_16BE
public static final EByteOrderMark UTF_16LE
public static final EByteOrderMark UTF_8_BOM
public static final int MAX_BOM_LENGTH
public static EByteOrderMark[] values()
for (EByteOrderMark c : EByteOrderMark.values()) System.out.println(c);
public static EByteOrderMark valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic java.nio.charset.Charset getEncoding()
encoding
public byte[] getBOM()
public int getBOMLength()
public static java.util.Optional<EByteOrderMark> determineBOM(byte[] data)
public static java.util.Optional<EByteOrderMark> skipBOM(java.io.InputStream data) throws java.io.IOException
InputStream
must offer
mark support.java.io.IOException