public class Script extends java.lang.Object implements Deleteable, java.lang.Comparable, java.awt.datatransfer.Transferable, Folderable, Uniqueable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_LANGUAGE
The default language.
|
(package private) static java.awt.datatransfer.DataFlavor[] |
flavors |
static java.awt.datatransfer.DataFlavor |
INFO_FLAVOR
Drag 'n drop stuff.
|
static java.lang.String |
LANGUAGE_GROOVY |
static java.lang.String |
LANGUAGE_INTERPRETED_JAVA
Possible values for the language.
|
static java.lang.String |
LANGUAGE_JAVASCRIPT |
static java.lang.String |
LANGUAGE_JSCRIPT |
static java.lang.String |
LANGUAGE_PERL |
static java.lang.String |
LANGUAGE_PYTHON |
static java.lang.String |
LANGUAGE_VBSCRIPT |
static org.apache.log4j.Logger |
log
Used for logging.
|
Constructor and Description |
---|
Script()
Required by castor.
|
Script(int scriptID)
Generates a new Script based on the ID.
|
Script(int scriptID,
java.lang.String name,
java.lang.String scriptText,
java.lang.String language,
int folderID,
boolean overwriteOnImport)
Generates a new Script.
|
Script(java.lang.String name)
Generates a new Script.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object object)
Required by the
Comparable interface. |
void |
delete()
Deletes the script from the database.
|
void |
dumpToLog()
Dumps the script to the log.
|
boolean |
equals(java.lang.Object object)
Overriding equals...
|
static javax.swing.JComboBox |
getComboBoxForScripts(java.util.Set<Script> hsScripts)
Takes a
HashSet of Script objects and returns a JComboBox representing them all. |
java.lang.String |
getDateExported()
Gets the date the scraping session was exported.
|
Folder |
getFolder()
Gets the folder containing this object.
|
int |
getID()
Gets the ID of the script.
|
java.lang.String |
getIdentifier()
Gets the identifier for this object.
|
java.lang.String |
getLanguage()
Gets the language.
|
java.lang.String |
getName()
Gets the name.
|
boolean |
getNeedsToBeSaved()
Indicates whether or not the object needs to be saved.
|
javax.swing.tree.DefaultMutableTreeNode |
getNode()
Gets the node representing this scraping file.
|
boolean |
getOverwriteOnImport()
Indicates whether or not this script should be overwritten on import.
|
static java.lang.String |
getScriptIdentifier(java.lang.String languageName)
Given a script language name, gets its BSF identifier.
|
java.lang.String |
getScriptText()
Gets the text of the script to be run.
|
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor df) |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors() |
static java.lang.Object[] |
getValidScriptLanguages()
Gets an array of valid script languages.
|
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor df)
Transferable methods.
|
void |
moveToNewFolder(Folder folder)
Moves the object to a new folder.
|
static boolean |
readerPointsToImportableScript(java.io.Reader reader)
Indicates whether or not the given reader points to an importable script.
|
void |
removeFromFolder()
Removes the object from its current folder.
|
void |
save()
Saves the script to the database.
|
void |
setDateExported(java.lang.String date)
Sets the date the scraping session was exported.
|
void |
setFolder(Folder folder)
Sets the folder containing this object.
|
void |
setID(int scriptID)
Sets the ID of the script.
|
void |
setIdentifier(java.lang.String identifier)
Sets the identifier for this object.
|
void |
setLanguage(java.lang.String language)
Sets the language.
|
void |
setName(java.lang.String name)
Sets the name.
|
void |
setNeedsToBeSaved(boolean needsToBeSaved)
Sets whether or not the object needs to be saved.
|
void |
setNode(javax.swing.tree.DefaultMutableTreeNode node)
Sets the node representing this scraping file.
|
void |
setOverwriteOnImport(boolean overwriteOnImport)
Determines whether or not this script should be overwritten on import.
|
void |
setScriptText(java.lang.String scriptText)
Gets the text of the script to be run.
|
java.lang.String |
toString()
Overridden so that the name appears as the title in the main tree.
|
static Script |
unmarshalScript(java.io.Reader reader)
Unmarshals a script from the given reader.
|
public static org.apache.log4j.Logger log
public static final java.lang.String LANGUAGE_INTERPRETED_JAVA
public static final java.lang.String LANGUAGE_JAVASCRIPT
public static final java.lang.String LANGUAGE_PYTHON
public static final java.lang.String LANGUAGE_JSCRIPT
public static final java.lang.String LANGUAGE_VBSCRIPT
public static final java.lang.String LANGUAGE_PERL
public static final java.lang.String LANGUAGE_GROOVY
public static final java.lang.String DEFAULT_LANGUAGE
public static final java.awt.datatransfer.DataFlavor INFO_FLAVOR
@NotNull static java.awt.datatransfer.DataFlavor[] flavors
public Script()
public Script(@Nullable java.lang.String name)
name
- A name to identify the file.public Script(int scriptID)
scriptID
- The ID of the script.public Script(int scriptID, @Nullable java.lang.String name, java.lang.String scriptText, @Nullable java.lang.String language, int folderID, boolean overwriteOnImport)
scriptID
- The ID of the script.name
- A name to identify the file.scriptText
- The text of the script to be run.language
- The scripting language the script is written in.folderID
- The ID of the folder containing the object.overwriteOnImport
- Indicates whether or not the script should be overwritten on import.@Nullable public static java.lang.String getScriptIdentifier(@Nullable java.lang.String languageName)
languageName
- The name of the language.public boolean getOverwriteOnImport()
public void setOverwriteOnImport(boolean overwriteOnImport)
overwriteOnImport
- A boolean.@NotNull public static Script unmarshalScript(java.io.Reader reader) throws org.exolab.castor.mapping.MappingException, java.io.IOException, org.exolab.castor.xml.ValidationException, org.exolab.castor.xml.MarshalException
reader
- A Reader
stream containing the script to be unmarshalled.org.exolab.castor.mapping.MappingException
java.io.IOException
org.exolab.castor.xml.ValidationException
org.exolab.castor.xml.MarshalException
@Nullable public static java.lang.Object[] getValidScriptLanguages()
@Nullable public java.lang.String getName()
public void setName(@Nullable java.lang.String name)
name
- The name.public java.lang.String getScriptText()
public void setScriptText(java.lang.String scriptText)
scriptText
- The text of the script.@Nullable public Folder getFolder()
getFolder
in interface Folderable
public void setFolder(@Nullable Folder folder)
setFolder
in interface Folderable
folder
- The folder.public void removeFromFolder()
removeFromFolder
in interface Folderable
public void moveToNewFolder(Folder folder)
moveToNewFolder
in interface Folderable
folder
- The Folder
to which the object should be moved.@Nullable public java.lang.String getLanguage()
public void setLanguage(@Nullable java.lang.String language)
language
- The language.public void setNode(@Nullable javax.swing.tree.DefaultMutableTreeNode node)
node
- A DefaultMutableTreeNode
.@Nullable public javax.swing.tree.DefaultMutableTreeNode getNode()
DefaultMutableTreeNode
.public int getID()
public void setID(int scriptID)
scriptID
- The ID.@Nullable public java.lang.String toString()
toString
in class java.lang.Object
@NotNull public static javax.swing.JComboBox getComboBoxForScripts(@NotNull java.util.Set<Script> hsScripts)
HashSet
of Script
objects and returns a JComboBox
representing them all.hsScripts
- A HashSet
of Script
objects.JComboBox
.public void save()
public void delete()
delete
in interface Deleteable
@Nullable public java.lang.String getDateExported()
public void setDateExported(@Nullable java.lang.String date)
date
- The date as a string.public int compareTo(java.lang.Object object)
Comparable
interface.compareTo
in interface java.lang.Comparable
object
- The object to compare to.public boolean equals(@Nullable java.lang.Object object)
equals
in class java.lang.Object
object
- The object we're comparing.public static boolean readerPointsToImportableScript(@NotNull java.io.Reader reader)
reader
- A Reader
used to reader the characters.public boolean isDataFlavorSupported(@NotNull java.awt.datatransfer.DataFlavor df)
isDataFlavorSupported
in interface java.awt.datatransfer.Transferable
@NotNull public java.lang.Object getTransferData(@NotNull java.awt.datatransfer.DataFlavor df) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
getTransferData
in interface java.awt.datatransfer.Transferable
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
@NotNull public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
getTransferDataFlavors
in interface java.awt.datatransfer.Transferable
public boolean getNeedsToBeSaved()
public void setNeedsToBeSaved(boolean needsToBeSaved)
needsToBeSaved
- A boolean.@Nullable public java.lang.String getIdentifier()
Uniqueable
getIdentifier
in interface Uniqueable
public void setIdentifier(@Nullable java.lang.String identifier)
Uniqueable
setIdentifier
in interface Uniqueable
identifier
- The identifier.public void dumpToLog()