Class ByteOrderMark

    • Constructor Summary

      Constructors 
      Constructor Description
      ByteOrderMark​(java.lang.String charsetName, int... bytes)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Indicates if this instance'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 the Charset the BOM represents.
      (package private) int[] getRawBytes()  
      int hashCode()
      Computes the hash code for this BOM.
      int length()
      Gets the length of the BOM's bytes.
      boolean matches​(int[] test)
      Tests whether the given array starts with the bytes for this BOM.
      java.lang.String toString()
      Converts this instance to a String representation of the BOM.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • UTF_8

        public static final ByteOrderMark UTF_8
        UTF-8 BOM.

        This BOM is:

         0xEF 0xBB 0xBF
         
      • UTF_16BE

        public static final ByteOrderMark UTF_16BE
        UTF-16BE BOM (Big-Endian).

        This BOM is:

         0xFE 0xFF
         
      • UTF_16LE

        public static final ByteOrderMark UTF_16LE
        UTF-16LE BOM (Little-Endian).

        This BOM is:

         0xFF 0xFE
         
      • UTF_32BE

        public static final ByteOrderMark UTF_32BE
        UTF-32BE BOM (Big-Endian).

        This BOM is:

         0x00 0x00 0xFE 0xFF
         
        Since:
        2.2
      • UTF_32LE

        public static final ByteOrderMark UTF_32LE
        UTF-32LE BOM (Little-Endian).

        This BOM is:

         0xFF 0xFE 0x00 0x00
         
        Since:
        2.2
      • charsetName

        private final java.lang.String charsetName
        Charset name.
      • bytes

        private final int[] bytes
        Bytes.
    • Constructor Detail

      • ByteOrderMark

        public ByteOrderMark​(java.lang.String charsetName,
                             int... bytes)
        Constructs a new instance.
        Parameters:
        charsetName - The name of the charset the BOM represents
        bytes - The BOM's bytes
        Throws:
        java.lang.IllegalArgumentException - if the charsetName is zero length
        java.lang.IllegalArgumentException - if the bytes are zero length
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Indicates if this instance's bytes equals another.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - The object to compare to
        Returns:
        true if the bom's bytes are equal, otherwise false
      • 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
      • getCharsetName

        public java.lang.String getCharsetName()
        Gets the name of the Charset the BOM represents.
        Returns:
        the character set name
      • getRawBytes

        int[] getRawBytes()
      • hashCode

        public int hashCode()
        Computes the hash code for this BOM.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code for this BOM.
        See Also:
        Object.hashCode()
      • length

        public int length()
        Gets the length of the BOM's bytes.
        Returns:
        the length of the BOM's bytes
      • matches

        public boolean matches​(int[] test)
        Tests whether the given array starts with the bytes for this BOM.
        Parameters:
        test - the array to test.
        Returns:
        whether the given array starts with the bytes for this BOM.
        Since:
        2.19.0
      • toString

        public java.lang.String toString()
        Converts this instance to a String representation of the BOM.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the length of the BOM's bytes