Package ghidra.app.script
Class JavaScriptProvider
- java.lang.Object
-
- ghidra.app.script.GhidraScriptProvider
-
- ghidra.app.script.JavaScriptProvider
-
- All Implemented Interfaces:
ExtensionPoint
,java.lang.Comparable<GhidraScriptProvider>
public class JavaScriptProvider extends GhidraScriptProvider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ghidra.util.classfinder.ExtensionPoint
ExtensionPoint.Exclude, ExtensionPoint.Util
-
-
Constructor Summary
Constructors Constructor Description JavaScriptProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
compile(ResourceFile sourceFile, java.io.PrintWriter writer)
void
createNewScript(ResourceFile newScript, java.lang.String category)
Creates a new script using the specified file.boolean
deleteScript(ResourceFile scriptSource)
Deletes the script file and unloads the script from the script manager.protected java.io.File
getClassFile(ResourceFile sourceFile, java.lang.String className)
Gets the class file corresponding to the given source file and class name.java.lang.String
getCommentCharacter()
Returns the comment character.java.lang.String
getDescription()
Returns a description for this type of script.java.lang.String
getExtension()
Returns the file extension for this type of script.GhidraScript
getScriptInstance(ResourceFile sourceFile, java.io.PrintWriter writer)
Returns a GhidraScript instance for the specified source file.protected boolean
needsCompile(ResourceFile sourceFile, java.io.File classFile)
protected boolean
scriptCompiledExternally(java.io.File classFile)
-
Methods inherited from class ghidra.app.script.GhidraScriptProvider
compareTo, equals, hashCode, toString, writeBody, writeHeader
-
-
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
Description copied from class:GhidraScriptProvider
Returns a description for this type of script.- Specified by:
getDescription
in classGhidraScriptProvider
- Returns:
- a description for this type of script
-
getExtension
public java.lang.String getExtension()
Description copied from class:GhidraScriptProvider
Returns the file extension for this type of script. For example, ".java" or ".py".- Specified by:
getExtension
in classGhidraScriptProvider
- Returns:
- the file extension for this type of script
-
deleteScript
public boolean deleteScript(ResourceFile scriptSource)
Description copied from class:GhidraScriptProvider
Deletes the script file and unloads the script from the script manager.- Overrides:
deleteScript
in classGhidraScriptProvider
- Parameters:
scriptSource
- the script source file- Returns:
- true if the script was completely deleted and cleaned up
-
getScriptInstance
public GhidraScript getScriptInstance(ResourceFile sourceFile, java.io.PrintWriter writer) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
Description copied from class:GhidraScriptProvider
Returns a GhidraScript instance for the specified source file.- Specified by:
getScriptInstance
in classGhidraScriptProvider
- Parameters:
sourceFile
- the source filewriter
- the print writer to write warning/error messages- Returns:
- a GhidraScript instance for the specified source file
- Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
-
getClassFile
protected java.io.File getClassFile(ResourceFile sourceFile, java.lang.String className)
Gets the class file corresponding to the given source file and class name. If the class is in a package, the class name should include the full package name.- Parameters:
sourceFile
- The class's source file.className
- The class's name (including package if applicable).- Returns:
- The class file corresponding to the given source file and class name.
-
needsCompile
protected boolean needsCompile(ResourceFile sourceFile, java.io.File classFile)
-
scriptCompiledExternally
protected boolean scriptCompiledExternally(java.io.File classFile)
-
compile
protected boolean compile(ResourceFile sourceFile, java.io.PrintWriter writer) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
createNewScript
public void createNewScript(ResourceFile newScript, java.lang.String category) throws java.io.IOException
Description copied from class:GhidraScriptProvider
Creates a new script using the specified file.- Specified by:
createNewScript
in classGhidraScriptProvider
- Parameters:
newScript
- the new script filecategory
- the script category- Throws:
java.io.IOException
- if an error occurs writing the file
-
getCommentCharacter
public java.lang.String getCommentCharacter()
Description copied from class:GhidraScriptProvider
Returns the comment character. For example, "//" or "#".- Specified by:
getCommentCharacter
in classGhidraScriptProvider
- Returns:
- the comment character
-
-