eteg.sinon.executor
Class CollectorExecutor

java.lang.Object
  extended by eteg.sinon.executor.CollectorExecutor

public class CollectorExecutor
extends java.lang.Object

Class that executes a Collector instance.

Version:
$Revision: 1.7 $
Author:
Thiago H. de Paula Figueiredo , Last modified by $Author: thiagohp $

Field Summary
static java.lang.String LOG_FILENAME
          Sinon log filename.
 
Constructor Summary
CollectorExecutor(Collector collector)
          Single constructor of this class.
 
Method Summary
 void addValueToProperty(java.lang.String propertyId, java.lang.String value, boolean allowDuplicates)
          Adds a value to a multivalued property (list).
 void execute()
          Executes all catalogs of this collector in sequence.
 void execute(Catalog[] catalogs)
          Executes a list of catalogs of the coletor.
 int getBytesDownloaded()
          Return the number of bytes already downloaded.
 Collector getCollector()
          Retuns the Collector to be executed by this executor.
 byte[] getCurrentBytes()
          Retorns the last downloaded document as a byte array.
 Catalog getCurrentCatalog()
          Returns the Catalog being executed.
 DataExtraction getCurrentDataExtraction()
          Returns the DataExtraction being executed.
 Page getCurrentPage()
          Returns the Page being executed.
 int getCurrentPosition()
          Retorns the current position in the current page.
 Step getCurrentStep()
          Returns the Step being executed.
 java.lang.String getCurrentText()
          Retorns the last downloaded page text.
 java.lang.String getExecutionInfo()
          Returns a String containing some execution information.
 long getFinishTime()
          Retorns the moment this executor finished in Unix timestamp format.
 org.apache.commons.logging.Log getLog()
          Returns the logger used by this executor.
 int getPagesDownloaded()
          Returns the number of pages already downloaded.
 java.lang.String getPropertyInfo()
          Retorns a String containing name and value of all properties set.
 java.lang.String[] getPropertyNames()
          Retorns a String array containing the name of all properties set in this executor.
 java.lang.Object getPropertyValue(java.lang.String propertyName)
          Returns the value of the property which name is propertyName.
 long getStartTime()
          Retorns the moment this executor started in Unix timestamp format.
 boolean isStopped()
          Returns true if the execution of this collector was stopped and false otherwise.
 void setProperty(java.lang.String propertyId, java.lang.String value)
          Sets a property.
 void stop()
          Stops the execution of this collector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILENAME

public static final java.lang.String LOG_FILENAME
Sinon log filename.

See Also:
Constant Field Values
Constructor Detail

CollectorExecutor

public CollectorExecutor(Collector collector)
Single constructor of this class.

Parameters:
collector - a Collector instance.
Throws:
java.lang.IllegalArgumentException - if collector is null.
Method Detail

execute

public void execute()
             throws SinonException
Executes all catalogs of this collector in sequence.

Throws:
SinonException - if some error ocurrs.

execute

public void execute(Catalog[] catalogs)
             throws SinonException
Executes a list of catalogs of the coletor.

Parameters:
catalogs - a Catalog array..
Throws:
SinonException - if some unhandled error ocurrs.

getCollector

public Collector getCollector()
Retuns the Collector to be executed by this executor.

Returns:
a Collector instance.

getCurrentCatalog

public Catalog getCurrentCatalog()
Returns the Catalog being executed.

Returns:
a Catalog instance.

getCurrentPage

public Page getCurrentPage()
Returns the Page being executed.

Returns:
a Page instance.

getCurrentDataExtraction

public DataExtraction getCurrentDataExtraction()
Returns the DataExtraction being executed.

Returns:
a DataExtraction instance.

getCurrentStep

public Step getCurrentStep()
Returns the Step being executed.

Returns:
a Step instance.

getPropertyNames

public java.lang.String[] getPropertyNames()
Retorns a String array containing the name of all properties set in this executor.

Returns:
a String[].

getCurrentText

public java.lang.String getCurrentText()
Retorns the last downloaded page text.

Returns:
a String.

getCurrentBytes

public byte[] getCurrentBytes()
Retorns the last downloaded document as a byte array.

Returns:
a byte[].

getCurrentPosition

public int getCurrentPosition()
Retorns the current position in the current page.

Returns:
an int.

getPagesDownloaded

public int getPagesDownloaded()
Returns the number of pages already downloaded.

Returns:
an int.

getBytesDownloaded

public int getBytesDownloaded()
Return the number of bytes already downloaded.

Returns:
an int.

getStartTime

public long getStartTime()
Retorns the moment this executor started in Unix timestamp format. Returns -1 if this executor has not started yet.

Returns:
a long.

getFinishTime

public long getFinishTime()
Retorns the moment this executor finished in Unix timestamp format. Returns -1 if this executor has not finished yet.

Returns:
a long.

getExecutionInfo

public java.lang.String getExecutionInfo()
Returns a String containing some execution information.

Returns:
a String.

getPropertyInfo

public java.lang.String getPropertyInfo()
Retorns a String containing name and value of all properties set.

Returns:
a String.

getLog

public org.apache.commons.logging.Log getLog()
Returns the logger used by this executor.

Returns:
a org.apache.commons.logging.Log instance.

getPropertyValue

public final java.lang.Object getPropertyValue(java.lang.String propertyName)
Returns the value of the property which name is propertyName. If this property is a simple value, a String is returned. Otherwise, a List containing Strings is returned.

Parameters:
propertyName - a String.
Returns:
the value of propertyName.
Throws:
java.lang.IllegalArgumentException - if propertyName is null.

addValueToProperty

public final void addValueToProperty(java.lang.String propertyId,
                                     java.lang.String value,
                                     boolean allowDuplicates)
                              throws SinonException
Adds a value to a multivalued property (list). If the property does not exists yet, it is created. To set simple properties, use setProperty(java.lang.String, java.lang.String).

Parameters:
propertyId - a String containing the property name.
value - a String containing the value to be added.
allowDuplicates - a boolean telling if duplicate values can be added or not.
Throws:
SinonException - if propertyId is not a multivalued property.
java.lang.IllegalArgumentException - if propertyId is null or if value is null.

setProperty

public final void setProperty(java.lang.String propertyId,
                              java.lang.String value)
                       throws SinonException
Sets a property. This method can only be used with simple properties. To add a value to a multivalued property, use addValueToProperty(java.lang.String, java.lang.String, boolean).

Parameters:
propertyId - a String containing the property name.
value - a String containing the property value.
Throws:
SinonException - if propertyId for o nome de uma propriedade multivalorada.
java.lang.IllegalArgumentException - se propertyId null ou se value null.

stop

public void stop()
Stops the execution of this collector.


isStopped

public boolean isStopped()
Returns true if the execution of this collector was stopped and false otherwise.

Returns:
true if the execution of this collector was stopped and false otherwise.


Copyright © 2004-2005 ETEG Internet Ltda.. All Rights Reserved.