org.crsh.shell.impl.command
Class InvocationContextImpl<P>

java.lang.Object
  extended by org.crsh.shell.impl.command.AbstractInvocationContext<P>
      extended by org.crsh.shell.impl.command.InvocationContextImpl<P>
All Implemented Interfaces:
Appendable, CommandContext<P>, InvocationContext<P>, RuntimeContext, InteractionContext, Consumer<P>, Screenable, ScreenContext

public final class InvocationContextImpl<P>
extends AbstractInvocationContext<P>


Field Summary
private static int CLOSED
          .
private  CommandContext<P> commandContext
          .
private static int FLUSHED
          .
(package private)  int status
          .
private  RenderPrintWriter writer
          .
private static int WRITTEN
          .
 
Constructor Summary
InvocationContextImpl(CommandContext<P> commandContext)
           
 
Method Summary
 Screenable append(char c)
           
 Screenable append(CharSequence s)
           
 Screenable append(CharSequence csq, int start, int end)
           
 Screenable append(Style style)
           
 void close()
           
 Screenable cls()
           
 void flush()
          Flush the stream.
 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.
 void provide(P 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.
 CommandInvoker<?,?> resolve(String s)
          Resolve a command invoker for the specified command line.
 boolean takeAlternateBuffer()
          Take control of the alternate buffer.
 
Methods inherited from class org.crsh.shell.impl.command.AbstractInvocationContext
leftShift
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRITTEN

private static final int WRITTEN
.

See Also:
Constant Field Values

FLUSHED

private static final int FLUSHED
.

See Also:
Constant Field Values

CLOSED

private static final int CLOSED
.

See Also:
Constant Field Values

commandContext

private final CommandContext<P> commandContext
.


writer

private RenderPrintWriter writer
.


status

int status
.

Constructor Detail

InvocationContextImpl

public InvocationContextImpl(CommandContext<P> commandContext)
Method Detail

getWriter

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

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

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.

Returns:
true if the usual buffer is shown
Throws:
IOException

resolve

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

Parameters:
s - the command line
Returns:
the command invoker
Throws:
CommandException - any command exception

getConsumedType

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

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.

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.

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

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.

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.

Returns:
the term height

append

public Screenable append(CharSequence s)
                  throws IOException
Throws:
IOException

append

public Screenable append(char c)
                  throws IOException
Throws:
IOException

append

public Screenable append(CharSequence csq,
                         int start,
                         int end)
                  throws IOException
Throws:
IOException

append

public Screenable append(Style style)
                  throws IOException
Throws:
IOException

cls

public Screenable cls()
               throws IOException
Throws:
IOException

provide

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

Parameters:
element - the provided element
Throws:
Exception - any exception

flush

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

Throws:
IOException - any io exception

close

public void close()
           throws Exception
Throws:
Exception

getSession

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

Returns:
the session map

getAttributes

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

Returns:
the attributes map


Copyright © 2015 eXo Platform SAS. All Rights Reserved.