edu.berkeley.psi.sed.generic
Class genericPacketReader

java.lang.Object
  extended by edu.berkeley.psi.sed.generic.genericPacketReader

 class genericPacketReader
extends java.lang.Object

This is a package-internal class which reads generic request packets. An instance of this class is fed ATcpInPackets (via the parsePacket method). When a complete packet has been read, a genericRequest is pushed to the corresponding SinkIF. This is the bulk of the generic protocol implementation.


Field Summary
private  aSocketInputStream ais
           
private  SinkIF compQ
           
private  genericConnection conn
           
private static boolean DEBUG
           
private  int genericVer
           
private  java.util.Vector header
           
private  java.lang.String request
           
private  int state
           
private static int STATE_DONE
           
private static int STATE_HEADER
           
private static int STATE_START
           
private  java.io.StreamTokenizer tok
           
private  java.lang.String url
           
 
Constructor Summary
genericPacketReader(genericConnection conn, SinkIF compQ)
          Create an genericPacketReader with the given genericConnection and completion queue.
 
Method Summary
private  int accumulateHeader()
          Accumulate header lines.
private  java.lang.String nextLine()
          Read the next line from the packet.
private  java.lang.String nextWord()
          Read the next whitespace-delimited word from the packet.
(package private)  boolean parsePacket(ATcpInPacket pkt)
          Parse the given packet; returns true if a complete generic request has been received and parsed.
private  int parseURL()
          Parse the first line of the request header.
private  void processHeader()
          Process the header, possibly pushing an genericRequest to the user.
private  void reset()
          Reset the internal state of the packet reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

STATE_START

private static final int STATE_START
See Also:
Constant Field Values

STATE_HEADER

private static final int STATE_HEADER
See Also:
Constant Field Values

STATE_DONE

private static final int STATE_DONE
See Also:
Constant Field Values

state

private int state

ais

private aSocketInputStream ais

tok

private java.io.StreamTokenizer tok

request

private java.lang.String request

url

private java.lang.String url

genericVer

private int genericVer

header

private java.util.Vector header

conn

private genericConnection conn

compQ

private SinkIF compQ
Constructor Detail

genericPacketReader

genericPacketReader(genericConnection conn,
                    SinkIF compQ)
Create an genericPacketReader with the given genericConnection and completion queue.

Method Detail

parsePacket

boolean parsePacket(ATcpInPacket pkt)
              throws java.io.IOException
Parse the given packet; returns true if a complete generic request has been received and parsed.

Throws:
java.io.IOException

reset

private void reset()
Reset the internal state of the packet reader.


parseURL

private int parseURL()
              throws java.io.IOException
Parse the first line of the request header.

Throws:
java.io.IOException

accumulateHeader

private int accumulateHeader()
                      throws java.io.IOException
Accumulate header lines.

Throws:
java.io.IOException

processHeader

private void processHeader()
                    throws java.io.IOException
Process the header, possibly pushing an genericRequest to the user.

Throws:
java.io.IOException

nextWord

private java.lang.String nextWord()
                           throws java.io.IOException
Read the next whitespace-delimited word from the packet.

Throws:
java.io.IOException

nextLine

private java.lang.String nextLine()
                           throws java.io.IOException
Read the next line from the packet.

Throws:
java.io.IOException