org.crsh.command
Class InvocationContextImpl<P>

java.lang.Object
  extended by org.crsh.command.InvocationContextImpl<P>
All Implemented Interfaces:
Closeable, Flushable, CommandContext<P>, InvocationContext<P>, RuntimeContext, Consumer<P>, InteractionContext, ScreenContext

public final class InvocationContextImpl<P>
extends Object
implements InvocationContext<P>


Field Summary
private  CommandContext<P> commandContext
          .
private  RenderPrintWriter writer
          .
 
Constructor Summary
InvocationContextImpl(CommandContext<P> commandContext)
           
 
Method Summary
 void close()
           
 void flush()
           
 Map<String,Object> getAttributes()
          Returns the current attributes.
 Class<P> getConsumedType()
          Returns the class of the element generic type.
 int getHeight()
          Returns the screen height in chars.
 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.
 RenderPrintWriter getWriter()
          Returns the writer for the output.
 boolean isPiped()
           
 InvocationContextImpl<P> leftShift(Object o)
           
 void provide(P 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.
 CommandInvoker<?,?> resolve(String s)
          Resolve a command invoker for the specified command line.
 boolean takeAlternateBuffer()
          Take control of the alternate buffer.
 void write(Chunk chunk)
          Write a chunk to the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandContext

private final CommandContext<P> commandContext
.


writer

private RenderPrintWriter writer
.

Constructor Detail

InvocationContextImpl

public InvocationContextImpl(CommandContext<P> commandContext)
Method Detail

isPiped

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

getWriter

public RenderPrintWriter getWriter()
Description copied from interface: InvocationContext
Returns the writer for the output.

Specified by:
getWriter in interface InvocationContext<P>
Returns:
the writer

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

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

resolve

public CommandInvoker<?,?> resolve(String s)
                            throws ScriptException,
                                   IOException
Description copied from interface: InvocationContext
Resolve a command invoker for the specified command line.

Specified by:
resolve in interface InvocationContext<P>
Parameters:
s - the command line
Returns:
the command invoker
Throws:
ScriptException - any script exception
IOException - any io exception

getConsumedType

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

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

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)
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
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
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

write

public void write(Chunk chunk)
           throws IOException
Description copied from interface: ScreenContext
Write a chunk to the screen.

Specified by:
write in interface ScreenContext
Parameters:
chunk - the chunk
Throws:
IOException - any io exception

provide

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

Specified by:
provide in interface Consumer<P>
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 IOException
Specified by:
close in interface Closeable
Throws:
IOException

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

leftShift

public InvocationContextImpl<P> leftShift(Object o)
                                   throws IOException
Throws:
IOException


Copyright © 2013 eXo Platform SAS. All Rights Reserved.