org.apache.taglibs.scrape
Class PageData

java.lang.Object
  extended by org.apache.taglibs.scrape.PageData

public class PageData
extends java.lang.Object

PageData - An object used to store information about a scrape done by the tags in the scrape package.

Version:
1.0
Author:
Rich Catlett

Field Summary
static java.util.HashMap pageurls
          static HashMap holds all of the pagedata objects keyed to the url
 
Constructor Summary
PageData()
          constructor for the class simply creates an instance of the PageData object
 
Method Summary
 java.lang.String getAuth()
          get the base64 encoded auth string for proxy authorization
 boolean getChangeFlag()
          getter method for changeflag
 java.util.ArrayList getHeaders()
          get the http headers
 java.util.Set getKeySet()
          getter method for the key set of the HashMap scrapes
 long getLastScrape()
          getter method for lastscrape
 boolean getNewFlag()
          getter method for newflag
static PageData getPage(java.lang.String url, int port, java.lang.String server, java.lang.String name, java.lang.String pass)
          method checks the static HashMap pageurls for the given url if it exists it is returned, otherwise a new pagedata object is created and added to the HashMap pageurls
 javax.servlet.jsp.PageContext getPageContext()
          getter method for pagecontext returns the PageContext object for this page
 int getProxyPort()
          get the value of the proxy port
 java.lang.String getProxyServer()
          get the value of the proxy port
 java.lang.String getResults(java.lang.String id)
          getter method for a result string from a scrapedata object
 ScrapeData getScrape(java.lang.String key)
          getter method for a single scrapedata object from HashMap scrapes
 boolean getSSL()
          get secure
 void scrapePage(java.lang.String url, long time, javax.servlet.jsp.PageContext pc, java.lang.String cs)
          checks the scrapeint, if enough time has passed it starts the getPage thread to go out and get the page, and sets scrapeing to true, then if newflag it will wait for the thread to finish running, otherwise it will just fall through and return the already stored results
 void setAuth(java.lang.String name, java.lang.String pass)
          set the username and password values for authentication to the proxy server
 void setClientPass(java.lang.String value)
          set the pass word to access the client keystore
 void setException()
          set exception to true, a malformedpatternexception has been thrown in page
 void setExceptionText(java.lang.String begin, java.lang.String end)
          sets the exception text to make the error in the jsp page easier for the author to find
protected  void setHeader(java.lang.String name, java.lang.String value)
          set the name and value of any extra headers to be sent
 void setLastScrape(long time)
          setter method for lastscrape
 void setNewflag()
          setter method for newflag only called to set newflag to false
 void setPageContext(javax.servlet.jsp.PageContext page)
          setter method for pagecontext
 void setProxyPort(int value)
          set the value of proxy port
 void setProxyServer(java.lang.String value)
          set the value of proxy server
 void setScrape(java.lang.String id, java.lang.String begin, java.lang.String end, java.lang.String anchors, java.lang.String strip)
          method to add an object to the HashMap scrapes, it first checks to see if the object already exists
 void setSSL(boolean value)
          set the value of secure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageurls

public static java.util.HashMap pageurls
static HashMap holds all of the pagedata objects keyed to the url

Constructor Detail

PageData

public PageData()
constructor for the class simply creates an instance of the PageData object

Method Detail

getPage

public static PageData getPage(java.lang.String url,
                               int port,
                               java.lang.String server,
                               java.lang.String name,
                               java.lang.String pass)
method checks the static HashMap pageurls for the given url if it exists it is returned, otherwise a new pagedata object is created and added to the HashMap pageurls

Parameters:
url - the url of the page given in the calling PageTag
port - the port to use for the connection to the proxy server
server - the proxy server
secure - is the link going over https
name - user name for authentication
pass - password for authentication
Returns:
a PageData object either newly created or one already in existence

setScrape

public final void setScrape(java.lang.String id,
                            java.lang.String begin,
                            java.lang.String end,
                            java.lang.String anchors,
                            java.lang.String strip)
                     throws javax.servlet.jsp.JspException
method to add an object to the HashMap scrapes, it first checks to see if the object already exists

