public class RunnableScrapingSession
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static org.apache.log4j.Logger |
log
Used for logging.
|
| Constructor and Description |
|---|
RunnableScrapingSession(java.lang.String name)
Instantiates a new runnable scraping session that will use the scraping session identified by the name parameter to scrape data.
|
RunnableScrapingSession(java.lang.String name,
ScrapingSession parentScrapingSession)
Creates a new instance by inheriting the state and notifiable from the given
ScrapingSession. |
RunnableScrapingSession(java.lang.String name,
ScrapingSession parentScrapingSession,
boolean inheritHttpState)
Creates a new instance by inheriting the state and notifiable from the given
ScrapingSession. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEndScrapeCallback(EventHandler<SessionEventData> handler)
Adds a callback to be called after the scraping session runs.
|
boolean |
getDoLazyScrape()
Indicates whether or not a lazy scrape should be done on the session.
|
<T> T |
getInternalVariable(java.lang.String key)
Gets the value of an internal variable.
|
java.lang.String |
getName()
Gets the name of the scraping session.
|
ScrapingSession |
getScrapingSession()
Returns the scraping session that will be run (or is running).
|
ScrapingSessionNotifiable |
getScrapingSessionNotifiable()
Gets the object the scraping session will use to notify its progress of.
|
int |
getTimeout()
Gets the timeout, in minutes, for the scraping session.
|
java.lang.Object |
getVariable(java.lang.String variable)
Gets the value of a session variable.
|
boolean |
isCompleted()
Returns true if the scrape has been completed (and was therefore run)
|
void |
loadVariables(java.lang.String fileToReadFrom)
Reads in and loads the session variables that were previously saved to a file.
|
void |
scrape()
Indicates the the runnable scraping session should be queued up for scraping.
|
void |
setDoLazyScrape(boolean doLazyScrape)
Indicates whether or not a lazy scrape should be done on the session.
|
void |
setInternalVariable(java.lang.String key,
java.lang.Object value)
Sets the value of an internal variable
|
void |
setName(java.lang.String name)
Sets the name of the scraping session.
|
void |
setScrapingSessionNotifiable(ScrapingSessionNotifiable scrapingSessionNotifiable)
Sets the object the scraping session will use to notify its progress of.
|
void |
setTimeout(int timeout)
Sets the timeout, in minutes, for the scraping session.
|
void |
setVariable(java.lang.String variable,
java.lang.Object value)
Sets the value of a session variable
|
void |
stopScraping()
Tells the child to stop scraping.
|
void |
stopScraping(boolean forceUpdate,
StopScrapingCallType stopScrapingType,
java.lang.String explanation)
Tells the child to stop scraping.
|
java.lang.String |
toString() |
boolean |
wasStopped()
Returns true if the scrape was stopped (either by calling stopScraping or in the workbench by clicking the stop scraping button)
|
public RunnableScrapingSession(java.lang.String name)
throws java.lang.Exception
name - The name of the scraping session. Note that this scraping session should already exist.java.lang.Exception - If the session doesn't existpublic RunnableScrapingSession(java.lang.String name,
@NotNull
ScrapingSession parentScrapingSession)
throws java.lang.Exception
ScrapingSession.name - The name of the scraping session this will run.parentScrapingSession - The ScrapingSession this should inherit from.java.lang.Exception - If the session doesn't exist or a null parent session is givenpublic RunnableScrapingSession(java.lang.String name,
@NotNull
ScrapingSession parentScrapingSession,
boolean inheritHttpState)
throws java.lang.Exception
ScrapingSession.name - The name of the scraping session this will run.parentScrapingSession - The ScrapingSession this should inherit from.inheritHttpState - Whether or not the HttpState should be inherited from the passed in scraping session.java.lang.Exception - If the session doesn't exist or a null parent session is given@Nullable public java.lang.String getName()
public void setName(java.lang.String name)
name - The name.public void setVariable(@NotNull java.lang.String variable, java.lang.Object value)
variable - The variable.value - The value of the variable.@InternalOnly public void setInternalVariable(@NotNull java.lang.String key, java.lang.Object value)
key - The variable.value - The value of the variable.@Nullable public java.lang.Object getVariable(@NotNull java.lang.String variable)
variable - The name of the variable.@Nullable public <T> T getInternalVariable(@NotNull java.lang.String key)
key - The name of the variable.public int getTimeout()
public void setTimeout(int timeout)
timeout - The timeout, in minutes.public boolean getDoLazyScrape()
public void setDoLazyScrape(boolean doLazyScrape)
doLazyScrape - A boolean.public void loadVariables(@NotNull java.lang.String fileToReadFrom) throws java.lang.Exception
fileToReadFrom - The file to read the variables from.java.lang.Exception - On error loading the variables from file@Nullable @InternalOnly public ScrapingSessionNotifiable getScrapingSessionNotifiable()
@InternalOnly public void setScrapingSessionNotifiable(ScrapingSessionNotifiable scrapingSessionNotifiable)
scrapingSessionNotifiable - The object.public void scrape()
@Nullable @InternalOnly public ScrapingSession getScrapingSession()
public void addEndScrapeCallback(@NotNull EventHandler<SessionEventData> handler)
SessionEventFireTime.AfterEndAndOtherCallbacks event, so if the
session adds it's own those may not have fired yet. Generally only internal code should use that fire time unless you know what you're doinghandler - The handler to addpublic void stopScraping()
public void stopScraping(boolean forceUpdate,
@NotNull
StopScrapingCallType stopScrapingType,
@Nullable
java.lang.String explanation)
forceUpdate - True iff this stop information should overwrite the stop information of a previous stop call (if one has occurred)stopScrapingType - The type of the stop call to setexplanation - An explanation of the stop callpublic boolean isCompleted()
public boolean wasStopped()
@NotNull public java.lang.String toString()
toString in class java.lang.Object