celeboss.HTMLload
Class HTMLParser

java.lang.Object
  extended byceleboss.HTMLload.HTMLParser
Direct Known Subclasses:
CelebParser, LeagueOfLeagueParser, LeagueParser, PortfolioParser

public abstract class HTMLParser
extends java.lang.Object

This class uses a HTMLDataSource to load details.

Version:
1.0
Author:
bevans

Constructor Summary
protected HTMLParser(java.io.InputStream in)
          Creates a parser that will extract information from a HTML file representing the Celebrity details.
 
Method Summary
 void close()
          Close the associated stream.
protected static float convertMoney(java.lang.String txt)
          Helper method converts a raw text to a money value.
protected static float convertPerc(java.lang.String txt)
          This helper method converts a raw text to a percentage
protected  java.lang.String extractTitledValue(java.lang.String title)
          Extract the text value next to a property title.
protected  char getChar()
          This is a simple helper method that strips carriage returns from incoming chars.
protected  int getMillions()
          This method extract the number of millions the next sequecne of HTML describes.
protected  java.lang.String getNextValue()
          Get the next raw text value from the stream
protected  void setReturnTags(boolean b)
          Change whether this parser should return the HTML tags
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLParser

protected HTMLParser(java.io.InputStream in)
Creates a parser that will extract information from a HTML file representing the Celebrity details.

Parameters:
in - Input stream containig raw HTML.
Method Detail

convertMoney

protected static float convertMoney(java.lang.String txt)
Helper method converts a raw text to a money value.

Parameters:
txt - Raw text
Returns:
Money vlaue.

convertPerc

protected static float convertPerc(java.lang.String txt)
This helper method converts a raw text to a percentage

Parameters:
txt - Raw text
Returns:
FLoat of percentage

close

public void close()
           throws java.io.IOException
Close the associated stream.

Throws:
java.io.IOException - Problem closing.

extractTitledValue

protected java.lang.String extractTitledValue(java.lang.String title)
                                       throws java.io.IOException
Extract the text value next to a property title. This method will move throught the stream.

Parameters:
title - Search target
Returns:
Value extracted from stream.
Throws:
java.io.IOException - Problem reading stream.

getChar

protected char getChar()
                throws java.io.IOException
This is a simple helper method that strips carriage returns from incoming chars.

Returns:
Next char in stream.
Throws:
java.io.IOException - Problem reading stream

getMillions

protected int getMillions()
                   throws java.io.IOException
This method extract the number of millions the next sequecne of HTML describes. It assumes that the stream is correctly positioned. It is used in both the Portfolio and Mini-league parsers.

Returns:
Millions
Throws:
java.io.IOException - Something wrong with source stream

getNextValue

protected java.lang.String getNextValue()
                                 throws java.io.IOException
Get the next raw text value from the stream

Returns:
Text value.
Throws:
java.io.IOException - Problem with stream getting value

setReturnTags

protected void setReturnTags(boolean b)
Change whether this parser should return the HTML tags

Parameters:
b - New setting.