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<Void,Void>, ShellCommand

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

This class provides the base class for Groovy scripts. It should not be used directly as it is rather used for configuring a Groovy CompilerConfiguration.setScriptBaseClass(String) class.

Version:
$Revision$
Author:
Julien Viet

Field Summary
private  String[] args
          .
private  CommandContext context
          .
 
Constructor Summary
GroovyScriptCommand()
           
 
Method Summary
 CommandCompletion complete(CommandContext context, String line)
          Provide completions for the specified arguments.
 CommandInvoker<?,?> createInvoker(String line)
          Provides an invoker for the specified arguments.
 String describe(String line, DescriptionFormat mode)
          Returns a description of the command or null if none can be found.
 Class<Void> getConsumedType()
          Returns the class of the consumed type.
 Class<Void> getProducedType()
          Returns the class of the produced type.
 Object getProperty(String property)
           
 void invoke(InvocationContext<Void,Void> context)
          Invoke a command
 Object invokeMethod(String name, Object args)
           
 
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

context

private CommandContext context
.


args

private String[] args
.

Constructor Detail

GroovyScriptCommand

public GroovyScriptCommand()
Method Detail

getProducedType

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

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

getConsumedType

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

Specified by:
getConsumedType in interface CommandInvoker<Void,Void>
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 void invoke(InvocationContext<Void,Void> context)
                  throws ScriptException
Description copied from interface: CommandInvoker
Invoke a command

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

createInvoker

public final CommandInvoker<?,?> createInvoker(String line)
Description copied from interface: ShellCommand
Provides an invoker for the specified arguments.

Specified by:
createInvoker in interface ShellCommand
Parameters:
line - the command line arguments
Returns:
the command to provide


Copyright © 2012 eXo Platform SAS. All Rights Reserved.