public class BOMEncodingDetector extends SingleByteReceiver implements EncodingDetector
Modifier and Type | Field and Description |
---|---|
protected static int |
BOM_NOTHINGYET |
protected static int |
BOM_SEEN_0000 |
protected static int |
BOM_SEEN_0000FE |
protected static int |
BOM_SEEN_EF |
protected static int |
BOM_SEEN_EFBB |
protected static int |
BOM_SEEN_FE |
protected static int |
BOM_SEEN_FF |
protected static int |
BOM_SEEN_FFFE |
protected static int |
BOM_SEEN_FFFE00 |
protected static int |
BOM_SEEN_ZERO |
protected int |
currentState |
protected java.lang.String |
encoding |
protected ByteReceiver |
overflowByteReceiver |
protected ByteBuffer |
replayBuffer |
byteBuffer
Constructor and Description |
---|
BOMEncodingDetector(ByteReceiver overflowByteReceiver)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dealWithByte(byte b)
Receive a byte.
|
protected boolean |
dealWithRemainder(byte[] buffer,
int offset,
int len,
java.io.InputStream inputStream)
Deal with the remainder of the input.
|
protected boolean |
establishEncoding(java.lang.String encoding)
Establish the provided encoding, and send the rest to the child, if any.
|
java.lang.String |
getEncoding()
Retrieve final encoding determination.
|
protected void |
mark()
Set a "mark".
|
protected boolean |
playFromCurrentPoint()
Send stream from current point onward with the current encoding.
|
protected boolean |
replay()
Establish NO encoding, and replay from the current saved point to the child, if any.
|
void |
setEncoding(java.lang.String encoding)
Set initial encoding.
|
dealWithBytes
finishUp
protected java.lang.String encoding
protected final ByteReceiver overflowByteReceiver
protected ByteBuffer replayBuffer
protected static final int BOM_NOTHINGYET
protected static final int BOM_SEEN_EF
protected static final int BOM_SEEN_FF
protected static final int BOM_SEEN_FE
protected static final int BOM_SEEN_ZERO
protected static final int BOM_SEEN_EFBB
protected static final int BOM_SEEN_FFFE
protected static final int BOM_SEEN_0000
protected static final int BOM_SEEN_FFFE00
protected static final int BOM_SEEN_0000FE
protected int currentState
public BOMEncodingDetector(ByteReceiver overflowByteReceiver)
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.public void setEncoding(java.lang.String encoding)
setEncoding
in interface EncodingDetector
public java.lang.String getEncoding()
getEncoding
in interface EncodingDetector
public boolean dealWithByte(byte b) throws ManifoldCFException
dealWithByte
in class SingleByteReceiver
ManifoldCFException
protected boolean establishEncoding(java.lang.String encoding) throws ManifoldCFException
ManifoldCFException
protected void mark()
protected boolean replay() throws ManifoldCFException
ManifoldCFException
protected boolean playFromCurrentPoint() throws ManifoldCFException
ManifoldCFException
protected boolean dealWithRemainder(byte[] buffer, int offset, int len, java.io.InputStream inputStream) throws java.io.IOException, ManifoldCFException
dealWithRemainder
in class SingleByteReceiver
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.java.io.IOException
ManifoldCFException