org.crsh.shell.impl.command.pipeline
Class CommandInvokerAdapter<C,P,CONSUMER extends CommandContext<? super P>>

java.lang.Object
  extended by org.crsh.shell.impl.command.pipeline.CommandInvokerAdapter<C,P,CONSUMER>
All Implemented Interfaces:
Appendable, CommandContext<Object>, RuntimeContext, InteractionContext, Consumer<Object>, Producer<P,CONSUMER>, Screenable, ScreenContext

 class CommandInvokerAdapter<C,P,CONSUMER extends CommandContext<? super P>>
extends Object
implements Consumer<Object>, Producer<P,CONSUMER>, CommandContext<Object>

Author:
Julien Viet

Field Summary
private  ScreenContextConsumer adapter
          .
private  boolean charSequenceConsumer
          .
private  boolean clsConsumer
          .
(package private)  CommandInvoker<C,P> command
          .
private  Class<C> consumedType
          .
protected  CONSUMER consumer
          .
private  Class<P> producedType
          .
private  ScreenContext screenContext
          .
private  boolean styleConsumer
          .
 
Constructor Summary
CommandInvokerAdapter(CommandInvoker<C,P> command, Class<C> consumedType, Class<P> producedType)
           
 
Method Summary
 Appendable append(char c)
           
 Appendable append(CharSequence s)
           
 Appendable append(CharSequence csq, int start, int end)
           
 Screenable append(Style style)
           
 void close()
          Close the producer.
 Screenable cls()
           
 void flush()
          Flush the stream.
 Map<String,Object> getAttributes()
          Returns the current attributes.
 Class<Object> 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.
 void open(CONSUMER consumer)
          Open the producer with the specified consumer.
 void provide(Object element)
          Provide an element.
 String readLine(String msg, boolean echo)
          Display a message and read a line on the console, this method call can be blocking until the user provides a value.
 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

command

final CommandInvoker<C,P> command
.


consumer

protected CONSUMER extends CommandContext<? super P> consumer
.


consumedType

private final Class<C> consumedType
.


producedType

private final Class<P> producedType
.


adapter

private ScreenContextConsumer adapter
.


screenContext

private ScreenContext screenContext
.


charSequenceConsumer

private final boolean charSequenceConsumer
.


styleConsumer

private final boolean styleConsumer
.


clsConsumer

private final boolean clsConsumer
.

Constructor Detail

CommandInvokerAdapter

CommandInvokerAdapter(CommandInvoker<C,P> command,
                      Class<C> consumedType,
                      Class<P> producedType)
Method Detail

takeAlternateBuffer

public 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 ScreenContext.flush() method is invoked.

Specified by:
takeAlternateBuffer in interface InteractionContext
Returns:
true if the alternate buffer is shown
Throws:
IOException

releaseAlternateBuffer

public 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 ScreenContext.flush() method is invoked.

Specified by:
releaseAlternateBuffer in interface InteractionContext
Returns:
true if the usual buffer is shown
Throws:
IOException

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
Parameters:
propertyName - the property name
Returns:
the property value

readLine

public String readLine(String msg,
                       boolean echo)
                throws IOException,
                       InterruptedException
Description copied from interface: InteractionContext
Display a message and read a line on the console, this method call can be blocking until the user provides a value. If no line can be read then null is returned.

Specified by:
readLine in interface InteractionContext
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
Throws:
IOException - any io exception
InterruptedException - the thread was interrupted while waiting for the user value

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

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
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
Returns:
the term height

open

public void open(CONSUMER consumer)
          throws Exception
Description copied from interface: Producer
Open the producer with the specified consumer.

Specified by:
open in interface Producer<P,CONSUMER extends CommandContext<? super P>>
Parameters:
consumer - the consumer
Throws:
Exception - any exception

getConsumedType

public 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

getProducedType

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

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

provide

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

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

append

public Appendable append(char c)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(CharSequence s)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(CharSequence csq,
                         int start,
                         int end)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Screenable append(Style style)
                  throws IOException
Specified by:
append in interface Screenable
Throws:
IOException

cls

public Screenable cls()
               throws IOException
Specified by:
cls in interface Screenable
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: Consumer
Flush the stream.

Specified by:
flush in interface Consumer<Object>
Specified by:
flush in interface ScreenContext
Throws:
IOException - any io exception

close

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

Specified by:
close in interface CommandContext<Object>
Specified by:
close in interface Producer<P,CONSUMER extends CommandContext<? super P>>
Throws:
Exception - any exception


Copyright © 2015 eXo Platform SAS. All Rights Reserved.