SilverStream
Application Server 3.5

com.sssw.srv.mail
Class AgoBufferingInputStream

java.lang.Object
 |
 +--java.io.InputStream
       |
       +--com.sssw.srv.mail.AgoBufferingInputStream

public class AgoBufferingInputStream
extends InputStream

Provides an input stream suited to streaming MIME messages. In addition to methods to peek at bytes without removing them from the stream, this class implements a notion of boundaries that can partition the stream by MIME content boundaries. When a boundary is hit while reading, the stream appears to be at the end. This is typically used to read from an AgoByteStore.


Constructor Summary
AgoBufferingInputStream()
           
 
Method Summary
 void clearBoundary()
          Clears the last boundary set using the setBoundary() method.
 void clearMark()
          Clears the last set mark position.
 int peek()
          Peeks at the next byte in the character or byte store witout advancing the offset.
 int peek(int nth)
          Returns the nth next byte from the current offset in the character store, byte store, or input stream without consuming it.
 void setBoundary(byte[] boundary)
          Sets a new boundary.
 void setMark()
          Sets a mark position.
 void unwindToMark()
          Restores the input stream to the last mark set.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgoBufferingInputStream

public AgoBufferingInputStream()
Method Detail

setBoundary

public void setBoundary(byte[] boundary)
Sets a new boundary.
Parameters:
boundary - specifies the boundary to set.
Usage:

The stream ends when the boundary is encountered in the underlying stream. This allows a stream to be used in parsing MIME messages. The boundary can be cleared using the clearBoundary() method.

Example:
     bis.setBoundary(someByte);
 
See Also:
AgoBufferingInputStream.clearBoundary(), AgoBufferingInputStream.clearMark(), AgoBufferingInputStream.setMark()

clearBoundary

public void clearBoundary()
Clears the last boundary set using the setBoundary() method.
Example:
     bis.clearBoundary();
 
See Also:
AgoBufferingInputStream.setBoundary( byte[] boundary )

peek

public int peek()
         throws IOException
Peeks at the next byte in the character or byte store witout advancing the offset.
Usage:

The read() method can then be used to read the byte. This is shorthand for peek(); The peek() method does not move the offset, the read() method does.

Example:
     int i = bis.peek();
 
See Also:
AgoBufferingInputStream.peek( int nth ), InputStream.read()

peek

public int peek(int nth)
         throws IOException
Returns the nth next byte from the current offset in the character store, byte store, or input stream without consuming it.
Parameters:
nth - specifies the byte to peek at. It is zero-based, 0 is the next byte.
Usage:

The nth parameter is zero-based. If the value of nth is 0, the next byte is returned. If the value of nth is 1, the second byte is returned, etc. The read() method can then be used to read the byte. The peek() method does not move the offset, the read() method does.

Example:
     int i = bis.peek(1);
 
See Also:
AgoBufferingInputStream.peek(), InputStream.read()

setMark

public void setMark()
Sets a mark position.
Usage:

Once a mark is set, all read operations can be undone until the clearMark() method is called. If needed, the unwindToMark() method can be called to restore the stream to the position is was at when the setMark() method was last called.

Example:
     bis.setMark();
 
See Also:
AgoBufferingInputStream.clearMark(), AgoBufferingInputStream.unwindToMark()

clearMark

public void clearMark()
Clears the last set mark position.
Usage:

Once a mark is set, all read operations can be undone until the clearMark() method is called. If needed, the unwindToMark() method can be called to "unwind" (restore) the stream to the position is was at when the the setMark() method was last called.

Example:
     bis.clearMark();
 
See Also:
AgoBufferingInputStream.setMark(), AgoBufferingInputStream.unwindToMark()

unwindToMark

public void unwindToMark()
Restores the input stream to the last mark set.
Usage:

Once a mark is set, all read operations can be undone until the clearMark() method is called. If needed, the unwindToMark() method can be called to restore the stream to the position is was at when the setMark() method was last called.

Example:
     bis.unwindToMark();
 
See Also:
AgoBufferingInputStream.clearMark(), AgoBufferingInputStream.setMark()

SilverStream
Application Server 3.5