org.crsh.command
Class GroovyScriptCommand

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by groovy.lang.Script
          extended by org.crsh.command.GroovyScriptCommand
All Implemented Interfaces:
groovy.lang.GroovyObject, CommandInvoker<Object,Object>, ShellCommand

public abstract class GroovyScriptCommand
extends groovy.lang.Script
implements ShellCommand, CommandInvoker<Object,Object>


Field Summary
private  String[] args
          .
protected  CommandContext context
          The current context.
protected  RenderPrintWriter out
          The current output.
private  LinkedList<InvocationContext<?>> stack
          .
 
Constructor Summary
protected GroovyScriptCommand()
           
 
Method Summary
 CommandCompletion complete(CommandContext context, String line)
          Provide completions for the specified arguments.
 String describe(String line, DescriptionFormat mode)
          Returns a description of the command or null if none can be found.
 Class<Object> getConsumedType()
          Returns the class of the consumed type.
 Class<Object> getProducedType()
          Returns the class of the produced type.
 Object getProperty(String property)
           
 PipeCommand<Object> invoke(InvocationContext<Object> context)
          Invoke a command
 Object invokeMethod(String name, Object args)
           
 InvocationContext<?> peekContext()
           
 InvocationContext<?> popContext()
           
 void pushContext(InvocationContext<?> context)
           
 CommandInvoker<?,?> resolveInvoker(String line)
          Provides an invoker for the command line specified as a command line to parse.
 CommandInvoker<?,?> resolveInvoker(String name, Map<String,?> options, List<?> args)
          Provides an invoker for the command line specified under the form of a command, options and arguments.
 
Methods inherited from class groovy.lang.Script
evaluate, evaluate, getBinding, print, printf, printf, println, println, run, run, setBinding, setProperty
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

private LinkedList<InvocationContext<?>> stack
.


context

protected CommandContext context
The current context.


out

protected RenderPrintWriter out
The current output.


args

private String[] args
.

Constructor Detail

GroovyScriptCommand

protected GroovyScriptCommand()
Method Detail

pushContext

public final void pushContext(InvocationContext<?> context)
                       throws NullPointerException
Throws:
NullPointerException

popContext

public final InvocationContext<?> popContext()

peekContext

public final InvocationContext<?> peekContext()

getProducedType

public final Class<Object> getProducedType()
Description copied from interface: CommandInvoker
Returns the class of the produced type.

Specified by:
getProducedType in interface CommandInvoker<Object,Object>
Returns:
the produced type

getConsumedType

public final Class<Object> getConsumedType()
Description copied from interface: CommandInvoker
Returns the class of the consumed type.

Specified by:
getConsumedType in interface CommandInvoker<Object,Object>
Returns:
the consumed type

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject
Overrides:
invokeMethod in class groovy.lang.Script

getProperty

public final Object getProperty(String property)
Specified by:
getProperty in interface groovy.lang.GroovyObject
Overrides:
getProperty in class groovy.lang.Script

complete

public final CommandCompletion complete(CommandContext context,
                                        String line)
Description copied from interface: ShellCommand
Provide completions for the specified arguments.

Specified by:
complete in interface ShellCommand
Parameters:
context - the command context
line - the original command line arguments
Returns:
the completions

describe

public String describe(String line,
                       DescriptionFormat mode)
Description copied from interface: ShellCommand
Returns a description of the command or null if none can be found.

Specified by:
describe in interface ShellCommand
Parameters:
line - the usage line
mode - the description mode
Returns:
the description

invoke

public final PipeCommand<Object> invoke(InvocationContext<Object> context)
                                 throws ScriptException
Description copied from interface: CommandInvoker
Invoke a command

Specified by:
invoke in interface CommandInvoker<Object,Object>
Parameters:
context - the command execution context
Returns:
the related pipe
Throws:
ScriptException - any script exception

resolveInvoker

public final CommandInvoker<?,?> resolveInvoker(String line)
Description copied from interface: ShellCommand
Provides an invoker for the command line specified as a command line to parse.

Specified by:
resolveInvoker in interface ShellCommand
Parameters:
line - the command line arguments
Returns:
the command

resolveInvoker

public CommandInvoker<?,?> resolveInvoker(String name,
                                          Map<String,?> options,
                                          List<?> args)
Description copied from interface: ShellCommand
Provides an invoker for the command line specified under the form of a command, options and arguments.

Specified by:
resolveInvoker in interface ShellCommand
Parameters:
name - the command name, might be null
options - the options
args - the arguments
Returns:
the command


Copyright © 2012 eXo Platform SAS. All Rights Reserved.