Class TagParser

java.lang.Object
  |
  +--TagParser

public class TagParser
extends java.lang.Object

A VERY simple parser that helps the programmer search through the xml and collect course id's and prerequisites.


Constructor Summary
TagParser(java.lang.String s)
          Create a parser with the string to be parsed.
 
Method Summary
 java.lang.String getString()
          get the string pointed to by the index.
 java.lang.String getTag()
          search the string for the next tag name (element name).
static void main(java.lang.String[] args)
          test driver
 java.lang.String nextPrereq()
          Gathering prerequisites from within an attribute list.
 int skipDouble()
          leave the index one char beyond the next double quote " if none exists return -1, otherwise return the index of the double quote + 1
 int skipLeftAngle()
          search the xml and leave the index one char beyond the next '<' if no '<' exists return -1, otherwise return the index of the '<' plus 1
 java.lang.String skipParticularTag(java.lang.String tag)
          move the index beyond a particular tag name.
 int skipToPrerequisite()
          pre: the index is just beyond an element name but before any prerequisites.
 void skipWhite()
          move the index past any white space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagParser

public TagParser(java.lang.String s)
Create a parser with the string to be parsed.
Method Detail

skipLeftAngle

public int skipLeftAngle()
search the xml and leave the index one char beyond the next '<' if no '<' exists return -1, otherwise return the index of the '<' plus 1

skipDouble

public int skipDouble()
leave the index one char beyond the next double quote " if none exists return -1, otherwise return the index of the double quote + 1

skipWhite

public void skipWhite()
move the index past any white space. If no whitespace is present, leave the index alone.

getString

public java.lang.String getString()
get the string pointed to by the index. A string may contain {letters,digits,underscores,dashes}. If none of these symbols is present then return the empty string.
Returns:
the string got or the empty string

getTag

public java.lang.String getTag()
search the string for the next tag name (element name). if none exists then return null otherwise return the name

skipParticularTag

public java.lang.String skipParticularTag(java.lang.String tag)
move the index beyond a particular tag name. if the tag name does not exist then return null. if the tag name does exist return the name.

skipToPrerequisite

public int skipToPrerequisite()
pre: the index is just beyond an element name but before any prerequisites. post: if there are no prerequisites return -1 if there are prerequisites move the index to the first and return 1

nextPrereq

public java.lang.String nextPrereq()
Gathering prerequisites from within an attribute list. Pre: the index is within a quoted attribute list. Post: returns null if no attributes remain returns the next attribute (as a string) if one exists

main

public static void main(java.lang.String[] args)
test driver