org.crsh.shell.impl.command
Class InvokerPipeFilter<C,P>

java.lang.Object
  extended by org.crsh.shell.impl.command.InvokerPipeFilter<C,P>
All Implemented Interfaces:
Closeable, Flushable, Consumer<C>, Filter<C,P>, InteractionContext<C>, Pipe<C>, Producer<P>, ProducerConsumer<C,P>, ProducerContext<C>, ScreenContext<C>

 class InvokerPipeFilter<C,P>
extends Object
implements Filter<C,P>

A pipe filter that invokes a command through a CommandInvoker.


Field Summary
(package private)  ProducerConsumer<C,P> command
          .
private  ProducerContext<P> context
          .
 
Constructor Summary
InvokerPipeFilter(ProducerConsumer<C,P> command)
           
 
Method Summary
 void close()
          Close the producer.
 void flush()
           
 Class<C> getConsumedType()
          Returns the class of the consumed type.
 int getHeight()
          Returns the screen height in chars.
 Class<P> getProducedType()
          Returns the class of the produced type.
 String getProperty(String propertyName)
          Returns a generic property, usually this property is resolved by the shell client.
 int getWidth()
          Returns the screen width in chars.
 void invoke(InvocationContext<P> context)
           
 void open(ProducerContext<P> context)
          Open the producer with the specified context.
 void provide(C element)
          Provide an element.
 String readLine(String msg, boolean echo)
          Display a message and read a line on the console.
 boolean releaseAlternateBuffer()
          Release control of the alternate buffer.
 void setPiped(boolean piped)
          Set the pipe status.
 boolean takeAlternateBuffer()
          Take control of the alternate buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

command

final ProducerConsumer<C,P> command
.


context

private ProducerContext<P> context
.

Constructor Detail

InvokerPipeFilter

InvokerPipeFilter(ProducerConsumer<C,P> command)
Method Detail

invoke

public void invoke(InvocationContext<P> context)
            throws ScriptException,
                   IOException
Throws:
ScriptException
IOException

setPiped

public void setPiped(boolean piped)
Description copied from interface: Producer
Set the pipe status.

Specified by:
setPiped in interface Producer<P>
Parameters:
piped - the piped status

getProducedType

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

Specified by:
getProducedType in interface Producer<P>
Returns:
the produced type

getConsumedType

public Class<C> getConsumedType()
Description copied from interface: Consumer
Returns the class of the consumed type.

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

takeAlternateBuffer

public boolean takeAlternateBuffer()
Description copied from interface: InteractionContext
Take control of the alternate buffer. When the alternate buffer is already used nothing happens. The buffer switch should occur when then Flushable.flush() method is invoked.

Specified by:
takeAlternateBuffer in interface InteractionContext<C>
Returns:
true if the alternate buffer is shown

releaseAlternateBuffer

public boolean releaseAlternateBuffer()
Description copied from interface: InteractionContext
Release control of the alternate buffer. When the normal buffer is already used nothing happens. The buffer switch should occur when then Flushable.flush() method is invoked.

Specified by:
releaseAlternateBuffer in interface InteractionContext<C>
Returns:
true if the usual buffer is shown

getProperty

public String getProperty(String propertyName)
Description copied from interface: InteractionContext
Returns a generic property, usually this property is resolved by the shell client.

Specified by:
getProperty in interface InteractionContext<C>
Parameters:
propertyName - the property name
Returns:
the property value

readLine

public String readLine(String msg,
                       boolean echo)
Description copied from interface: InteractionContext
Display a message and read a line on the console. If no line can be read then null is returned.

Specified by:
readLine in interface InteractionContext<C>
Parameters:
msg - the message to display before reading a line
echo - wether or not the line read should be echoed when typing
Returns:
the line read

getWidth

public int getWidth()
Description copied from interface: ScreenContext
Returns the screen width in chars. When the value is not positive it means the value could not be determined.

Specified by:
getWidth in interface ScreenContext<C>
Returns:
the term width

getHeight

public int getHeight()
Description copied from interface: ScreenContext
Returns the screen height in chars. When the value is not positive it means the value could not be determined.

Specified by:
getHeight in interface ScreenContext<C>
Returns:
the term height

open

public void open(ProducerContext<P> context)
Description copied from interface: Producer
Open the producer with the specified context.

Specified by:
open in interface Producer<P>
Parameters:
context - the context

provide

public void provide(C element)
             throws IOException
Description copied from interface: Pipe
Provide an element.

Specified by:
provide in interface Pipe<C>
Parameters:
element - the provided element
Throws:
IOException

flush

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

close

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

Specified by:
close in interface Closeable
Specified by:
close in interface Producer<P>
Throws:
ScriptException


Copyright © 2012 eXo Platform SAS. All Rights Reserved.