|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
things.data.processing.rfc822.HeaderProcessorv3
public abstract class HeaderProcessorv3
Processes headers. Read only. Based on v1
Your specific processor will extend this class. The declarations() method will register supported headers with calls to declare(); A call to process() will process a specific message, which will in turn call the other abstract methods for matches (or not-matched). The object can be reused all you want--so keep it around and process() over and over again.
EXAMPLE LEX MATCHING ENGINE
Inputs beb bea be 0 1 2 3 4 5 a 0 0 4 0 0 0 b 1 0 3 0 0 0 c 0 0 0 0 0 0 d 0 0 0 0 0 0 e 0 2 0 0 0 0 f 0 0 0 0 0 0 : 0 0 -3 -1 -2 0 Terms -1 beb -2 bea -3 be -4
Version History
EPG - Initial (part of toolkit) - 22 NOV 02 EPG - Modified for this project - 14 FEB 05 EPG - Forked into a second implementation - 25 MAR 05
Field Summary | |
---|---|
protected byte[] |
headerBuffer
|
protected int |
headerBufferLength
|
protected boolean |
headerLineBroken
|
static int |
MAX_HEADER_NAME_SIZE
|
Constructor Summary | |
---|---|
HeaderProcessorv3()
|
Method Summary | |
---|---|
int |
available()
Make sure we always report out available, even if it is just the remaining tee character. |
void |
clearPause()
Clear a pause (if any) and allow it to move to the next line. |
void |
close()
Do not let a user close this stream. |
protected abstract java.util.List<java.lang.String> |
complete()
Complete on a specific header. |
protected abstract void |
declarations()
All declarations should be put here, so they are done with any initialization. |
void |
declare(java.lang.String headerName,
int id,
boolean caseSensitive)
Declare a header. |
void |
deplete()
Deplete current header line. |
void |
init()
Reinitialize the processor. |
boolean |
isDone()
Is the stream done? Is there anything left in the header? |
boolean |
isLineBroken()
Is the line broken? |
boolean |
isPaused()
Is the stream paused? Meaning that the current line has been depleted. |
boolean |
markSupported()
We do not support mark. |
protected abstract void |
match(int id)
This method will be called when a header is matched. |
java.util.List<java.lang.String> |
process(java.lang.String messageId,
java.io.InputStream input)
Process the headers. |
int |
read()
Implement the read method which will be used by header data processors. |
protected abstract void |
start(java.lang.String messageId)
Start on a specific header. |
protected abstract void |
unmatch(byte[] headerBuffer,
int size)
This method will be called when a header is unmatched. |
void |
writeOriginalHeaderNameWithColon(java.io.OutputStream os)
Write the original header name with a colon into the given output stream. |
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 |
---|
public static final int MAX_HEADER_NAME_SIZE
protected boolean headerLineBroken
protected byte[] headerBuffer
protected int headerBufferLength
Constructor Detail |
---|
public HeaderProcessorv3() throws java.lang.Throwable
java.lang.Throwable
Method Detail |
---|
protected abstract void declarations() throws java.lang.Throwable
java.lang.Throwable
protected abstract void start(java.lang.String messageId) throws java.lang.Throwable
messageId
- the id for the message being processed. The implementation may choose to ignore it.
java.lang.Throwable
protected abstract void match(int id) throws java.lang.Throwable
id
- The defined id.
java.lang.Throwable
protected abstract void unmatch(byte[] headerBuffer, int size) throws java.lang.Throwable
headerBuffer
- What we read about the header already.
java.lang.Throwable
protected abstract java.util.List<java.lang.String> complete() throws java.lang.Throwable
java.lang.Throwable
public void declare(java.lang.String headerName, int id, boolean caseSensitive) throws java.lang.Throwable
headerName
- The header name.id
- The header id. This can be a duplicate. Cannot be =< 0.caseSensitive
- if true, the header name will be case sensitive.
java.lang.Throwable
public java.util.List<java.lang.String> process(java.lang.String messageId, java.io.InputStream input) throws java.lang.Throwable
messageId
- The id for the message or document. This may be echoed into the entries, depending on the specific implementation.input
- The input stream.
java.lang.Throwable
public void init() throws java.lang.Throwable
java.lang.Throwable
public void writeOriginalHeaderNameWithColon(java.io.OutputStream os) throws java.lang.Throwable
os
- the stream.
java.lang.Throwable
public void deplete() throws java.lang.Throwable
java.lang.Throwable
public boolean isLineBroken()
public boolean isPaused()
public void clearPause()
public boolean isDone()
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.InputStream
public void close()
close
in interface java.io.Closeable
close
in class java.io.InputStream
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |