things.data.processing.http
Class HttpHeaderProcessor

java.lang.Object
  extended by java.io.InputStream
      extended by things.data.processing.rfc822.HeaderProcessorv3
          extended by things.data.processing.http.HttpHeaderProcessor
All Implemented Interfaces:
java.io.Closeable

public class HttpHeaderProcessor
extends HeaderProcessorv3

Processes headers for HTTP. This implementation assumes 8-bit characters throughout the header.

Version:
1.0

Version History

EPG - Initial - 12 FEB 07
 
Author:
Erich P. Gatejen

Field Summary
static int HEADER_CONTENT_LENGTH
           
static java.lang.String HEADER_CONTENT_LENGTH_STRING
           
static int HEADER_CONTENT_TYPE
           
static java.lang.String HEADER_CONTENT_TYPE_STRING
           
static int HEADER_TRANSFER_ENCODING
           
static java.lang.String HEADER_TRANSFER_ENCODING_STRING
           
 
Fields inherited from class things.data.processing.rfc822.HeaderProcessorv3
headerBuffer, headerBufferLength, headerLineBroken, MAX_HEADER_NAME_SIZE
 
Constructor Summary
HttpHeaderProcessor()
           
 
Method Summary
protected  java.util.List<java.lang.String> complete()
          Complete on a specific header.
protected  void declarations()
          All declarations should be put here, so they are done with any initialization.
protected  void headersComplete()
          The headers are done.
protected  void match(int id)
          This method will be called when a header is matched.
 void processHeader(java.io.InputStream input, HttpHeaders headers)
          Process the header.
protected  void start(java.lang.String messageId)
          Start on a specific header.
protected  void unmatch(byte[] headerBuffer, int size)
          This method will be called when a header is unmatched.
 
Methods inherited from class things.data.processing.rfc822.HeaderProcessorv3
available, clearPause, close, declare, deplete, init, isDone, isLineBroken, isPaused, markSupported, process, read, writeOriginalHeaderNameWithColon
 
Methods inherited from class java.io.InputStream
mark, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_CONTENT_TYPE

public static final int HEADER_CONTENT_TYPE
See Also:
Constant Field Values

HEADER_CONTENT_TYPE_STRING

public static final java.lang.String HEADER_CONTENT_TYPE_STRING
See Also:
Constant Field Values

HEADER_CONTENT_LENGTH

public static final int HEADER_CONTENT_LENGTH
See Also:
Constant Field Values

HEADER_CONTENT_LENGTH_STRING

public static final java.lang.String HEADER_CONTENT_LENGTH_STRING
See Also:
Constant Field Values

HEADER_TRANSFER_ENCODING

public static final int HEADER_TRANSFER_ENCODING
See Also:
Constant Field Values

HEADER_TRANSFER_ENCODING_STRING

public static final java.lang.String HEADER_TRANSFER_ENCODING_STRING
See Also:
Constant Field Values
Constructor Detail

HttpHeaderProcessor

public HttpHeaderProcessor()
                    throws java.lang.Throwable
Throws:
java.lang.Throwable
Method Detail

processHeader

public void processHeader(java.io.InputStream input,
                          HttpHeaders headers)
                   throws java.lang.Throwable
Process the header. This is a one way trip. This implementation does NOT write anything.

Parameters:
input - the source input.
headers - the headers. all header data will be written into it.
Throws:
java.lang.Throwable

declarations

protected void declarations()
                     throws java.lang.Throwable
All declarations should be put here, so they are done with any initialization.

Specified by:
declarations in class HeaderProcessorv3
Throws:
java.lang.Throwable

start

protected void start(java.lang.String messageId)
              throws java.lang.Throwable
Start on a specific header. This gives the implementation a chance to initialize.

Specified by:
start in class HeaderProcessorv3
Parameters:
messageId - the id for the message being processed. The implementation may choose to ignore it.
Throws:
java.lang.Throwable

unmatch

protected void unmatch(byte[] headerBuffer,
                       int size)
                throws java.lang.Throwable
This method will be called when a header is unmatched. Be sure to write to outs if you want anything preserved! This includes the CRLF. The read() method will supply the read of the header line.

Specified by:
unmatch in class HeaderProcessorv3
Parameters:
headerBuffer - What we read about the header already.
size - how much is actually in the buffer.
Throws:
java.lang.Throwable

match

protected void match(int id)
              throws java.lang.Throwable
This method will be called when a header is matched. This will be called when a header is matched for a read-only operation.

Specified by:
match in class HeaderProcessorv3
Parameters:
id - The defined id.
Throws:
java.lang.Throwable

complete

protected java.util.List<java.lang.String> complete()
                                             throws java.lang.Throwable
Complete on a specific header. This gives the implementation a chance to return entries. If anything is returned at all is up to the implementation. It can give a null if it wants to.

Specified by:
complete in class HeaderProcessorv3
Returns:
A list of header fields.
Throws:
java.lang.Throwable

headersComplete

protected void headersComplete()
                        throws java.lang.Throwable
The headers are done. All that is left is the final CR and LFs, whatever they may be. This is a good time to add your own headers.

Throws:
java.lang.Throwable


Things.