Quadcap Embeddable Server

com.quadcap.util.text.Scanner Class Reference

List of all members.

Detailed Description

The class implements a series of low-level stream scanning operations, using OctetMaps to implement 'while' and 'until'.

Author:
Stan Bailes

Definition at line 58 of file Scanner.java.

Public Member Functions

 Scanner (InputStream is, boolean saveit)
String getLog ()
 Scanner (InputStream is)
 Construct a new scanner, attached to the specified input stream.

void reset (InputStream is)
final void skipWhile (OctetMap map) throws IOException
 Read and discard characters until a character is found which is not in the map.

final void skipUntil (OctetMap map) throws IOException
 Read and discard characters until a character is found which is in the map.

final String parseWhile (OctetMap map) throws IOException
 Return the next portion of the stream which consists of characters IN the specified set.

final String parseUntil (OctetMap map) throws IOException
 Return the next portion of the stream which consists of characters NOT IN the specified set.

final void matchChar (int expected) throws IOException
 Read the next character, and verify that it is equal to the expected value.

final void matchString (OctetMap map, String expected) throws IOException
 Read the next string using the specified map, and verify that it IS equal to the expected value.

final void matchStringIgnoreCase (OctetMap map, String expected) throws IOException
 Read the next string using the specified map, and verify that it IS equal to the expected value, if all characters in both strings are converted to monocase.

final int peek () throws IOException
 Peek ahead one character in the stream by reading, then pushing back the character.


Static Public Member Functions

int copyWhile (InputStream is, OutputStream os, OctetMap map) throws IOException
 Copy bytes from an input stream to an output stream until a byte not in the specified set is found.

int copyUntil (InputStream is, OutputStream os, OctetMap map) throws IOException
 Copy bytes from an input stream to an output stream until a byte in the specified set is found.

int copyUntil (InputStream is, OutputStream os, int dc) throws IOException
int copyUntil (BufferedInputStream is, OutputStream os, String s) throws IOException
 Copy bytes from in to out until the specified string is is.read from in</code.

int skipWhile (InputStream is, int dc) throws IOException
 Read and discard characters until a character is found which is not equal to the specified character.


Package Functions

final int read () throws IOException
final void unread (int c)

Package Attributes

InputStream is
StringBuffer sb = new StringBuffer()
int pushback = -1
LogInputStream log = null
ByteArrayOutputStream bos = null


Constructor & Destructor Documentation

com.quadcap.util.text.Scanner.Scanner InputStream  is,
boolean  saveit
 

Definition at line 67 of file Scanner.java.

References com.quadcap.util.text.Scanner.bos.

com.quadcap.util.text.Scanner.Scanner InputStream  is  ) 
 

Construct a new scanner, attached to the specified input stream.

Parameters:
is the stream to scan.

Definition at line 84 of file Scanner.java.


Member Function Documentation

int com.quadcap.util.text.Scanner.copyUntil BufferedInputStream  is,
OutputStream  os,
String  s
throws IOException [static]
 

Copy bytes from in to out until the specified string is is.read from in</code.

The string bytes are not written to out

Parameters:
is the input stream from which bytes are is.read
os the output stream to which bytes are written
s the delimiter string
Returns:
< 0 if end of file is reached before the string is found, >= 0 otherwise
Exceptions:
IOException may be thrown

Definition at line 319 of file Scanner.java.

References com.quadcap.util.text.Scanner.is.

int com.quadcap.util.text.Scanner.copyUntil InputStream  is,
OutputStream  os,
int  dc
throws IOException [static]
 

Definition at line 296 of file Scanner.java.

References com.quadcap.util.text.Scanner.is.

int com.quadcap.util.text.Scanner.copyUntil InputStream  is,
OutputStream  os,
OctetMap  map
throws IOException [static]
 

Copy bytes from an input stream to an output stream until a byte in the specified set is found.

That byte is returned, or -1 the end of file is reached.

Parameters:
is the input stream from which bytes are is.read
os the output stream to which bytes are written
map the set of valid delimiter bytes
Returns:
the first matching byte
Exceptions:
IOException may be thrown

Definition at line 285 of file Scanner.java.

References com.quadcap.util.text.Scanner.copyUntil(), and com.quadcap.util.text.Scanner.is.

