org.fossilec.odettej.service
Class OdetteExchangeBuffer

java.lang.Object
  extended by org.fossilec.odettej.service.OdetteExchangeBuffer
Direct Known Subclasses:
CommandExchangeBuffer, DataExchangeBuffer

public abstract class OdetteExchangeBuffer
extends java.lang.Object

The communication between Odette FTP entities is basically done by sending and receiving messages in Exchange Buffers via the transport layer. An Odette Exchange Buffer can have either a Command or Data buffer.

Author:
Rafael Marins

Field Summary
protected  java.nio.ByteBuffer buffer
          The content of this Exchange Buffer.
protected static java.lang.String BUFFER_CHARSET
           
static int MAX_OEB_LENGTH
          Maximum Exchange Buffer length allowed by protocol specification.
static int MIN_OEB_LENGTH
          Minimum Exchange Buffer length allowed by protocol specification.
 
Constructor Summary
protected OdetteExchangeBuffer()
           
 
Method Summary
 java.nio.ByteBuffer getBuffer()
          Return the Exchange Buffer rewinded.
 CommandIdentifier getIdentifier()
          Return the corresponding CommandIdentifier relative to the Exchange Buffer contents.
static OdetteExchangeBuffer getInstance(java.nio.ByteBuffer rawBuffer, boolean strictFormat)
          Create and return a new OdetteExchangeBuffer instance corresponding to a Command Exchange Buffer or Data Exchange Buffer, regarding the identifier at first octet of the exchange buffer data.
 int getLength()
          Get the Odette Exchange Buffer length.
protected abstract  void parse(java.nio.ByteBuffer rawBuffer)
           
protected  void setBuffer(java.nio.ByteBuffer buffer)
           
protected  void setIdentifier(CommandIdentifier identifier)
           
protected  void setLength(int length)
          Set the Odette Exchange Buffer length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_OEB_LENGTH

public static final int MIN_OEB_LENGTH
Minimum Exchange Buffer length allowed by protocol specification.

See Also:
Constant Field Values

MAX_OEB_LENGTH

public static final int MAX_OEB_LENGTH
Maximum Exchange Buffer length allowed by protocol specification.

See Also:
Constant Field Values

BUFFER_CHARSET

protected static final java.lang.String BUFFER_CHARSET
See Also:
Constant Field Values

buffer

protected java.nio.ByteBuffer buffer
The content of this Exchange Buffer. Its buffer capacity are allocated before being initialized with some content.

Constructor Detail

OdetteExchangeBuffer

protected OdetteExchangeBuffer()
Method Detail

getIdentifier

public CommandIdentifier getIdentifier()
                                throws OdetteFTPException
Return the corresponding CommandIdentifier relative to the Exchange Buffer contents. Its value is parsed from the first octet of the Exchange Buffer specified through class constructor.

The CommandIdentifier defines the format of the Exchange Buffer contents.

Returns:
CommandIdentifier Instance relative to the command type of this Exchange Buffer.
Throws:
CommandNotRecognisedException - Command identifier not recognised in the specified buffer.
java.nio.charset.IllegalCharsetNameException - Error while decoding byte buffer with a invalid charset.
OdetteFTPException
See Also:
CommandIdentifier

setIdentifier

protected void setIdentifier(CommandIdentifier identifier)

getBuffer

public java.nio.ByteBuffer getBuffer()
Return the Exchange Buffer rewinded.

Returns:
ByteBuffer

setBuffer

protected void setBuffer(java.nio.ByteBuffer buffer)

parse

protected abstract void parse(java.nio.ByteBuffer rawBuffer)
                       throws OdetteFTPException
Parameters:
rawBuffer -
bufferLength -
Throws:
java.lang.IllegalArgumentException - If the buffer is null.
OdetteFTPException
BufferCorruptedException - When a invalid buffer length is specified or with a wrong position.

getLength

public int getLength()
Get the Odette Exchange Buffer length.

Returns:
The Odette Exchange Buffer length.

setLength

protected void setLength(int length)
Set the Odette Exchange Buffer length.

Parameters:
length - The length of Odette Exchange Buffer.

getInstance

public static OdetteExchangeBuffer getInstance(java.nio.ByteBuffer rawBuffer,
                                               boolean strictFormat)
                                        throws OdetteFTPException
Create and return a new OdetteExchangeBuffer instance corresponding to a Command Exchange Buffer or Data Exchange Buffer, regarding the identifier at first octet of the exchange buffer data.

Parameters:
rawBuffer - The overall Exchange Buffer.
bufferLength - Length of the remaining buffer to be read.
Returns:
ExchangeBuffer Concrete instance representing a Command Exchange Buffer or Data Exchange Buffer.
Throws:
OdetteFTPException
CommandNotRecognisedException - Command identifier not recognised.
BufferCorruptedException - When a invalid buffer length is specified or the buffer is badly positioned.
See Also:
CommandExchangeBuffer, DataExchangeBuffer


Copyright © 2005 ObjectWeb Consortium. All Rights Reserved.