Class ByteOrderMark

    • Field Detail

      • 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
    • Constructor Detail

      • ByteOrderMark

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

      • getCharsetName

        public String getCharsetName()
        Gets the name of the Charset 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​(Object obj)
        Indicates if this BOM's bytes equals another.
        Overrides:
        equals in class 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 class Object
        Returns:
        the hashcode for this BOM.
        See Also:
        Object.hashCode()
      • toString

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