    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.www.http.HttpParser

    java.lang.Object
       |
       +----org.w3c.www.http.HttpParser

public class HttpParser
extends Object

A private class to help with the parsing. Contains only some static method, helping to parse various byte buffers into Java object (Yes, I am still and again trying to reduce memory consumption).

I don't know wether this sucks or not. One hand I am sparing a tremedous amount of Strings creation, on the other end I am recoding a number of parsers that are available on String instances.

##

HttpParser()

##

compare(byte[], int, int, byte[])
  Compare two byte arrays.
compare(byte[], int, int, byte[], int, int)
  Compare two byte arrays.
error(String, String)
  Emit an error.
nextItem(byte[], ParseState)
  Parse list of items, taking care of quotes and optional LWS.
parseDate(byte[], ParseState)
  Parse the given byte array as an HTTP compliant date.
parseDateOrDeltaSeconds(byte[], ParseState)
parseDateOrDeltaSeconds(byte[], ParseState, long)
  Parse a date as either a delta-second value, or a date.
parseDeltaSecond(byte[], ParseState)
  Parse a delta-second value.
parseInt(byte[], int, ParseState)
  Parse an integer, and return an updated pointer.
parseInt(byte[], ParseState)
parseMonth(byte[], ParseState)
parseQuality(byte[], ParseState)
skipSpaces(byte[], ParseState)
  Skip leading LWS, not including CR LF.
unquote(byte[], ParseState)

##

HttpParser

     public HttpParser()

##

error

     protected static void error(String mth,
                                 String msg) throws HttpInvalidValueException

  Emit an error.

  Parameters:
    mth - The method trigerring the error.
    msg - An associated message.
  Throws: HttpInvalidValueException
    To indicate the error to caller.

compare

     public static final int compare(byte b1[],
                                     int o1,
                                     int l1,
                                     byte b2[],
                                     int o2,
                                     int l2)

  Compare two byte arrays. I am not comfident about how the equality of byte arrays is performed by other means, sorry.

  Parameters:
    b1 - The first byte array.
    o1 - The offset of the bytes to compare.
    l1 - The number of bytes to compare.
    b2 - What to compare against.
    o2 - The offset of the bytes to compare.
    l2 - The length of the bytes to compare.
  Returns:
    An integer, <0 if b1 is less than b2, 0 if equals, >0otherwise.

compare

     public static final int compare(byte b1[],
                                     int o1,
                                     int l1,
                                     byte b2[])

  Compare two byte arrays. Short-cut version of the above version.

  Parameters:
    b1 - The first byte array.
    o1 - The offset of the bytes to compare.
    l1 - The number of bytes to compare.
    b2 - What to compare against.
  Returns:
    An integer, <0 if b1 is less than b2, 0 if equals, >0otherwise.

parseInt

     public static final int parseInt(byte buf[],
                                      int radix,
                                      ParseState ps)

  Parse an integer, and return an updated pointer.

parseInt

     public static final int parseInt(byte buf[],
                                      ParseState ps)

unquote

     public static boolean unquote(byte buf[],
                                   ParseState ps)

skipSpaces

     public static final int skipSpaces(byte buf[],
                                        ParseState ps)

  Skip leading LWS, not including CR LF. Update the input offset, after any leading space.

  Parameters:
    buf - The buffer to be parsed.
    ptr - The buffer pointer to be updated on return.
  Returns:
    The potentially advanced buffer input offset.

nextItem

     public static final int nextItem(byte buf[],
                                      ParseState ps)

  Parse list of items, taking care of quotes and optional LWS. The output offset points to the next element of the list.

parseMonth

     public static int parseMonth(byte buf[],
                                  ParseState ps)

parseDeltaSecond

     public static long parseDeltaSecond(byte buf[],
                                         ParseState ps)

  Parse a delta-second value.

  Returns:
    A long giving the date at which to retry as a number of milliseconds since Java epoch.

parseDate

     public static long parseDate(byte buf[],
                                  ParseState ps)

  Parse the given byte array as an HTTP compliant date.

  Parameters:
    buf - The byte buffer to parse.
    sp - The current parsing state.
  Returns:
    A long giving the date as a number of milliseconds since epoch.

parseDateOrDeltaSeconds

     public static long parseDateOrDeltaSeconds(byte buf[],
                                                ParseState ps,
                                                long relto)

  Parse a date as either a delta-second value, or a date. In case of delta seconds, we use the current time (except if one is provided), to compute the date.

  Returns:
    A date encoded as the number of millisconds since Java epoch.

parseDateOrDeltaSeconds

     public static long parseDateOrDeltaSeconds(byte buf[],
                                                ParseState ps)

parseQuality

     public static double parseQuality(byte buf[],
                                       ParseState ps)

    All Packages  Class Hierarchy  This Package  Previous  Next  Index