Package ghidra.app.script

# Class GhidraScriptProvider

java.lang.Object
ghidra.app.script.GhidraScriptProvider

All Implemented Interfaces:
  `ExtensionPoint`, `Comparable<GhidraScriptProvider>`

Direct Known Subclasses:
  `JavaScriptProvider`, `PythonScriptProvider`

public abstract class GhidraScriptProvider extends Object implements ExtensionPoint, Comparable<GhidraScriptProvider>
A provider that can compile, interpret, load, etc., Ghidra Scripts from a given language.

NOTE: ALL GhidraScriptProvider CLASSES MUST END IN "ScriptProvider". If not, the ClassSearcher will not find them.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GhidraScriptProvider()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(GhidraScriptProvider that)`
  `abstract void`
  `createNewScript(ResourceFile newScript, 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.
  `boolean`
  `equals(Object obj)`
  `protected String`
  `fixupName(String scriptName)`
  Deprecated.
  `Pattern`
  `getBlockCommentEnd()`
  Returns a Pattern that matches block comment closings.
  `Pattern`
  `getBlockCommentStart()`
  Returns a Pattern that matches block comment openings.
  `protected String`
  `getCertificationBodyPrefix()`
  Return the prefix for each certification header body line if this file is subject to certification.
  `protected String`
  `getCertifyHeaderEnd()`
  Return the end of certification header line if this file type is subject to certification.
  `protected String`
  `getCertifyHeaderStart()`
  Return the start of certification header line if this file type is subject to certification.
  `abstract String`
  `getCommentCharacter()`
  Returns the comment character.
  `abstract String`
  `getDescription()`
  Returns a description for this type of script.
  `abstract String`
  `getExtension()`
  Returns the file extension for this type of script.
  `abstract GhidraScript`
  `getScriptInstance(ResourceFile sourceFile, PrintWriter writer)`
  Returns a GhidraScript instance for the specified source file.
  `int`
  `hashCode()`
  `String`
  `toString()`
  `protected void`
  `writeBody(PrintWriter writer)`
  Writes the script body template.
  `protected void`
  `writeHeader(PrintWriter writer, String category)`
  Writes the script header.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### GhidraScriptProvider

    public GhidraScriptProvider()

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### compareTo

    public int compareTo(GhidraScriptProvider that)
    Specified by:
      `compareTo` in interface `Comparable<GhidraScriptProvider>`

  - ### deleteScript

    public boolean deleteScript(ResourceFile scriptSource)
    Deletes the script file and unloads the script from the script manager.
    Parameters:
      `scriptSource` - the script source file
    Returns:
      true if the script was completely deleted and cleaned up

  - ### getDescription

    public abstract String getDescription()
    Returns a description for this type of script.
    Returns:
      a description for this type of script

  - ### getExtension

    public abstract String getExtension()
    Returns the file extension for this type of script.

    For example, ".java" or ".py".

    Returns:
      the file extension for this type of script

  - ### getScriptInstance

    public abstract GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer) throws GhidraScriptLoadException
    Returns a GhidraScript instance for the specified source file.
    Parameters:
      `sourceFile` - the source file
      `writer` - the print writer to write warning/error messages. If the error prevents success, throw an exception instead. The caller will print the error.
    Returns:
      a GhidraScript instance for the specified source file
    Throws:
      `GhidraScriptLoadException` - when the script instance cannot be created

  - ### createNewScript

    public abstract void createNewScript(ResourceFile newScript, String category) throws IOException
    Creates a new script using the specified file.
    Parameters:
      `newScript` - the new script file
      `category` - the script category
    Throws:
      `IOException` - if an error occurs writing the file

  - ### getBlockCommentStart

    public Pattern getBlockCommentStart()
    Returns a Pattern that matches block comment openings.

    If block comments are not supported by this provider, then this returns null.

    Returns:
      the Pattern for block comment openings, null if block comments are not supported

  - ### getBlockCommentEnd

    public Pattern getBlockCommentEnd()
    Returns a Pattern that matches block comment closings.

    If block comments are not supported by this provider, then this returns null.

    Returns:
      the Pattern for block comment closings, null if block comments are not supported

  - ### getCommentCharacter

    public abstract String getCommentCharacter()
    Returns the comment character.

    For example, "//" or "#".

    Returns:
      the comment character

  - ### writeHeader

    protected void writeHeader(PrintWriter writer, String category)
    Writes the script header.

    Include a place holder for each meta-data item.

    Parameters:
      `writer` - the print writer
      `category` - the default category

  - ### writeBody

    protected void writeBody(PrintWriter writer)
    Writes the script body template.
    Parameters:
      `writer` - the print writer

  - ### fixupName

    @Deprecated protected String fixupName(String scriptName)
    Deprecated.
    Fixup a script name for searching in script directories.

    This method is part of a poorly specified behavior that is due for future amendment, see `GhidraScriptUtil.fixupName(String)`.

    Parameters:
      `scriptName` - the name of the script, must end with this provider's extension
    Returns:
      a (relative) file path to the corresponding script

  - ### getCertifyHeaderStart

    protected String getCertifyHeaderStart()
    Return the start of certification header line if this file type is subject to certification.
    Returns:
      start of certification header or null if not supported

  - ### getCertificationBodyPrefix

    protected String getCertificationBodyPrefix()
    Return the prefix for each certification header body line if this file is subject to certification.
    Returns:
      certification header body prefix or null if not supported

  - ### getCertifyHeaderEnd

    protected String getCertifyHeaderEnd()
    Return the end of certification header line if this file type is subject to certification.
    Returns:
      end of certification header or null if not supported