org.apache.mina.codec.textline

## Class TextLineEncoder

- java.lang.Object
- - org.apache.mina.codec.textline.TextLineEncoder

All Implemented Interfaces:
  ProtocolEncoder<String,ByteBuffer,Void>, StatelessProtocolEncoder<String,ByteBuffer>

    public class TextLineEncoder
    extends Object
    implements StatelessProtocolEncoder<String,ByteBuffer>

A `ProtocolEncoder` which encodes a string into a text line which ends with the delimiter.

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`TextLineEncoder()` Creates a new instance with the current default `Charset` and `LineDelimiter.UNIX` delimiter.
`TextLineEncoder(Charset charset)` Creates a new instance with the spcified `charset` and `LineDelimiter.UNIX` delimiter.
`TextLineEncoder(Charset charset, LineDelimiter delimiter)` Creates a new instance with the spcified `charset` and the specified `delimiter`.
`TextLineEncoder(Charset charset, String delimiter)` Creates a new instance with the spcified `charset` and the specified `delimiter`.
`TextLineEncoder(LineDelimiter delimiter)` Creates a new instance with the current default `Charset` and the specified `delimiter`.
`TextLineEncoder(String delimiter)` Creates a new instance with the current default `Charset` and the specified `delimiter`.

### Method Summary

Methods
`Void` `createEncoderState()` Create a new session context for this decoder
`ByteBuffer` `encode(String message, Void context)` Encodes higher-level message objects of type `INPUT` into binary or protocol-specific data of type `OUTPUT`.
`int` `getMaxLineLength()` Returns the allowed maximum size of the encoded line.
`void` `setMaxLineLength(int maxLineLength)` Sets the allowed maximum size of the encoded line.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TextLineEncoder

    public TextLineEncoder()

Creates a new instance with the current default `Charset` and `LineDelimiter.UNIX` delimiter.

#### TextLineEncoder

    public TextLineEncoder(String delimiter)

Creates a new instance with the current default `Charset` and the specified `delimiter`.

#### TextLineEncoder

    public TextLineEncoder(LineDelimiter delimiter)

Creates a new instance with the current default `Charset` and the specified `delimiter`.

#### TextLineEncoder

    public TextLineEncoder(Charset charset)

Creates a new instance with the spcified `charset` and `LineDelimiter.UNIX` delimiter.

#### TextLineEncoder

    public TextLineEncoder(Charset charset,
                   String delimiter)

Creates a new instance with the spcified `charset` and the specified `delimiter`.

#### TextLineEncoder

    public TextLineEncoder(Charset charset,
                   LineDelimiter delimiter)

Creates a new instance with the spcified `charset` and the specified `delimiter`.

### Method Detail

#### getMaxLineLength

    public int getMaxLineLength()

Returns the allowed maximum size of the encoded line. If the size of the encoded line exceeds this value, the encoder will throw a `IllegalArgumentException`. The default value is `Integer.MAX_VALUE`.

#### setMaxLineLength

    public void setMaxLineLength(int maxLineLength)

Sets the allowed maximum size of the encoded line. If the size of the encoded line exceeds this value, the encoder will throw a `IllegalArgumentException`. The default value is `Integer.MAX_VALUE`.

#### createEncoderState

    public Void createEncoderState()

Description copied from interface: `ProtocolEncoder`
Create a new session context for this decoder

Specified by:
  `createEncoderState` in interface `ProtocolEncoder<String,ByteBuffer,Void>`
Returns:
  the newly created context

#### encode

    public ByteBuffer encode(String message,
                    Void context)

Description copied from interface: `ProtocolEncoder`
Encodes higher-level message objects of type `INPUT` into binary or protocol-specific data of type `OUTPUT`.

Specified by:
  `encode` in interface `ProtocolEncoder<String,ByteBuffer,Void>`
Parameters:
  `message` - the message to encode
  `context` - the encoding context (will be stored in the session for the next decode call)