org.crsh.shell.impl
Class AbstractInvocationContext<C,P>

java.lang.Object
  extended by org.crsh.shell.impl.CommandContextImpl
      extended by org.crsh.shell.impl.AbstractInvocationContext<C,P>
All Implemented Interfaces:
CommandContext, InvocationContext<C,P>
Direct Known Subclasses:
InvocationContextImpl

public abstract class AbstractInvocationContext<C,P>
extends CommandContextImpl
implements InvocationContext<C,P>

Version:
$Revision$
Author:
Julien Viet

Field Summary
protected  StringWriter buffer
          .
protected  Iterable<C> consumedItems
          .
protected  List<P> producedItems
          .
protected  ShellPrinter writer
          .
 
Constructor Summary
protected AbstractInvocationContext(Iterable<C> consumedItems, Map<String,Object> attributes)
           
 
Method Summary
protected  Map<String,Object> attributes(Map<String,Object> attributes)
          Provide an opportunity to subclass to change the attribute map.
 Iterable<C> consume()
          Returns an iterator over the stream of consumed items.
 StringWriter getBuffer()
           
 List<P> getProducedItems()
           
 ShellPrinter getWriter()
           
 boolean isPiped()
          Returns true if the command is involved in a pipe operation and receives a stream.
 void produce(P product)
           
 
Methods inherited from class org.crsh.shell.impl.CommandContextImpl
getAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.crsh.command.InvocationContext
getProperty, getWidth, readLine
 
Methods inherited from interface org.crsh.command.CommandContext
getAttributes
 

Field Detail

writer

protected ShellPrinter writer
.


buffer

protected StringWriter buffer
.


producedItems

protected List<P> producedItems
.


consumedItems

protected Iterable<C> consumedItems
.

Constructor Detail

AbstractInvocationContext

protected AbstractInvocationContext(Iterable<C> consumedItems,
                                    Map<String,Object> attributes)
Method Detail

attributes

protected Map<String,Object> attributes(Map<String,Object> attributes)
Description copied from class: CommandContextImpl
Provide an opportunity to subclass to change the attribute map. This implementation returns the same object by default.

Overrides:
attributes in class CommandContextImpl
Parameters:
attributes - the original attributes
Returns:
the replaced attributes

getProducedItems

public List<P> getProducedItems()

getBuffer

public StringWriter getBuffer()

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<C,P>
Returns:
true if the command is involved in a pipe

consume

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

Specified by:
consume in interface InvocationContext<C,P>
Returns:
the consumed items

produce

public void produce(P product)
Specified by:
produce in interface InvocationContext<C,P>

getWriter

public ShellPrinter getWriter()
Specified by:
getWriter in interface InvocationContext<C,P>


Copyright © 2012 eXo Platform SAS. All Rights Reserved.