Package org.rypt.f8
Class Utf8StringBuilder
- java.lang.Object
-
- java.io.OutputStream
-
- org.rypt.f8.Utf8Statistics
-
- org.rypt.f8.Utf8StringBuilder
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,CharSequence,Utf8ByteHandler<RuntimeException>,Utf8Handler<RuntimeException>
public class Utf8StringBuilder extends Utf8Statistics implements CharSequence
An implementation ofUtf8Handlerthat records byte statistics and decodes a UTF-8 encoded byte stream into a string.- Author:
- Hans Brende (hansbrende@apache.org)
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuildersb-
Fields inherited from interface org.rypt.f8.Utf8ByteHandler
END_OF_STREAM
-
-
Constructor Summary
Constructors Constructor Description Utf8StringBuilder()Utf8StringBuilder(StringBuilder sb)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)voidhandle1ByteCodePoint(int ascii)Called when a valid 1-byte sequence is encountered.voidhandle2ByteCodePoint(int b1, int b2)Called when a valid 2-byte sequence is encountered.voidhandle3ByteCodePoint(int b1, int b2, int b3)Called when a valid 3-byte sequence is encountered.voidhandle4ByteCodePoint(int b1, int b2, int b3, int b4)Called when a valid 4-byte sequence is encountered.voidhandleCodePoint(int codePoint)Called when a valid unicode code point is encounteredvoidhandleError()Called when an invalid UTF-8 byte sequence is detectedintlength()voidreset()CharSequencesubSequence(int start, int end)StringtoString()-
Methods inherited from class org.rypt.f8.Utf8Statistics
close, count2Byte, count3Byte, count4Byte, countAscii, countCodePoints, countInvalid, countInvalidIgnoringTruncation, countValid, handleContinuationError, handleContinuationError, handleContinuationError, looksLikeUtf8, write, write, write
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Methods inherited from interface org.rypt.f8.Utf8ByteHandler
handleIgnoredByte
-
Methods inherited from interface org.rypt.f8.Utf8Handler
handlePrefixError
-
-
-
-
Field Detail
-
sb
protected final StringBuilder sb
-
-
Constructor Detail
-
Utf8StringBuilder
public Utf8StringBuilder(StringBuilder sb)
-
Utf8StringBuilder
public Utf8StringBuilder()
-
-
Method Detail
-
handleCodePoint
public void handleCodePoint(int codePoint)
Description copied from interface:Utf8HandlerCalled when a valid unicode code point is encountered- Specified by:
handleCodePointin interfaceUtf8Handler<RuntimeException>- Overrides:
handleCodePointin classUtf8Statistics- Parameters:
codePoint- the code point that was encountered
-
reset
public void reset()
- Overrides:
resetin classUtf8Statistics
-
handleError
public void handleError()
Description copied from interface:Utf8HandlerCalled when an invalid UTF-8 byte sequence is detected- Specified by:
handleErrorin interfaceUtf8Handler<RuntimeException>- Overrides:
handleErrorin classUtf8Statistics
-
handle1ByteCodePoint
public void handle1ByteCodePoint(int ascii)
Description copied from interface:Utf8ByteHandlerCalled when a valid 1-byte sequence is encountered.- Specified by:
handle1ByteCodePointin interfaceUtf8ByteHandler<RuntimeException>- Specified by:
handle1ByteCodePointin interfaceUtf8Handler<RuntimeException>- Overrides:
handle1ByteCodePointin classUtf8Statistics- Parameters:
ascii- the valid ASCII character encountered, in the range 0-0x7F
-
handle2ByteCodePoint
public void handle2ByteCodePoint(int b1, int b2)Description copied from interface:Utf8ByteHandlerCalled when a valid 2-byte sequence is encountered.- Specified by:
handle2ByteCodePointin interfaceUtf8ByteHandler<RuntimeException>- Specified by:
handle2ByteCodePointin interfaceUtf8Handler<RuntimeException>- Overrides:
handle2ByteCodePointin classUtf8Statistics- Parameters:
b1- the prefix byte, in the range (byte)0xC2-(byte)0xDFb2- the continuation byte, in the range (byte)0x80-(byte)0xBF- See Also:
Utf8.codePoint(int, int)
-
handle3ByteCodePoint
public void handle3ByteCodePoint(int b1, int b2, int b3)Description copied from interface:Utf8ByteHandlerCalled when a valid 3-byte sequence is encountered.- Specified by:
handle3ByteCodePointin interfaceUtf8ByteHandler<RuntimeException>- Specified by:
handle3ByteCodePointin interfaceUtf8Handler<RuntimeException>- Overrides:
handle3ByteCodePointin classUtf8Statistics- Parameters:
b1- the prefix byte, in the range (byte)0xE0-(byte)0xEFb2- 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, respectivelyb3- the second continuation byte, in the range (byte)0x80-(byte)0xBF- See Also:
Utf8.codePoint(int, int, int)
-
handle4ByteCodePoint
public void handle4ByteCodePoint(int b1, int b2, int b3, int b4)Description copied from interface:Utf8ByteHandlerCalled when a valid 4-byte sequence is encountered.- Specified by:
handle4ByteCodePointin interfaceUtf8ByteHandler<RuntimeException>- Specified by:
handle4ByteCodePointin interfaceUtf8Handler<RuntimeException>- Overrides:
handle4ByteCodePointin classUtf8Statistics- Parameters:
b1- the prefix byte, in the range (byte)0xF0-(byte)0xF4b2- 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, respectivelyb3- the second continuation byte, in the range (byte)0x80-(byte)0xBFb4- the third continuation byte, in the range (byte)0x80-(byte)0xBF- See Also:
Utf8.codePoint(int, int, int, int)
-
length
public int length()
- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
subSequence
public CharSequence subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classUtf8Statistics
-
-