org.crsh.ssh.term.inline
Class SSHInlineShellProcessContext

java.lang.Object
  extended by org.crsh.ssh.term.inline.SSHInlineShellProcessContext
All Implemented Interfaces:
Flushable, Consumer<Chunk>, InteractionContext<Chunk>, ScreenContext<Chunk>, ShellProcessContext

public class SSHInlineShellProcessContext
extends Object
implements ShellProcessContext

ShellProcessContext for SSH inline commands


Field Summary
private  SSHContext context
          .
private  PrintStream err
          .
private  CountDownLatch latch
          .
private static String MSG
          .
private  boolean msgDone
          .
private  PrintStream out
          .
private  ShellProcess process
          .
private  ShellResponse response
          .
 
Constructor Summary
SSHInlineShellProcessContext(SSHContext context, ShellProcess process, PrintStream out, PrintStream err)
           
 
Method Summary
 void end(ShellResponse response)
          This method is invoked when the process ends.
 SSHInlineShellProcessContext execute()
           
 void flush()
           
 Class<Chunk> getConsumedType()
          Returns the class of the element generic type.
 int getHeight()
          Returns the screen height in chars.
 String getProperty(String name)
          Returns a generic property, usually this property is resolved by the shell client.
(package private)  ShellResponse getResponse()
           
 int getWidth()
          Returns the screen width in chars.
 void provide(Chunk 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.
 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

MSG

private static final String MSG
.

See Also:
Constant Field Values

msgDone

private boolean msgDone
.


response

private ShellResponse response
.


latch

private final CountDownLatch latch
.


context

private final SSHContext context
.


process

private final ShellProcess process
.


out

private final PrintStream out
.


err

private final PrintStream err
.

Constructor Detail

SSHInlineShellProcessContext

SSHInlineShellProcessContext(SSHContext context,
                             ShellProcess process,
                             PrintStream out,
                             PrintStream err)
Method Detail

execute

public SSHInlineShellProcessContext execute()

takeAlternateBuffer

public boolean takeAlternateBuffer()
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<Chunk>
Returns:
true if the alternate buffer is shown

releaseAlternateBuffer

public boolean releaseAlternateBuffer()
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<Chunk>
Returns:
true if the usual buffer is shown

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

getProperty

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

Specified by:
getProperty in interface InteractionContext<Chunk>
Parameters:
name - 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<Chunk>
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

getConsumedType

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

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

provide

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

Specified by:
provide in interface Consumer<Chunk>
Parameters:
element - the provided element
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Throws:
IOException

end

public void end(ShellResponse response)
Description copied from interface: ShellProcessContext
This method is invoked when the process ends.

Specified by:
end in interface ShellProcessContext
Parameters:
response - the shell response

getResponse

ShellResponse getResponse()


Copyright © 2014 eXo Platform SAS. All Rights Reserved.