Package org.ec4j.core
Enum Resource.Bom
- All Implemented Interfaces:
Serializable,Comparable<Resource.Bom>,java.lang.constant.Constable
- Enclosing interface:
Resource
An enum of Byte Order Marks (BOMs) to be able to support encodings with BOM unsupported by
Charset.forName(String).- Since:
- 0.0.4
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getName()static Resource.BomReturns aResource.Bomhaving the givenname.static StringIf the givencharsetis aResource.Bom.BomCharset, skips the BOM sequence in the givenbytesarray and returns a new String built out the remaining part ofbytes; otherwise returns a new String built out thebytes.static InputStreamskipBom(InputStream inputStream, Charset charset) If the givencharsetis aResource.Bom.BomCharset, skips the BOM sequence in the giveninputStreamand returns the giveninputStream; otherwise just returns the giveninputStream.static Resource.BomReturns the enum constant of this type with the specified name.static Resource.Bom[]values()Returns an array containing the constants of this enum type, in the order they are declared.static OutputStreamwriteBom(OutputStream outpuStream, Charset charset) If the givencharsetis aResource.Bom.BomCharset, writes the BOM sequence into the givenoutpuStreamand returns the givenoutpuStream; otherwise just returns the givenoutpuStream.
-
Enum Constant Details
-
UTF_8_BOM
utf-8-bom- Since:
- 0.0.4
-
-
Field Details
-
bomBytes
private final byte[] bomBytes -
charset
-
name
-
-
Constructor Details
-
Bom
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
ofName
Returns aResource.Bomhaving the givenname.- Parameters:
name- name of the encoding- Returns:
- a
Resource.Bomornullif the name is unknown - Since:
- 0.0.4
-
skipBom
If the givencharsetis aResource.Bom.BomCharset, skips the BOM sequence in the givenbytesarray and returns a new String built out the remaining part ofbytes; otherwise returns a new String built out thebytes.- Parameters:
bytes- the byte array to processcharset- the encoding of thebytes- Returns:
- a new
String - Since:
- 0.0.4
-
skipBom
If the givencharsetis aResource.Bom.BomCharset, skips the BOM sequence in the giveninputStreamand returns the giveninputStream; otherwise just returns the giveninputStream.- Parameters:
inputStream-InputStreamto processcharset- the encoding of thein- Returns:
in- Throws:
IOException- if there are i/o issues- Since:
- 0.0.4
-
writeBom
If the givencharsetis aResource.Bom.BomCharset, writes the BOM sequence into the givenoutpuStreamand returns the givenoutpuStream; otherwise just returns the givenoutpuStream.- Parameters:
outpuStream- theOutputStreamto write tocharset- theCharsetof the givenoutputStream- Returns:
outpuStream- Throws:
IOException- if there are i/o issues- Since:
- 0.0.4
-
bomBytesHumanReadable
- Returns:
- a comma and space separated HEX formatted BOM bytes
- Since:
- 0.0.4
-
getBomBytes
public byte[] getBomBytes()- Returns:
- a copy of
bomBytes - Since:
- 0.0.4
-
getCharset
- Returns:
- the
Resource.Bom.BomCharsetassociated with thisResource.Bom - Since:
- 0.0.4
-
getName
- Returns:
- the name of the encoding
- Since:
- 0.0.4
-