org.crsh.command
Class InnerInvocationContext<P>

java.lang.Object
  extended by org.crsh.command.InnerInvocationContext<P>
All Implemented Interfaces:
CommandContext, InvocationContext<Void,P>

 class InnerInvocationContext<P>
extends Object
implements InvocationContext<Void,P>

Author:
Julien Viet

Field Summary
(package private)  InvocationContext<?,?> outter
          .
(package private)  boolean piped
          .
(package private)  Class<? extends P> producedType
          .
(package private)  List<P> products
          .
 
Constructor Summary
InnerInvocationContext(InvocationContext<?,?> outter, Class<? extends P> producedType, boolean piped)
           
 
Method Summary
 Iterable<Void> consume()
          Returns an iterator over the stream of consumed items.
 Map<String,Object> getAttributes()
          Returns the current shell attributes.
 String getProperty(String propertyName)
          Returns a generic property, usually this property is resolved by the shell client.
 Map<String,Object> getSession()
          Returns the current shell session.
 int getWidth()
          Returns the term width in chars.
 ShellPrintWriter getWriter()
          Returns the writer for the output.
 boolean isPiped()
          Returns true if the command is involved in a pipe operation and receives a stream.
 void produce(P product)
          Produce an item.
 String readLine(String msg, boolean echo)
          Display a message and read a line on the console.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outter

final InvocationContext<?,?> outter
.


producedType

final Class<? extends P> producedType
.


products

List<P> products
.


piped

final boolean piped
.

Constructor Detail

InnerInvocationContext

InnerInvocationContext(InvocationContext<?,?> outter,
                       Class<? extends P> producedType,
                       boolean piped)
Method Detail

getWidth

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

Specified by:
getWidth in interface InvocationContext<Void,P>
Returns:
the term width

getProperty

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

Specified by:
getProperty in interface InvocationContext<Void,P>
Parameters:
propertyName - the property name
Returns:
the property value

readLine

public String readLine(String msg,
                       boolean echo)
Description copied from interface: InvocationContext
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 InvocationContext<Void,P>
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

getWriter

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

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

isPiped

public boolean isPiped()
Description copied from interface: InvocationContext
Returns true if the command is involved in a pipe operation and receives a stream.

Specified by:
isPiped in interface InvocationContext<Void,P>
Returns:
true if the command is involved in a pipe

consume

public Iterable<Void> consume()
                       throws IllegalStateException
Description copied from interface: InvocationContext
Returns an iterator over the stream of consumed items.

Specified by:
consume in interface InvocationContext<Void,P>
Returns:
the consumed items
Throws:
IllegalStateException - if the command is not involved in a pipe operation

produce

public void produce(P product)
Description copied from interface: InvocationContext
Produce an item.

Specified by:
produce in interface InvocationContext<Void,P>
Parameters:
product - the item product

getSession

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

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

getAttributes

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

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


Copyright © 2012 eXo Platform SAS. All Rights Reserved.