celeboss.HTMLload
Class WebDataSource

java.lang.Object
  extended byceleboss.HTMLload.HTMLDataSource
      extended byceleboss.HTMLload.WebDataSource
All Implemented Interfaces:
CelebDataSource

public class WebDataSource
extends HTMLDataSource

This class goes over the internet to the CelebDaq web site to extract details.

Version:
1.0
Author:
bevans

Field Summary
static java.lang.String LOGINURL
           
static java.lang.String TRADEURL
           
 
Method Summary
 java.lang.String buyShares(Celebrity celebrity, int number)
          Buy shares in a Celebrity.
protected  java.io.InputStream getCelebrityStream(int celebrityId)
          Extract the HTML details for the specified celebrity.
protected  java.io.InputStream getLeagueOfLeagueStream(int leagueId)
          Extract the HTML details of the league of leagues .
protected  java.io.InputStream getLeaguesStream()
          Extract the HTML details of the leagues this account is assigned.
protected  java.io.InputStream getLeagueStream(int leagueID)
          Extract the HTML details for the specified mini league.
protected  java.io.InputStream getPortfolioStream()
          Get the raw HTML dtaa as a stream for the portfolio
 boolean isLive()
          This data soruce is always live since it uses the CelebDaq server
 java.lang.String sellShares(Celebrity celebrity, int number)
          Sell shares in a Celebrity.
 void setUserPassword(java.lang.String user, java.lang.String password)
          Redefine the username and password assigned to this data source
 
Methods inherited from class celeboss.HTMLload.HTMLDataSource
getCelebrities, getLeagues, getUsername, updateCelebrity, updateLeague, updatePortfolio
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGINURL

public static final java.lang.String LOGINURL
See Also:
Constant Field Values

TRADEURL

public static final java.lang.String TRADEURL
See Also:
Constant Field Values
Method Detail

buyShares

public java.lang.String buyShares(Celebrity celebrity,
                                  int number)
                           throws java.io.IOException
Buy shares in a Celebrity. This will issue a URL to the remote Celebdaq server.

Parameters:
celebrity - Celebrity to buy
number - Number to buy
Returns:
Description of error condition
Throws:
java.io.IOException - Problem contacting server

getCelebrityStream

protected java.io.InputStream getCelebrityStream(int celebrityId)
                                          throws java.io.IOException
Extract the HTML details for the specified celebrity. This method is synchronised because the data source only maintains one connectino to the web server.

Specified by:
getCelebrityStream in class HTMLDataSource
Parameters:
celebrityId - Issues number of the celebrity.
Returns:
Input stream of the returned HTML
Throws:
java.io.IOException - If a problem occurs in the reading.
See Also:
HTMLDataSource.updateCelebrity(Celebrity)

getLeagueOfLeagueStream

protected java.io.InputStream getLeagueOfLeagueStream(int leagueId)
                                               throws java.io.IOException
Extract the HTML details of the league of leagues .

Specified by:
getLeagueOfLeagueStream in class HTMLDataSource
Parameters:
leagueId - League id.
Returns:
Input stream of the returned HTML
Throws:
java.io.IOException - If a problem occurs in the reading.

getLeaguesStream

protected java.io.InputStream getLeaguesStream()
                                        throws java.io.IOException
Extract the HTML details of the leagues this account is assigned.

Specified by:
getLeaguesStream in class HTMLDataSource
Returns:
Input stream of the returned HTML
Throws:
java.io.IOException - If a problem occurs in the reading.

getLeagueStream

protected java.io.InputStream getLeagueStream(int leagueID)
                                       throws java.io.IOException
Extract the HTML details for the specified mini league.

Specified by:
getLeagueStream in class HTMLDataSource
Parameters:
leagueID - Issues number of the league.
Returns:
Input stream of the returned HTML
Throws:
java.io.IOException - If a problem occurs in the reading.
See Also:
HTMLDataSource.updateLeague(celeboss.data.MiniLeague)

getPortfolioStream

protected java.io.InputStream getPortfolioStream()
                                          throws java.io.IOException
Get the raw HTML dtaa as a stream for the portfolio

Specified by:
getPortfolioStream in class HTMLDataSource
Returns:
HTML stream.
Throws:
java.io.IOException - if a problem occurs reading the stream.

isLive

public boolean isLive()
This data soruce is always live since it uses the CelebDaq server

Returns:
true;

sellShares

public java.lang.String sellShares(Celebrity celebrity,
                                   int number)
                            throws java.io.IOException
Sell shares in a Celebrity. This will issue a URL to the remote Celebdaq server.

Parameters:
celebrity - Celebrity to sell
number - Number to buy
Returns:
Description of error condition
Throws:
java.io.IOException - Problem contacting web server

setUserPassword

public void setUserPassword(java.lang.String user,
                            java.lang.String password)
Redefine the username and password assigned to this data source

Specified by:
setUserPassword in interface CelebDataSource
Overrides:
setUserPassword in class HTMLDataSource
Parameters:
user - New user
password - New password