org.eclipse.net4j.buffer
Enum BufferState

java.lang.Object
  extended by java.lang.Enum<BufferState>
      extended by org.eclipse.net4j.buffer.BufferState
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<BufferState>

public enum BufferState
extends java.lang.Enum<BufferState>

Enumerates the internal states of an IBuffer.

State Machine Diagram:


Enum Constant Summary
GETTING
          Indicates that the IBuffer can provide a ByteBuffer that can be used for getting data.
INITIAL
          Indicates that the IBuffer has just been provided by its IBufferProvider or that is has been used and subsequently cleared.
PUTTING
          Indicates that the IBuffer can provide a ByteBuffer that can be used for putting data.
READING_BODY
          Indicates that the IBuffer is currently reading its body from a SocketChannel.
READING_HEADER
          Indicates that the IBuffer is currently reading its header from a SocketChannel.
WRITING
          Indicates that the IBuffer is currently writing its data to a SocketChannel.
 
Method Summary
static BufferState valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static BufferState[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

INITIAL

public static final BufferState INITIAL
Indicates that the IBuffer has just been provided by its IBufferProvider or that is has been used and subsequently cleared.

A transition to PUTTING can be triggered by calling IBuffer.startPutting(short) once. If the buffer is intended to be passed to an IChannel later the channel index of that Channel has to be passed because it is part of the buffer's header. A ByteBuffer is returned that can be used for putting data.

A transition to GETTING can be triggered by calling IBuffer.startGetting(SocketChannel) repeatedly until it finally returns a ByteBuffer that can be used for getting data.


PUTTING

public static final BufferState PUTTING
Indicates that the IBuffer can provide a ByteBuffer that can be used for putting data.

A transition to WRITING can be triggered by calling IBuffer.write(SocketChannel).

A transition to GETTING can be triggered by calling IBuffer.flip().

A transition to INITIAL can be triggered by calling IBuffer.clear().


WRITING

public static final BufferState WRITING
Indicates that the IBuffer is currently writing its data to a SocketChannel.

Self transitions to WRITING can be triggered by repeatedly calling IBuffer.write(SocketChannel) until it returns true.

A transition to INITIAL can be triggered by calling IBuffer.clear().


READING_HEADER

public static final BufferState READING_HEADER
Indicates that the IBuffer is currently reading its header from a SocketChannel.

Transitions to READING_HEADER, READING_BODY or GETTING can be triggered by repeatedly calling IBuffer.startGetting(SocketChannel) until it returns a ByteBuffer that can be used for getting data.

A transition to INITIAL can be triggered by calling IBuffer.clear().


READING_BODY

public static final BufferState READING_BODY
Indicates that the IBuffer is currently reading its body from a SocketChannel.

Transitions to READING_BODY or GETTING can be triggered by repeatedly calling IBuffer.startGetting(SocketChannel) until it returns a ByteBuffer that can be used for getting data.

A transition to INITIAL can be triggered by calling IBuffer.clear().


GETTING

public static final BufferState GETTING
Indicates that the IBuffer can provide a ByteBuffer that can be used for getting data.

A transition to INITIAL can be triggered by calling IBuffer.clear().

Method Detail

values

public static final BufferState[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(BufferState c : BufferState.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static BufferState valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

Copyright (c) 2004 - 2008 Eike Stepper, Germany.
All Rights Reserved.