Package org.apache.james.mime4j.io
Class LineReaderInputStreamAdaptor
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.james.mime4j.io.LineReaderInputStream
-
- org.apache.james.mime4j.io.LineReaderInputStreamAdaptor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class LineReaderInputStreamAdaptor extends LineReaderInputStream
InputStreamused by the MIME parser to detect whether the underlying data stream was used (read from) and whether the end of the stream was reached.
-
-
Field Summary
Fields Modifier and Type Field Description private LineReaderInputStreambisprivate booleaneofprivate intmaxLineLenprivate booleanused
-
Constructor Summary
Constructors Constructor Description LineReaderInputStreamAdaptor(java.io.InputStream is)LineReaderInputStreamAdaptor(java.io.InputStream is, int maxLineLen)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intdoReadLine(ByteArrayBuffer dst)booleaneof()booleanisUsed()intread()intread(byte[] b, int off, int len)intreadLine(ByteArrayBuffer dst)Reads one line of text into the givenByteArrayBuffer.longskip(long count)java.lang.StringtoString()booleanunread(ByteArrayBuffer buf)Tries to unread the last read line.booleanunread(RecycledByteArrayBuffer buf)
-
-
-
Field Detail
-
bis
private final LineReaderInputStream bis
-
maxLineLen
private final int maxLineLen
-
used
private boolean used
-
eof
private boolean eof
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
readLine
public int readLine(ByteArrayBuffer dst) throws MaxLineLimitException, java.io.IOException
Description copied from class:LineReaderInputStreamReads one line of text into the givenByteArrayBuffer.- Specified by:
readLinein classLineReaderInputStream- Parameters:
dst- Destination- Returns:
- number of bytes copied or
-1if the end of the stream has been reached. - Throws:
MaxLineLimitException- if the line exceeds a limit on the line length imposed by a subclass.java.io.IOException- in case of an I/O error.
-
doReadLine
private int doReadLine(ByteArrayBuffer dst) throws MaxLineLimitException, java.io.IOException
- Throws:
MaxLineLimitExceptionjava.io.IOException
-
eof
public boolean eof()
-
isUsed
public boolean isUsed()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
unread
public boolean unread(ByteArrayBuffer buf)
Description copied from class:LineReaderInputStreamTries to unread the last read line. Implementation may refuse to unread a new buffer until the previous unread one has been competely consumed. Implementations will directly use the byte array backed by buf, so make sure to not alter it anymore once this method has been called.- Specified by:
unreadin classLineReaderInputStream- Returns:
- true if the unread has been succesfull.
-
unread
public boolean unread(RecycledByteArrayBuffer buf)
- Specified by:
unreadin classLineReaderInputStream
-
skip
public long skip(long count) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
-