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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<EdtScript>
Load scripts from the given path (file or directory).static Collection<EdtScript>
Load scripts from the given path (file or directory).static EdtScript
Creates a new instance ofEdtScript
(without a contributor) from the given file.getData()
getHelp()
Returns help for this script.void
overwriteWith
(EdtScript script) Overwrites this script with the given script.void
setupSession
(org.apache.felix.service.command.CommandSession session, List<?> arguments) Sets up session parameters for this script execution.toString()
-
Field Details
-
SCRIPT_FILE_EXTENSION
- See Also:
-
SCRIPT_FILE_PREDICATE
-
-
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 benull
.contributor
- script's contributor. May benull
for scripts loaded from the file system.content
- script content, cannot benull
.namespace
- namespace under which the script is registered. May benull
or blank, in which casethe default namespace
is assumed.
-
-
Method Details
-
from
Creates a new instance ofEdtScript
(without a contributor) from the given file.- Parameters:
path
- file to read, cannot benull
.namespace
- namespace under which the script is registered. May benull
or blank, in which casethe default namespace
is assumed.- Returns:
- script, never
null
. The script'scontributor
will benull
. - 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 benull
. 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 benull
or blank, in which casethe 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 benull
. 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 benull
or blank, in which casethe default namespace
is assumed.pathPredicate
- path predicate to apply before loading scripts, cannot benull
.- 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 interfaceorg.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 benull
.script
- script to be executed, cannot benull
.arguments
- script arguments, cannot benull
.
-
getData
-
getHelp
Returns help for this script.- Returns:
- help for this script. Never
null
.
-
overwriteWith
Overwrites this script with the given script.- Parameters:
script
- script to overwrite with, cannot benull
.
-
toString
-