Parameters:
id - unique identifier of the scrape the following attributes define
begin - beginning anchor for the scrape refered to by id
end - ending anchor for the scrape refered to by id
anchors - boolean flag that determines if begin and end anchors are part of the result
strip - boolean flag that determines if tags are to be striped from the result
Throws:
javax.servlet.jsp.JspException

getResults

public java.lang.String getResults(java.lang.String id)
                            throws javax.servlet.jsp.JspException
getter method for a result string from a scrapedata object

Parameters:
id - unique key for requested scrape
Returns:
results from scrapeidentified by id
Throws:
javax.servlet.jsp.JspException

setHeader

protected final void setHeader(java.lang.String name,
                               java.lang.String value)
set the name and value of any extra headers to be sent

Parameters:
name - string that is the name of an extra header to be sent
value - string that is the value of an extra header to be sent

getHeaders

public java.util.ArrayList getHeaders()
get the http headers

Returns:
name ArrayList of the names of http headers to be sent

setNewflag

public void setNewflag()
setter method for newflag only called to set newflag to false


getNewFlag

public boolean getNewFlag()
getter method for newflag

Returns:
boolean value of newflag true if new scrape exists else false

setProxyPort

public final void setProxyPort(int value)
set the value of proxy port

Parameters:
value - the proxy port to use for the connection as a String

getProxyPort

public final int getProxyPort()
get the value of the proxy port

Returns:
- int the proxy port number

setProxyServer

public final void setProxyServer(java.lang.String value)
set the value of proxy server

Parameters:
value - the proxy server to use for the connection

getProxyServer

public final java.lang.String getProxyServer()
get the value of the proxy port

Returns:
- String the name or the proxy server

setClientPass

public final void setClientPass(java.lang.String value)
set the pass word to access the client keystore

Parameters:
value - password to the client keystore

setAuth

public final void setAuth(java.lang.String name,
                          java.lang.String pass)
set the username and password values for authentication to the proxy server

Parameters:
name - username
pass - password
base64 - base64 encoded username and password

getAuth

public final java.lang.String getAuth()
get the base64 encoded auth string for proxy authorization

Returns:
- String base64 encoded authorization for the proxy server

setSSL

public final void setSSL(boolean value)
set the value of secure

Parameters:
value - true if the connection is to be made via https the default is false

getSSL

public final boolean getSSL()
get secure

Returns:
- boolean value of secure flag

getKeySet

public final java.util.Set getKeySet()
getter method for the key set of the HashMap scrapes

Returns:
the keys that the scrapes for this page are hashed to

setLastScrape

public void setLastScrape(long time)
setter method for lastscrape

Parameters:
time - current time

getLastScrape

public long getLastScrape()
getter method for lastscrape

Parameters:
time - current time

setExceptionText

public void setExceptionText(java.lang.String begin,
                             java.lang.String end)
sets the exception text to make the error in the jsp page easier for the author to find

Parameters:
begin - the beginning marker for scrape where error occured
end - the end marker for the scrape where error occured

setException

public void setException()
set exception to true, a malformedpatternexception has been thrown in page


getChangeFlag

public boolean getChangeFlag()
getter method for changeflag

Returns:
boolean value of changeflag true if a scrape has been changed else false

getScrape

public ScrapeData getScrape(java.lang.String key)
getter method for a single scrapedata object from HashMap scrapes

Parameters:
key - the value the requested scrapedata object is keyed to
Returns:
the requested scrapedata boject

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext page)
setter method for pagecontext

Parameters:
page - the page context object for this page

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
getter method for pagecontext returns the PageContext object for this page


scrapePage

public void scrapePage(java.lang.String url,
                       long time,
                       javax.servlet.jsp.PageContext pc,
                       java.lang.String cs)
                throws javax.servlet.jsp.JspException
checks the scrapeint, if enough time has passed it starts the getPage thread to go out and get the page, and sets scrapeing to true, then if newflag it will wait for the thread to finish running, otherwise it will just fall through and return the already stored results

Parameters:
url - url of the page to be scraped
time - length of time to wait before rescrape
proxy - boolean value that says whether or not to use a proxy server
pc - PageContext for this JSP page
cs - charset to be used to scrape the page
Throws:
javax.servlet.jsp.JspException


Copyright ? 2000-2004 The Apache Software Foundation. All Rights Reserved.