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, Closeable, Flushable, CommandInvoker<Object,Object>, ShellCommand, Consumer<Object>, Filter<Object,Object,CommandContext<Object>>, Producer<Object,CommandContext<Object>>

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


Field Summary
private  String[] args
          .
protected  InvocationContext context
          The current context.
protected  RenderPrintWriter out
          The current output.
private  boolean piped
          .
private  LinkedList<InvocationContext<?>> stack
          .
 
Constructor Summary
protected GroovyScriptCommand()
           
 
Method Summary
 void close()
          Close the producer.
 CompletionMatch complete(RuntimeContext 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.
 void execute(String s)
           
 void flush()
           
 Class<Object> getConsumedType()
          Returns the class of the element generic type.
 Class<Object> getProducedType()
          Returns the class of the produced type.
 Object getProperty(String property)
           
 Object invokeMethod(String name, Object args)
           
 void open(CommandContext<Object> consumer)
          Open the producer with the specified consumer.
 InvocationContext<?> peekContext()
           
 InvocationContext<?> popContext()
           
 void provide(Object element)
          Provide an element.
 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 InvocationContext context
The current context.


out

protected RenderPrintWriter out
The current output.


args

private String[] args
.


piped

private boolean piped
.

Constructor Detail

GroovyScriptCommand

protected GroovyScriptCommand()
Method Detail

pushContext

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

popContext

public final InvocationContext<?> popContext()

execute

public final void execute(String s)
                   throws ScriptException,
                          IOException
Throws:
ScriptException
IOException

peekContext

public final InvocationContext<?> peekContext()

getProducedType

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

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

getConsumedType

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

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

invokeMethod

public final 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 CompletionMatch complete(RuntimeContext 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 final 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

open

public final void open(CommandContext<Object> consumer)
Description copied from interface: Producer
Open the producer with the specified consumer.

Specified by:
open in interface Producer<Object,CommandContext<Object>>
Parameters:
consumer - the consumer

provide

public final void provide(Object element)
                   throws IOException
Description copied from interface: Consumer
Provide an element.

Specified by:
provide in interface Consumer<Object>
Parameters:
element - the provided element
Throws:
IOException

flush

public final void flush()
                 throws IOException
Specified by:
flush in interface Flushable
Throws:
IOException

close

public final void close()
Description copied from interface: Producer
Close the producer.

Specified by:
close in interface Closeable
Specified by:
close in interface Producer<Object,CommandContext<Object>>

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 final 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 © 2014 eXo Platform SAS. All Rights Reserved.