Class EdtScript

java.lang.Object
com.e1c.g5.v8.dt.internal.cli.api.EdtScript
All Implemented Interfaces:
ICliCommand, org.apache.felix.service.command.Function

public class EdtScript extends Object implements org.apache.felix.service.command.Function, ICliCommand
Command provider for CLI scripts.
  • Field Details

  • Constructor Details

    • EdtScript

      public EdtScript(String path, org.eclipse.core.runtime.IContributor contributor, String content, String namespace)
      Creates a new instance.
      Parameters:
      path - scipt path. Cannot be null.
      contributor - script's contributor. May be null for scripts loaded from the file system.
      content - script content, cannot be null.
      namespace - namespace under which the script is registered. May be null or blank, in which case the default namespace is assumed.
  • Method Details

    • from

      public static EdtScript from(Path path, String namespace) throws IOException
      Creates a new instance of EdtScript (without a contributor) from the given file.
      Parameters:
      path - file to read, cannot be null.
      namespace - namespace under which the script is registered. May be null or blank, in which case the default namespace is assumed.
      Returns:
      script, never null. The script's contributor will be null.
      Throws:
      IOException - if failed to access file, or the file's encoding is not supported.
    • from

      public static Collection<EdtScript> from(Path path, int maxDepth, String namespace) throws IOException
      Load scripts from the given path (file or directory).

      The same as from(path, maxDepth, EdtScript.SCRIPT_FILE_PREDICATE).

      Parameters:
      path - path to load from, may be file or directory. Cannot be null. The file or directory must exist.
      maxDepth - if path is a directory, max depth of traversing it.
      namespace - namespace under which the scripts are registered. May be null or blank, in which case the default namespace is assumed.
      Returns:
      a collection of loaded scripts, never null.
      Throws:
      IOException - on I/O error.
    • from

      public static Collection<EdtScript> from(Path path, int maxDepth, String namespace, Predicate<Path> pathPredicate) throws IOException
      Load scripts from the given path (file or directory).
      Parameters:
      path - path to load from, may be file or directory. Cannot be null. The file or directory must exist.
      maxDepth - if path is a directory, max depth of traversing it.
      namespace - namespace under which the scripts are registered. May be null or blank, in which case the default namespace is assumed.
      pathPredicate - path predicate to apply before loading scripts, cannot be null.
      Returns:
      a collection of loaded scripts, never null.
      Throws:
      IOException - on I/O error.
    • execute

      public Object execute(org.apache.felix.service.command.CommandSession parentSession, List<Object> arguments) throws Exception
      Specified by:
      execute in interface org.apache.felix.service.command.Function
      Throws:
      Exception
    • setupSession

      public void setupSession(org.apache.felix.service.command.CommandSession session, List<?> arguments)
      Sets up session parameters for this script execution.
      Parameters:
      session - command session, cannot be null.
      script - script to be executed, cannot be null.
      arguments - script arguments, cannot be null.
    • getData

      public ICliScriptData getData()
    • getHelp

      public String getHelp()
      Returns help for this script.
      Returns:
      help for this script. Never null.
    • overwriteWith

      public void overwriteWith(EdtScript script)
      Overwrites this script with the given script.
      Parameters:
      script - script to overwrite with, cannot be null.
    • toString

      public String toString()
      Overrides:
      toString in class Object