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

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

 class Pipe<C,P>
extends Object
implements Filter<C,P,CommandContext<P>>, CommandContext<C>

Author:
Julien Viet

Field Summary
(package private)  Filter<C,P,InteractionContext<P>> command
          .
protected  CommandContext<P> context
          .
 
Constructor Summary
Pipe(Filter<C,P,InteractionContext<P>> command)
           
 
Method Summary
 void close()
          Close the producer.
 void flush()
           
 Map<String,Object> getAttributes()
          Returns the current attributes.
 Class<C> getConsumedType()
          Returns the class of the element generic 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.
 Map<String,Object> getSession()
          Returns the current session.
 int getWidth()
          Returns the screen width in chars.
 boolean isPiped()
           
 void open(CommandContext<P> consumer)
          Open the producer with the specified consumer.
 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.
 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

context

protected CommandContext<P> context
.


command

final Filter<C,P,InteractionContext<P>> command
.

Constructor Detail

Pipe

Pipe(Filter<C,P,InteractionContext<P>> command)
Method Detail

takeAlternateBuffer

public final boolean takeAlternateBuffer()
                                  throws IOException
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
Throws:
IOException

releaseAlternateBuffer

public final boolean releaseAlternateBuffer()
                                     throws IOException
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
Throws:
IOException

getProperty

public final 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 final 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 final 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 final 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

getSession

public Map<String,Object> getSession()
Description copied from interface: RuntimeContext
Returns the current session.

Specified by:
getSession in interface RuntimeContext
Returns:
the session map

getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: RuntimeContext
Returns the current attributes.

Specified by:
getAttributes in interface RuntimeContext
Returns:
the attributes map

isPiped

public boolean isPiped()
Specified by:
isPiped in interface CommandContext<C>

getProducedType

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

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

getConsumedType

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

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

open

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

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

provide

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

Specified by:
provide in interface Consumer<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,
                  IOException
Description copied from interface: Producer
Close the producer.

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


Copyright © 2014 eXo Platform SAS. All Rights Reserved.