org.erowid.sperowider.htmlshredding
Class RawHtmlData

java.lang.Object
  extended byorg.erowid.sperowider.htmlshredding.RawHtmlData

public class RawHtmlData
extends Object

Convenience class to allow easy parsing of found data. It sort of implements BufferedInputStream, but has a smarter marking mechanism ... you can make multiple nested marks. It is not threadsafe, so you'll have to manage that externally.

Version:
: $Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/htmlshredding/RawHtmlData.java,v 1.5 2005/02/27 03:56:39 gurustu Exp $
Author:
: $Author: gurustu $

Field Summary
static char[] EMPTY_ARRAY
          An empty character array
 
Constructor Summary
RawHtmlData(InputStream in)
          Creates a new RawHtmlData object from the InputStream
RawHtmlData(Reader reader)
          Creates a new RawHtmlData object from the Reader
RawHtmlData(String data)
          Creates a new RawHtmlData object from a String
 
Method Summary
 boolean characterMatch(int position, char match)
          Returns true if the character at the position matches the passed in character.
 boolean characterMatch(int position, char match, boolean ignoreCase)
          Returns true if the character at the position matches the passed in character.
 boolean charactersMatch(int position, char[] match)
          Returns true if the characters starting at position match the passed in parameter, without adjusting the current position.
 boolean charactersMatch(int position, char[] match, boolean ignoreCase)
          Returns true if the characters starting at position match the passed in parameter, without adjusting the current position.
 int getPosition()
          Gets the current position
 boolean isAtEnd()
          Returns true if the read position is past the end of the data
 void jumpTo(int position)
          Jumps to a position
static void main(String[] args)
          Tests.
 boolean nextCharactersMatch(char[] match)
          Returns true if the next characters match the passed in parameter, without adjusting the current position.
 boolean nextCharactersMatch(char[] match, boolean ignoreCase)
          Returns true if the next characters match the passed in parameter, without adjusting the current position.
 int read()
          Returns the next character as an int, or -1 if there are no characters left to read.
 char[] read(int length)
          Returns from the current position to the length provided
 char[] readPast(char[] match, boolean include)
          Reads up to, and including, the match characters
 char[] readPast(char[] match, boolean include, boolean ignoreCase)
          Reads up to, and including, the match characters
 char[] readPast(char match, boolean include)
          Reads up to, and including, the match character
 char[] readPast(char match, boolean include, boolean ignoreCase)
          Reads up to, and including, the match character
 char readPastWhitespace()
          Returns the first non-whitespace character
 char[] readTo(int position)
          Returns from the current position to the position provided
 char[] readUntil(char match)
          Reads up to, but not including the match character
 char[] readUntil(char[] match)
          Reads up to, but not including the match characters
 char[] readUntil(char[] match, boolean ignoreCase)
          Reads up to, but not including the match characters
 char[] readUntil(char match, boolean ignoreCase)
          Reads up to, but not including the match character
 char[] readWhitespace()
          Reads until we're done with whitespace
 void skip(int offset)
          Skips forward or back a number of spaces, and returns the position it's at.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final char[] EMPTY_ARRAY
An empty character array

Constructor Detail

RawHtmlData

public RawHtmlData(Reader reader)
            throws IOException
Creates a new RawHtmlData object from the Reader


RawHtmlData

public RawHtmlData(InputStream in)
            throws IOException
Creates a new RawHtmlData object from the InputStream


RawHtmlData

public RawHtmlData(String data)
Creates a new RawHtmlData object from a String

Method Detail

getPosition

public int getPosition()
Gets the current position


isAtEnd

public boolean isAtEnd()
Returns true if the read position is past the end of the data


jumpTo

public void jumpTo(int position)
Jumps to a position

Throws:
IndexOutOfBoundsException - If the jump-to position is below zero or above the size

skip

public void skip(int offset)
Skips forward or back a number of spaces, and returns the position it's at.

Throws:
IndexOutOfBoundsException - If the skipped-to position is below zero or above the size

read

public int read()
Returns the next character as an int, or -1 if there are no characters left to read.


nextCharactersMatch

public boolean nextCharactersMatch(char[] match,
                                   boolean ignoreCase)
Returns true if the next characters match the passed in parameter, without adjusting the current position.


nextCharactersMatch

public boolean nextCharactersMatch(char[] match)
Returns true if the next characters match the passed in parameter, without adjusting the current position.


characterMatch

public boolean characterMatch(int position,
                              char match)
Returns true if the character at the position matches the passed in character.


characterMatch

public boolean characterMatch(int position,
                              char match,
                              boolean ignoreCase)
Returns true if the character at the position matches the passed in character.


charactersMatch

public boolean charactersMatch(int position,
                               char[] match,
                               boolean ignoreCase)
Returns true if the characters starting at position match the passed in parameter, without adjusting the current position.


charactersMatch

public boolean charactersMatch(int position,
                               char[] match)
Returns true if the characters starting at position match the passed in parameter, without adjusting the current position.


read

public char[] read(int length)
Returns from the current position to the length provided


readTo

public char[] readTo(int position)
Returns from the current position to the position provided


readUntil

public char[] readUntil(char match,
                        boolean ignoreCase)
Reads up to, but not including the match character


readUntil

public char[] readUntil(char match)
Reads up to, but not including the match character


readUntil

public char[] readUntil(char[] match,
                        boolean ignoreCase)
Reads up to, but not including the match characters


readUntil

public char[] readUntil(char[] match)
Reads up to, but not including the match characters


readPast

public char[] readPast(char match,
                       boolean include,
                       boolean ignoreCase)
Reads up to, and including, the match character


readPast

public char[] readPast(char match,
                       boolean include)
Reads up to, and including, the match character


readPast

public char[] readPast(char[] match,
                       boolean include,
                       boolean ignoreCase)
Reads up to, and including, the match characters


readPast

public char[] readPast(char[] match,
                       boolean include)
Reads up to, and including, the match characters


readWhitespace

public char[] readWhitespace()
Reads until we're done with whitespace


readPastWhitespace

public char readPastWhitespace()
Returns the first non-whitespace character


main

public static void main(String[] args)
Tests.


spero logo small Sperowider is
© 2005 Erowid.org