org.apache.james.smtpserver
Class SizeLimitedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.james.smtpserver.SizeLimitedInputStream
All Implemented Interfaces:
java.io.Closeable

public class SizeLimitedInputStream
extends java.io.InputStream

Wraps an underlying input stream, limiting the allowable size of incoming data. The size limit is configured in the conf file, and when the limit is reached, a MessageSizeException is thrown.


Constructor Summary
SizeLimitedInputStream(java.io.InputStream in, long maxmessagesize)
          Constructor for the stream.
 
Method Summary
 int read()
          Overrides the read method of InputStream to call the read() method of the wrapped input stream.
 int read(byte[] b, int off, int len)
          Overrides the read method of InputStream to call the read() method of the wrapped input stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeLimitedInputStream

public SizeLimitedInputStream(java.io.InputStream in,
                              long maxmessagesize)
Constructor for the stream. Wraps an underlying stream.

Parameters:
in - InputStream to use as basis for new Stream.
maxmessagesize - Message size limit, in Kilobytes
Method Detail

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides the read method of InputStream to call the read() method of the wrapped input stream.

Overrides:
read in class java.io.InputStream
Returns:
Returns the number of bytes read.
Throws:
java.io.IOException - Throws a MessageSizeException, which is a sub-type of IOException

read

public int read()
         throws java.io.IOException
Overrides the read method of InputStream to call the read() method of the wrapped input stream.

Specified by:
read in class java.io.InputStream
Returns:
Returns the int character value of the byte read.
Throws:
java.io.IOException - Throws a MessageSizeException, which is a sub-type of IOException.


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.