org.webharvest.utils
Class SystemUtilities

java.lang.Object
  extended by org.webharvest.utils.SystemUtilities

public class SystemUtilities
extends java.lang.Object

Collection of useful constants and functions that are available in each scraper context.


Field Summary
static Variable apos
           
static Variable backspace
           
static Variable cr
           
static Variable lf
           
static Variable quot
           
static Variable space
           
static Variable tab
           
 
Constructor Summary
SystemUtilities(Scraper scraper)
           
 
Method Summary
 java.lang.String date()
          Returns current date formated as "yyyyMMdd".
 java.lang.String datetime(java.lang.Object format)
          Returns formatted date/time for specified format string.
 void defineVariable(java.lang.String varName, java.lang.Object varValue)
          Adds or/replaces variable in scraper's context.
 void defineVariable(java.lang.String varName, java.lang.Object varValue, boolean overwrite)
          Adds or/replaces variable in scraper's context.
 java.lang.String escapeXml(java.lang.Object s)
          Escapes XML string - special characters: &'"<> are replaced with XML escape sequences: & ' " < >
 java.lang.String fullUrl(java.lang.Object pageUrl, java.lang.Object link)
          Calculates full URL for specified page URL and link which could be full, absolute or relative like there can be found in A or IMG tags.
 java.lang.String getFilename(java.lang.String path)
           
 Variable getVar(java.lang.String varName)
          Returns variable from scraper context
 boolean isVariableDefined(java.lang.String varName)
           
 void setScraper(Scraper scraper)
           
 java.lang.String time()
           
 Variable xpath(java.lang.Object expression, java.lang.Object xml)
          Evaluates XPath expression on specified XML
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lf

public static final Variable lf

tab

public static final Variable tab

cr

public static final Variable cr

space

public static final Variable space

quot

public static final Variable quot

apos

public static final Variable apos

backspace

public static final Variable backspace
Constructor Detail

SystemUtilities

public SystemUtilities(Scraper scraper)
Method Detail

setScraper

public void setScraper(Scraper scraper)

isVariableDefined

public boolean isVariableDefined(java.lang.String varName)
Parameters:
varName -
Returns:
True if scraper's context contain not-null variable with specified name.

getVar

public Variable getVar(java.lang.String varName)
Returns variable from scraper context

Parameters:
varName - Name of the variable

defineVariable

public void defineVariable(java.lang.String varName,
                           java.lang.Object varValue,
                           boolean overwrite)
Adds or/replaces variable in scraper's context. If overwrite is false and variable with specified name already exists, it won't be updated.

Parameters:
varName -
varValue -
overwrite -

defineVariable

public void defineVariable(java.lang.String varName,
                           java.lang.Object varValue)
Adds or/replaces variable in scraper's context.

Parameters:
varName -
varValue -

datetime

public java.lang.String datetime(java.lang.Object format)
Returns formatted date/time for specified format string.

Parameters:
format -

date

public java.lang.String date()
Returns current date formated as "yyyyMMdd".


time

public java.lang.String time()

escapeXml

public java.lang.String escapeXml(java.lang.Object s)
Escapes XML string - special characters: &'"<> are replaced with XML escape sequences: & ' " < >


fullUrl

public java.lang.String fullUrl(java.lang.Object pageUrl,
                                java.lang.Object link)
Calculates full URL for specified page URL and link which could be full, absolute or relative like there can be found in A or IMG tags.


xpath

public Variable xpath(java.lang.Object expression,
                      java.lang.Object xml)
Evaluates XPath expression on specified XML

Parameters:
expression -
xml -

getFilename

public java.lang.String getFilename(java.lang.String path)
Parameters:
path -
Returns:
Filename for the full path