Class BOM

java.lang.Object
de.muehlencord.shared.util.file.BOM

public class BOM extends Object
Defines possbile file Byte Order Marks used in files.
Author:
Joern Muehlencord (joern@muehlencord.de)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int[]
    BOCU-1 - version 1
    protected static final int[]
    BOCU-2 - version 2
    protected static final int[]
    GB-18030
    protected static final int[]
    SCSU
    protected static final int[]
    UTF-EBCDIC
    protected static final int[]
    UTF-1
    protected static final int[]
    UTF-16 - big endian
    protected static final int[]
    UTF-16 - little endian
    protected static final int[]
    UTF32(Big Endian)
    protected static final int[]
    UTF32(Little Endian)
    protected static final int[]
    UTF7 - version 1
    protected static final int[]
    UTF7 - version 2
    protected static final int[]
    UTF7 - version 3
    protected static final int[]
    UTF7 - version 4
    protected static final int[]
    UTF-8
  • Constructor Summary

    Constructors
    Constructor
    Description
    BOM(int[] keys)
    creates a new instance of a BOM by the given key array
    BOM(int k1, int k2)
    creates a new instance of a BOM
    BOM(int k1, int k2, int k3)
    creates a new instance of a BOM
    BOM(int k1, int k2, int k3, int k4)
    creates a new instance of a BOM
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    returns true, if the given object is a BOM and represents the same encoding as this object
    static String
    getEncoding(int[] bomBytes)
    returns the name of the encoding for the given bom bytes
    int
    returns the hashcode for this object

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BOM_UTF32_BE

      protected static final int[] BOM_UTF32_BE
      UTF32(Big Endian)
    • BOM_UTF32_LE

      protected static final int[] BOM_UTF32_LE
      UTF32(Little Endian)
    • BOM_UTF1

      protected static final int[] BOM_UTF1
      UTF-1
    • BOM_UTF7_1

      protected static final int[] BOM_UTF7_1
      UTF7 - version 1
    • BOM_UTF7_2

      protected static final int[] BOM_UTF7_2
      UTF7 - version 2
    • BOM_UTF7_3

      protected static final int[] BOM_UTF7_3
      UTF7 - version 3
    • BOM_UTF7_4

      protected static final int[] BOM_UTF7_4
      UTF7 - version 4
    • BOM_UTF_EBCDIC

      protected static final int[] BOM_UTF_EBCDIC
      UTF-EBCDIC
    • BOM_UTF8

      protected static final int[] BOM_UTF8
      UTF-8
    • BOM_SCSU

      protected static final int[] BOM_SCSU
      SCSU
    • BOM_BOCU1_1

      protected static final int[] BOM_BOCU1_1
      BOCU-1 - version 1
    • BOM_BOCU1_2

      protected static final int[] BOM_BOCU1_2
      BOCU-2 - version 2
    • BOM_UTF16_BE

      protected static final int[] BOM_UTF16_BE
      UTF-16 - big endian
    • BOM_UTF16_LE

      protected static final int[] BOM_UTF16_LE
      UTF-16 - little endian
    • BOM_GB_18030

      protected static final int[] BOM_GB_18030
      GB-18030
  • Constructor Details

    • BOM

      public BOM(int k1, int k2, int k3, int k4)
      creates a new instance of a BOM
      Parameters:
      k1 - the key1
      k2 - the key2
      k3 - the key3
      k4 - the key4
    • BOM

      public BOM(int k1, int k2, int k3)
      creates a new instance of a BOM
      Parameters:
      k1 - the key1
      k2 - the key2
      k3 - the key3
    • BOM

      public BOM(int k1, int k2)
      creates a new instance of a BOM
      Parameters:
      k1 - the key1
      k2 - the key2
    • BOM

      public BOM(int[] keys)
      creates a new instance of a BOM by the given key array
      Parameters:
      keys - the keys to use (minimum 2 key, maximum 4 keys are evaluated)
  • Method Details

    • equals

      public boolean equals(Object o)
      returns true, if the given object is a BOM and represents the same encoding as this object
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare to
    • hashCode

      public int hashCode()
      returns the hashcode for this object
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode for this object
    • getEncoding

      public static String getEncoding(int[] bomBytes) throws UnsupportedEncodingException
      returns the name of the encoding for the given bom bytes
      Parameters:
      bomBytes - the bytes representing the bom
      Returns:
      the name of the encoding for the given bom bytes
      Throws:
      UnsupportedEncodingException - if no valid encoding name can be found