Package org.rypt.f8

Interface Utf8ByteHandler<X extends Exception>

  • All Known Subinterfaces:
    Utf8Handler<X>
    All Known Implementing Classes:
    Utf8Statistics, Utf8StringBuilder

    public interface Utf8ByteHandler<X extends Exception>
    Base interface for handling a UTF-8 encoded byte stream
    Author:
    Hans Brende (hansbrende@apache.org)
    • Method Detail

      • handle1ByteCodePoint

        void handle1ByteCodePoint​(int b1)
                           throws X extends Exception
        Called when a valid 1-byte sequence is encountered.
        Parameters:
        b1 - the valid ASCII character encountered, in the range 0-0x7F
        Throws:
        X extends Exception
      • handle2ByteCodePoint

        void handle2ByteCodePoint​(int b1,
                                  int b2)
                           throws X extends Exception
        Called when a valid 2-byte sequence is encountered.
        Parameters:
        b1 - the prefix byte, in the range (byte)0xC2-(byte)0xDF
        b2 - the continuation byte, in the range (byte)0x80-(byte)0xBF
        Throws:
        X extends Exception
        See Also:
        Utf8.codePoint(int, int)
      • handle3ByteCodePoint

        void handle3ByteCodePoint​(int b1,
                                  int b2,
                                  int b3)
                           throws X extends Exception
        Called when a valid 3-byte sequence is encountered.
        Parameters:
        b1 - the prefix byte, in the range (byte)0xE0-(byte)0xEF
        b2 - the first continuation byte, in the range (byte)0x80-(byte)0xBF, unless the prefix byte is (byte)0xED or (byte)0xE0, in which case the range is (byte)0x80-(byte)0x9F or (byte)0xA0-(byte)0xBF, respectively
        b3 - the second continuation byte, in the range (byte)0x80-(byte)0xBF
        Throws:
        X extends Exception
        See Also:
        Utf8.codePoint(int, int, int)
      • handle4ByteCodePoint

        void handle4ByteCodePoint​(int b1,
                                  int b2,
                                  int b3,
                                  int b4)
                           throws X extends Exception
        Called when a valid 4-byte sequence is encountered.
        Parameters:
        b1 - the prefix byte, in the range (byte)0xF0-(byte)0xF4
        b2 - the first continuation byte, in the range (byte)0x80-(byte)0xBF, unless the prefix byte is (byte)0xF4 or (byte)0xF0, in which case the range is (byte)0x80-(byte)0x8F or (byte)0x90-(byte)0x9F, respectively
        b3 - the second continuation byte, in the range (byte)0x80-(byte)0xBF
        b4 - the third continuation byte, in the range (byte)0x80-(byte)0xBF
        Throws:
        X extends Exception
        See Also:
        Utf8.codePoint(int, int, int, int)
      • handlePrefixError

        void handlePrefixError​(int err)
                        throws X extends Exception
        Called when an invalid prefix byte is encountered.
        Parameters:
        err - the invalid prefix byte, in the range (byte)0x80-(byte)0xC1 or (byte)0xF5-(byte)0xFF
        Throws:
        X extends Exception
      • handleContinuationError

        void handleContinuationError​(int b1,
                                     int err)
                              throws X extends Exception
        Called when an invalid continuation byte is encountered in a 2, 3, or 4-byte sequence.
        Parameters:
        b1 - the prefix byte
        err - the invalid first continuation byte, or END_OF_STREAM to indicate the end of the byte stream
        Throws:
        X extends Exception
      • handleContinuationError

        void handleContinuationError​(int b1,
                                     int b2,
                                     int err)
                              throws X extends Exception
        Called when an invalid continuation byte is encountered in a 3 or 4-byte sequence.
        Parameters:
        b1 - the prefix byte
        b2 - the first continuation byte
        err - the invalid second continuation byte, or END_OF_STREAM to indicate the end of the byte stream
        Throws:
        X extends Exception
      • handleContinuationError

        void handleContinuationError​(int b1,
                                     int b2,
                                     int b3,
                                     int err)
                              throws X extends Exception
        Called when an invalid continuation byte is encountered in a 4-byte sequence.
        Parameters:
        b1 - the prefix byte
        b2 - the first continuation byte
        b3 - the second continuation byte
        err - the invalid third continuation byte, or END_OF_STREAM to indicate the end of the byte stream
        Throws:
        X extends Exception
      • handleIgnoredByte

        default void handleIgnoredByte​(int b)
                                throws X extends Exception
        Called for a trailing byte in an invalid multi-byte sequence for which the error has already been handled, and thus, no action needs to be taken. This method is called for the second and third bytes in a 3-byte sequence corresponding to a surrogate code point.
        Parameters:
        b - the ignored byte
        Throws:
        X extends Exception
        See Also:
        Character.isSurrogate(char)