org.mailster.mina
Class TextLineConsumer

java.lang.Object
  extended by org.mailster.mina.TextLineConsumer
All Implemented Interfaces:
DataConsumer

public class TextLineConsumer
extends java.lang.Object
implements DataConsumer

---
Mailster (C) 2007-2009 De Oliveira Edouard

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See  Mailster Web Site
---

TextLineConsumer.java - This class consumes a IoBuffer extracting a \r\n terminated line and forwards decoded lines to a IoFilterCodec codec for further decoding.

Version:
$Revision: 1.6 $, $Date: 2009/01/30 01:32:30 $
Author:
Edouard De Oliveira

Field Summary
private  IoFilterCodec codec
           
private  org.apache.mina.core.buffer.IoBuffer delimBuf
           
private  int maxLineLength
           
private  int minLineLength
           
 
Constructor Summary
TextLineConsumer(java.nio.charset.Charset charset, IoFilterCodec codec)
          Creates a new instance with the specified charset the LineDelimiter.DEFAULT delimiter and the specified IoFilterCodec.
TextLineConsumer(java.nio.charset.Charset charset, org.apache.mina.filter.codec.textline.LineDelimiter delimiter, IoFilterCodec codec)
          Creates a new instance with the specified charset the specified delimiter and the specified IoFilterCodec.
TextLineConsumer(IoFilterCodec codec)
          Creates a new instance with the current default Charset, the LineDelimiter.DEFAULT delimiter and the specified IoFilterCodec.
 
Method Summary
 boolean consume(org.apache.mina.core.filterchain.IoFilter.NextFilter nextFilter, org.apache.mina.core.buffer.IoBuffer in)
          Consumes data and sends it to the IoFilterCodec#unwrap(NextFilter, IoBuffer) method.
 IoFilterCodec getCodec()
          Returns the associated codec.
 int getMaxLineLength()
          Returns the allowed maximum size of the line to be decoded.
 int getMinLineLength()
          Returns the allowed minimum size of the line to be decoded.
 void setMaxLineLength(int maxLineLength)
          Sets the allowed maximum size of the line to be decoded.
 void setMinLineLength(int minLineLength)
          Sets the allowed minimum size of the line to be decoded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delimBuf

private org.apache.mina.core.buffer.IoBuffer delimBuf

maxLineLength

private int maxLineLength

minLineLength

private int minLineLength

codec

private IoFilterCodec codec
Constructor Detail

TextLineConsumer

public TextLineConsumer(IoFilterCodec codec)
Creates a new instance with the current default Charset, the LineDelimiter.DEFAULT delimiter and the specified IoFilterCodec.


TextLineConsumer

public TextLineConsumer(java.nio.charset.Charset charset,
                        IoFilterCodec codec)
Creates a new instance with the specified charset the LineDelimiter.DEFAULT delimiter and the specified IoFilterCodec.


TextLineConsumer

public TextLineConsumer(java.nio.charset.Charset charset,
                        org.apache.mina.filter.codec.textline.LineDelimiter delimiter,
                        IoFilterCodec codec)
Creates a new instance with the specified charset the specified delimiter and the specified IoFilterCodec. Delimiter LineDelimiter.AUTO is not allowed.

Method Detail

getCodec

public IoFilterCodec getCodec()
Returns the associated codec.

Specified by:
getCodec in interface DataConsumer

getMinLineLength

public int getMinLineLength()
Returns the allowed minimum size of the line to be decoded. The default value is 0.


setMinLineLength

public void setMinLineLength(int minLineLength)
Sets the allowed minimum size of the line to be decoded. If the size of the line is smaller than this value, the #consume(NextFilter, IoBuffer) will return false immediately. The default value is 0.


getMaxLineLength

public int getMaxLineLength()
Returns the allowed maximum size of the line to be decoded. The default value is 1024 (1KB).


setMaxLineLength

public void setMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw a BufferDataException. The default value is 1024 (1KB).


consume

public boolean consume(org.apache.mina.core.filterchain.IoFilter.NextFilter nextFilter,
                       org.apache.mina.core.buffer.IoBuffer in)
                throws java.lang.Exception
Description copied from interface: DataConsumer
Consumes data and sends it to the IoFilterCodec#unwrap(NextFilter, IoBuffer) method.

Specified by:
consume in interface DataConsumer
Throws:
java.lang.Exception