org.norther.tammi.acorn.http
Class HttpParser.ParsedState

java.lang.Object
  extended by org.norther.tammi.acorn.http.HttpParser.ParsedState
Enclosing class:
HttpParser

public static final class HttpParser.ParsedState
extends Object

A state holder for the parser.


Constructor Summary
HttpParser.ParsedState()
          Constructs a new parsed state.
HttpParser.ParsedState(int start)
          Constructs a new parsed state with a start.
HttpParser.ParsedState(int start, int bend)
          Constructs a new parsed state with a start and a buffer end.
 
Method Summary
 void addSeparator(char sep)
          Adds an alternate separator.
 void clear()
          Clears the state.
 void clear(int start)
          Clears the state with a start.
 void clear(int start, int bend)
          Clears the state with a start and a buffer end.
 boolean hasNext()
          Checks whether non-parsed items still exists.
 int length()
          Returns the length of the buffer to be parsed.
 void nested(HttpParser.ParsedState ps)
          Starts a nested parsed state.
 void next()
          Starts to parse the next item.
 int nextItem(char[] raw)
          Parses a list of items, taking care of quotes and optional WS.
 void setQuotable(boolean flag)
          Sets whether quated items are parsed separately.
 void setSeparator(char sep)
          Sets the separator.
 void setSkipable(boolean flag)
          Sets whether leading and trailing spaces are skipped.
 String toString(char[] raw)
          Converts the parsed state into a string.
 String toString(char[] raw, boolean item)
          Converts the parsed item into a string.
 String toString(char[] raw, boolean item, boolean lower)
          Converts the parsed item into a upper/lower case string.
 boolean unquote(char[] raw)
          Removes quota.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpParser.ParsedState

public HttpParser.ParsedState()
Constructs a new parsed state.


HttpParser.ParsedState

public HttpParser.ParsedState(int start)
Constructs a new parsed state with a start.

Parameters:
start - a start offset

HttpParser.ParsedState

public HttpParser.ParsedState(int start,
                              int bend)
Constructs a new parsed state with a start and a buffer end.

Parameters:
start - a start offset.
bend - a buffer end.
Method Detail

setSeparator

public final void setSeparator(char sep)
Sets the separator.

Parameters:
sep - the separator.

addSeparator

public final void addSeparator(char sep)
Adds an alternate separator.

Note that the current implementation supports only one additional separator.

Parameters:
sep - the separator.

setQuotable

public final void setQuotable(boolean flag)
Sets whether quated items are parsed separately.

Parameters:
flag - true if quotable, otherwise false.

setSkipable

public final void setSkipable(boolean flag)
Sets whether leading and trailing spaces are skipped.

Parameters:
flag - true if skipped, otherwise false.

hasNext

public final boolean hasNext()
Checks whether non-parsed items still exists.

Returns:
true for non-parsed items, false otherwise.

length

public final int length()
Returns the length of the buffer to be parsed.

Returns:
the lenght of the buffer or -1 if not available.

clear

public final void clear()
Clears the state.


clear

public final void clear(int start)
Clears the state with a start.

Parameters:
start - the new start.

clear

public final void clear(int start,
                        int bend)
Clears the state with a start and a buffer end.

Parameters:
start - the new start.
bend - the new end.

next

public final void next()
Starts to parse the next item.


nested

public final void nested(HttpParser.ParsedState ps)
Starts a nested parsed state.

Parameters:
ps - the upper level state

unquote

public final boolean unquote(char[] raw)
Removes quota.

Parameters:
raw - the buffer.
Returns:
true, if something was removed.

nextItem

public final int nextItem(char[] raw)
Parses a list of items, taking care of quotes and optional WS.

Parameters:
raw - the buffer.
Returns:
the starting location or -1.

toString

public final String toString(char[] raw)
Converts the parsed state into a string.

Parameters:
raw - the buffer.
Returns:
the string.

toString

public final String toString(char[] raw,
                             boolean item)
Converts the parsed item into a string.

Parameters:
raw - the buffer.
item - the item flag.
Returns:
the string.

toString

public final String toString(char[] raw,
                             boolean item,
                             boolean lower)
Converts the parsed item into a upper/lower case string.

Parameters:
raw - the buffer.
item - the item flag.
lower - the case setting.
Returns:
the string.


Copyright © 2004 The Norther Organization. All rights reserved.