Class XMLEncodingDetector.RewindableInputStream
java.lang.Object
java.io.InputStream
org.apache.jasper.xmlparser.XMLEncodingDetector.RewindableInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
- Enclosing class:
XMLEncodingDetector
This class wraps the byte inputstreams we're presented with.
We need it because java.io.InputStreams don't provide
functionality to reread processed bytes, and they have a habit
of reading more than one character when you call their read()
methods. This means that, once we discover the true (declared)
encoding of a document, we can neither backtrack to read the
whole doc again nor start reading where we are with a new
reader.
This class allows rewinding an inputStream by allowing a mark
to be set, and the stream reset to that position. The
class assumes that it needs to read one character per
invocation when it's read() method is inovked, but uses the
underlying InputStream's read(char[], offset length) method--it
won't buffer data read this way!
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private intprivate InputStreamprivate intprivate intprivate intprivate int -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
fInputStream
-
fData
private byte[] fData -
fStartOffset
private int fStartOffset -
fEndOffset
private int fEndOffset -
fOffset
private int fOffset -
fLength
private int fLength -
fMark
private int fMark
-
-
Constructor Details
-
RewindableInputStream
-
-
Method Details
-
setStartOffset
public void setStartOffset(int offset) -
rewind
public void rewind() -
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
mark
public void mark(int howMuch) - Overrides:
markin classInputStream
-
reset
public void reset()- Overrides:
resetin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-