Class BOMEncodingDetector

  • All Implemented Interfaces:
    EncodingDetector

    public class BOMEncodingDetector
    extends SingleByteReceiver
    implements EncodingDetector
    This class represents the parse state of the BOM (byte order mark) parser. The byte order mark parser looks for a byte order mark at the start of a byte sequence, and based on whether it finds it or not, and what it finds, selects a preliminary character encoding. Once a preliminary character encoding is determined, an EncodingAccepter is notified, and further bytes are sent to a provided ByteReceiver.
    • Constructor Detail

      • BOMEncodingDetector

        public BOMEncodingDetector​(ByteReceiver overflowByteReceiver)
        Constructor.
        Parameters:
        overflowByteReceiver - Pass in the receiver of all overflow bytes. If no receiver is passed in, the detector will stop as soon as the BOM is either seen, or not seen.
    • Method Detail

      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Set initial encoding.
        Specified by:
        setEncoding in interface EncodingDetector
      • getEncoding

        public java.lang.String getEncoding()
        Retrieve final encoding determination.
        Specified by:
        getEncoding in interface EncodingDetector
      • establishEncoding

        protected boolean establishEncoding​(java.lang.String encoding)
                                     throws ManifoldCFException
        Establish the provided encoding, and send the rest to the child, if any.
        Throws:
        ManifoldCFException
      • mark

        protected void mark()
        Set a "mark".
      • dealWithRemainder

        protected boolean dealWithRemainder​(byte[] buffer,
                                            int offset,
                                            int len,
                                            java.io.InputStream inputStream)
                                     throws java.io.IOException,
                                            ManifoldCFException
        Deal with the remainder of the input. This is called only when dealWithByte() returns true.
        Overrides:
        dealWithRemainder in class SingleByteReceiver
        Parameters:
        buffer - is the buffer of characters that should come first.
        offset - is the offset within the buffer of the first character.
        len - is the number of characters in the buffer.
        inputStream - is the stream that should come after the characters in the buffer.
        Returns:
        true to abort, false if the end of the stream has been reached.
        Throws:
        java.io.IOException
        ManifoldCFException