simple.http
Class Pipeline

java.lang.Object
  extended by simple.http.Pipeline
All Implemented Interfaces:
Attributes
Direct Known Subclasses:
FilterPipeline

public class Pipeline
extends java.lang.Object
implements Attributes

This is a Pipeline object that is used to represent a HTTP Pipeline. This contains methods that allow attributes to be associated with a Pipeline. It is implements the Attributes interface which allows objects to be stored with the Pipeline.

This implements a close that allows the Pipeline to be closed. This ensures that both objects are closed i.e. both the InputStream and the OutputStream will be closed after the close method is invoked.

Author:
Niall Gallagher

Field Summary
protected  java.net.Socket sock
          This is the socket that provides the input and output.
protected  java.util.Hashtable table
          This is used to store properties for this connection.
 
Constructor Summary
protected Pipeline()
          This constructor allows the Pipeline to be extended in such a way that it does not involve ant initialization of the Pipeline itself.
  Pipeline(java.net.Socket sock)
          This creates a Pipeline from a Socket object.
 
Method Summary
 void close()
          This is a close method that ensures the communication link is shutdown.
 boolean contains(java.lang.String name)
          This can be used to determine if an attribute of a given name is present int the attribute object.
 java.lang.Object get(java.lang.String name)
          This will retrieve an attribute from this attributes class.
 java.net.InetAddress getInetAddress()
          This corresponds to the identity of the host that created the connection.
 java.io.InputStream getInputStream()
          Retrieves the InputStream.
 java.io.OutputStream getOutputStream()
          Retrieves the OutputStream.
 java.util.Set keySet()
          This will provide an Set object for attribute names for this pipeline object.
 void put(java.lang.String name, java.lang.Object obj)
          This can be used to set an attribute.
 void remove(java.lang.String name)
          This removes the attribute from this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected java.util.Hashtable table
This is used to store properties for this connection.


sock

protected java.net.Socket sock
This is the socket that provides the input and output.

Constructor Detail

Pipeline

protected Pipeline()
This constructor allows the Pipeline to be extended in such a way that it does not involve ant initialization of the Pipeline itself. This is used if there is no need for a Socket or Hashtable reference. This is used by FilterPipeline.


Pipeline

public Pipeline(java.net.Socket sock)
         throws java.io.IOException
This creates a Pipeline from a Socket object. Any sub classes of the Pipeline object may use this constructor to ensure that all the data is initialized for the Pipeline.

Parameters:
sock - the Socket that contains the streams
Throws:
java.io.IOException - if the object could not be created
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Retrieves the InputStream. This is a communication channel between the client and the server. The stream returned is the same as the Socket.getInputStream.

Returns:
an InputStream from the client, i.e. the Pipeline
Throws:
java.io.IOException - thrown if there is an I/O problem.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Retrieves the OutputStream. This is a communication channel from the server to the client. The stream returned is the same as the Socket.getOuputStream.

Returns:
an OutputStream to the client, i.e. the Pipeline
Throws:
java.io.IOException - thrown if there is an I/O problem

getInetAddress

public java.net.InetAddress getInetAddress()
This corresponds to the identity of the host that created the connection. The domain name can be retrieved from this.

Returns:
the identity of the peer that created connection

get

public java.lang.Object get(java.lang.String name)
This will retrieve an attribute from this attributes class. The attributes in an attributes object are identified by a String name. If the attribute specified by name does not exist then this returns null, otherwise the correct object.

Specified by:
get in interface Attributes
Parameters:
name - the name of the attribute to be retrieved
Returns:
the attribute that is referenced by the name

contains

public boolean contains(java.lang.String name)
This can be used to determine if an attribute of a given name is present int the attribute object. If there is concurrent access to this object then then this may not be accurate when the attribute method is invoked, for this reason the return value for get should always be checked to see if its null.

Specified by:
contains in interface Attributes
Parameters:
name - the name of the attribute the is being queried
Returns:
true if the attribute exists, false if it does not

remove

public void remove(java.lang.String name)
This removes the attribute from this object. This may cause any Set of the names returned to become stale.

Specified by:
remove in interface Attributes
Parameters:
name - the name of the attribute to be removed

put

public void put(java.lang.String name,
                java.lang.Object obj)
This can be used to set an attribute. The attribute will contain the name specified. This may not update any existing Set of the attribute names that was retrieved.

Specified by:
put in interface Attributes
Parameters:
name - the name of the attribute that is being added
obj - the value of the attribute that is being added

keySet

public java.util.Set keySet()
This will provide an Set object for attribute names for this pipeline object. This may not update if there are concurrent remove and set operations when this is used.

Specified by:
keySet in interface Attributes
Returns:
a set of the names of attributes for this pipline

close

public void close()
This is a close method that ensures the communication link is shutdown. Closes the InputStream and the OutputStream of the Socket. This method will not propagate any exceptions.