Referenced by com.quadcap.util.text.Scanner.copyUntil().

int com.quadcap.util.text.Scanner.copyWhile InputStream  is,
OutputStream  os,
OctetMap  map
throws IOException [static]
 

Copy bytes from an input stream to an output stream until a byte not in the specified set is found.

That byte is returned, or -1 the end of file is reached.

Parameters:
is the input stream from which bytes are is.read
os the output stream to which bytes are written
map the set of valid byte to copy
Returns:
the first non matching byte
Exceptions:
IOException may be thrown

Definition at line 263 of file Scanner.java.

References com.quadcap.util.text.Scanner.copyWhile(), and com.quadcap.util.text.Scanner.is.

Referenced by com.quadcap.util.text.Scanner.copyWhile().

String com.quadcap.util.text.Scanner.getLog  ) 
 

Definition at line 76 of file Scanner.java.

References com.quadcap.util.text.Scanner.bos.

Referenced by com.quadcap.http.servlets.cgi.CgiScript.makeOutputThread().

final void com.quadcap.util.text.Scanner.matchChar int  expected  )  throws IOException
 

Read the next character, and verify that it is equal to the expected value.

Parameters:
expected the expected character
Exceptions:
IOException if the character read from the stream is not equal to the specified character.

Definition at line 182 of file Scanner.java.

References com.quadcap.util.text.Scanner.matchChar(), and com.quadcap.util.text.Scanner.read().

Referenced by com.quadcap.util.text.Scanner.matchChar().

final void com.quadcap.util.text.Scanner.matchString OctetMap  map,
String  expected
throws IOException
 

Read the next string using the specified map, and verify that it IS equal to the expected value.

Parameters:
expected the expected string
Exceptions:
IOException if the character read from the stream is not equal to the specified character.

Definition at line 203 of file Scanner.java.

References com.quadcap.util.text.Scanner.matchString().

Referenced by com.quadcap.util.text.Scanner.matchString().

final void com.quadcap.util.text.Scanner.matchStringIgnoreCase OctetMap  map,
String  expected
throws IOException
 

Read the next string using the specified map, and verify that it IS equal to the expected value, if all characters in both strings are converted to monocase.

Parameters:
expected the expected string
Exceptions:
IOException if the character read from the stream is not equal to the specified character.

Definition at line 222 of file Scanner.java.

References com.quadcap.util.text.Scanner.matchStringIgnoreCase(), and com.quadcap.util.text.Scanner.peek().

Referenced by com.quadcap.util.text.Scanner.matchStringIgnoreCase().

final String com.quadcap.util.text.Scanner.parseUntil OctetMap  map  )  throws IOException
 

Return the next portion of the stream which consists of characters NOT IN the specified set.

Parameters:
map the set of characters to parse.
Exceptions:
IOException if an I/O exception is thrown

Definition at line 163 of file Scanner.java.

References com.quadcap.util.text.Scanner.parseUntil(), com.quadcap.util.text.Scanner.read(), and com.quadcap.util.text.Scanner.sb.

Referenced by com.quadcap.util.text.Scanner.parseUntil(), and com.quadcap.http.client.LinkChecker.run().

final String com.quadcap.util.text.Scanner.parseWhile OctetMap  map  )  throws IOException
 

Return the next portion of the stream which consists of characters IN the specified set.

Parameters:
map the set of characters to parse.
Exceptions:
IOException if an I/O exception is thrown

Definition at line 146 of file Scanner.java.

References com.quadcap.util.text.Scanner.parseWhile(), com.quadcap.util.text.Scanner.read(), and com.quadcap.util.text.Scanner.sb.

Referenced by com.quadcap.http.server22.WebServer.parseMimeTypes(), and com.quadcap.util.text.Scanner.parseWhile().

final int com.quadcap.util.text.Scanner.peek  )  throws IOException
 

Peek ahead one character in the stream by reading, then pushing back the character.

Returns:
the next character from the stream.
Exceptions:
IOException if an exception is thrown when the character is read.

Definition at line 242 of file Scanner.java.

References com.quadcap.util.text.Scanner.pushback, and com.quadcap.util.text.Scanner.read().

Referenced by com.quadcap.util.text.Scanner.matchStringIgnoreCase(), and com.quadcap.http.server22.WebServer.parseMimeTypes().

