public class ScrapingSessionState
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static org.apache.log4j.Logger |
log
Used for logging.
|
Constructor and Description |
---|
ScrapingSessionState() |
Modifier and Type | Method and Description |
---|---|
void |
clearVariables()
Clears all session variables.
|
void |
dropCachedDataSetTables()
Scans for any
DataSet objects, and, if they've been
cached, drops their corresponding tables. |
java.lang.String |
getAllSessionVariablesAsURLEncodedString()
Gets all session variables as a URL-encoded string.
|
<T> T |
getInternalVariable(java.lang.String key)
Gets the value of an internal use variable (not cleared by session.clearVariables())
|
java.util.Map<java.lang.String,java.lang.Object> |
getInternalVariables()
Gets the
HashMap holding all of the variables. |
int |
getNumVariables()
Gets the number of variables held by the object.
|
java.util.Iterator |
getSessionVariableKeysIterator()
Gets an
Iterator over which session variables
can be seen. |
java.util.Iterator |
getSessionVariableKeysIteratorSorted()
Gets an
Iterator over which sorted session variables
can be accessed. |
java.lang.String |
getString(java.lang.String variable)
Gets the value of a session variable as a
String . |
java.lang.Object |
getVariable(java.lang.String variable)
Gets the value of a session variable.
|
java.lang.String |
getVariableName(int sequence)
Gets the key of a variable by sequence.
|
java.util.Map<java.lang.String,java.lang.Object> |
getVariables()
Gets the
HashMap holding all of the variables. |
void |
loadVariables(java.lang.String fileToReadFrom)
Reads in and loads the session variables that were previously
saved to a file.
|
java.lang.String |
resolveVariables(java.lang.String value)
Given a
String attempts to resolve any variables. |
void |
saveVariables(java.lang.String fileToSaveTo)
Writes out the current session variables to a file.
|
void |
setInternalVariable(java.lang.String key,
java.lang.Object value)
Sets the value of an internal variable.
|
void |
setString(java.lang.String variable,
java.lang.String value)
Sets the value of a session variable as a
String . |
void |
setVariable(java.lang.String variable,
java.lang.Object value)
Sets the value of a session variable.
|
@Nullable public java.lang.Object getVariable(@NotNull java.lang.String variable)
variable
- The name of the variable.@InternalOnly @Nullable public <T> T getInternalVariable(@NotNull java.lang.String key)
key
- The name of the variablepublic void setVariable(@NotNull java.lang.String variable, @Nullable java.lang.Object value)
variable
- The variable.value
- The value of the variable.@InternalOnly public void setInternalVariable(@NotNull java.lang.String key, @Nullable java.lang.Object value)
key
- The variable.value
- The value of the variable, or null to clear it.public void clearVariables()
public java.lang.String getString(java.lang.String variable)
String
.variable
- The name of the variable.public void setString(java.lang.String variable, java.lang.String value)
String
.variable
- The variable.value
- The value of the variable.@Nullable public java.lang.String getVariableName(int sequence)
sequence
- The sequence.@NotNull public java.util.Map<java.lang.String,java.lang.Object> getVariables()
HashMap
holding all of the variables.HashMap
.@NotNull @InternalOnly public java.util.Map<java.lang.String,java.lang.Object> getInternalVariables()
HashMap
holding all of the variables.HashMap
.public int getNumVariables()
@NotNull public java.util.Iterator getSessionVariableKeysIterator()
Iterator
over which session variables
can be seen.Iterator
.@NotNull public java.util.Iterator getSessionVariableKeysIteratorSorted()
Iterator
over which sorted session variables
can be accessed.Iterator
.@NotNull public java.lang.String getAllSessionVariablesAsURLEncodedString()
public void saveVariables(@NotNull java.lang.String fileToSaveTo) throws java.io.IOException
fileToSaveTo
- The file to save the variables to.java.io.IOException
- On error writing to the filepublic void loadVariables(@NotNull java.lang.String fileToReadFrom) throws java.io.IOException
fileToReadFrom
- The file to read the variables from.java.io.IOException
- On error reading the file@Nullable public java.lang.String resolveVariables(@Nullable java.lang.String value)
String
attempts to resolve any variables.value
- The String
containing the variables.public void dropCachedDataSetTables()
DataSet
objects, and, if they've been
cached, drops their corresponding tables.