final int com.quadcap.util.text.Scanner.read  )  throws IOException [package]
 

Definition at line 99 of file Scanner.java.

References com.quadcap.util.text.Scanner.is, and com.quadcap.util.text.Scanner.pushback.

Referenced by com.quadcap.util.text.Scanner.matchChar(), com.quadcap.util.text.Scanner.parseUntil(), com.quadcap.util.text.Scanner.parseWhile(), com.quadcap.util.text.Scanner.peek(), com.quadcap.util.text.Scanner.skipUntil(), and com.quadcap.util.text.Scanner.skipWhile().

void com.quadcap.util.text.Scanner.reset InputStream  is  ) 
 

Definition at line 88 of file Scanner.java.

References com.quadcap.util.text.Scanner.bos, com.quadcap.util.text.Scanner.pushback, and com.quadcap.util.text.Scanner.reset().

Referenced by com.quadcap.util.text.Scanner.reset().

final void com.quadcap.util.text.Scanner.skipUntil OctetMap  map  )  throws IOException
 

Read and discard characters until a character is found which is in the map.

Then push back the terminating character.

Parameters:
map the set of characters which skip.
Exceptions:
IOException if an I/O exception is thrown

Definition at line 133 of file Scanner.java.

References com.quadcap.util.text.Scanner.read(), and com.quadcap.util.text.Scanner.skipUntil().

Referenced by com.quadcap.http.server22.WebServer.parseMimeTypes(), com.quadcap.http.client.LinkChecker.run(), and com.quadcap.util.text.Scanner.skipUntil().

int com.quadcap.util.text.Scanner.skipWhile InputStream  is,
int  dc
throws IOException [static]
 

Read and discard characters until a character is found which is not equal to the specified character.

Return the terminating character.

Parameters:
dc the character to discard
Exceptions:
IOException if an I/O exception is thrown

Definition at line 355 of file Scanner.java.

References com.quadcap.util.text.Scanner.is.

final void com.quadcap.util.text.Scanner.skipWhile OctetMap  map  )  throws IOException
 

Read and discard characters until a character is found which is not in the map.

Then push back the terminating character.

Parameters:
map the set of characters to skip.
Exceptions:
IOException if an I/O exception is thrown

Definition at line 120 of file Scanner.java.

References com.quadcap.util.text.Scanner.read(), and com.quadcap.util.text.Scanner.skipWhile().

Referenced by com.quadcap.http.server22.WebServer.parseMimeTypes(), com.quadcap.http.client.LinkChecker.run(), and com.quadcap.util.text.Scanner.skipWhile().

final void com.quadcap.util.text.Scanner.unread int  c  )  [package]
 

Definition at line 109 of file Scanner.java.

References com.quadcap.util.text.Scanner.pushback, and com.quadcap.util.text.Scanner.unread().

Referenced by com.quadcap.util.text.Scanner.unread().


Member Data Documentation

ByteArrayOutputStream com.quadcap.util.text.Scanner.bos = null [package]
 

Definition at line 65 of file Scanner.java.

Referenced by com.quadcap.util.text.Scanner.getLog(), com.quadcap.util.text.Scanner.reset(), and com.quadcap.util.text.Scanner.Scanner().

InputStream com.quadcap.util.text.Scanner.is [package]
 

Definition at line 59 of file Scanner.java.

Referenced by com.quadcap.util.text.Scanner.copyUntil(), com.quadcap.util.text.Scanner.copyWhile(), com.quadcap.util.text.Scanner.read(), and com.quadcap.util.text.Scanner.skipWhile().

LogInputStream com.quadcap.util.text.Scanner.log = null [package]
 

Definition at line 64 of file Scanner.java.

int com.quadcap.util.text.Scanner.pushback = -1 [package]
 

Definition at line 61 of file Scanner.java.

Referenced by com.quadcap.util.text.Scanner.peek(), com.quadcap.util.text.Scanner.read(), com.quadcap.util.text.Scanner.reset(), and com.quadcap.util.text.Scanner.unread().

StringBuffer com.quadcap.util.text.Scanner.sb = new StringBuffer() [package]
 

Definition at line 60 of file Scanner.java.

Referenced by com.quadcap.util.text.Scanner.parseUntil(), and com.quadcap.util.text.Scanner.parseWhile().