org.crsh.shell.impl.remoting
Class ClientProcessContext

java.lang.Object
  extended by org.crsh.shell.impl.remoting.ClientProcessContext
All Implemented Interfaces:
Flushable, InteractionContext, ScreenContext, ShellProcessContext

 class ClientProcessContext
extends Object
implements ShellProcessContext


Field Summary
(package private)  ArrayList<Chunk> buffer
          .
(package private)  ClientAutomaton client
          .
private  boolean closed
          .
(package private)  ShellProcess process
          .
 
Constructor Summary
ClientProcessContext(ClientAutomaton client, ShellProcess process)
           
 
Method Summary
 void end(ShellResponse response)
          This method is invoked when the process ends.
private  void ensureSize()
          Ensure we have a recent size, the size is considered as recent if it's younger than 2 second, otherwise send a get size message.
(package private)  void execute()
           
 void flush()
           
 Class<Chunk> getConsumedType()
           
 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.
 int getWidth()
          Returns the screen width in chars.
 void provide(Chunk 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.
 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

client

final ClientAutomaton client
.


process

final ShellProcess process
.


buffer

final ArrayList<Chunk> buffer
.


closed

private boolean closed
.

Constructor Detail

ClientProcessContext

ClientProcessContext(ClientAutomaton client,
                     ShellProcess process)
Method Detail

ensureSize

private void ensureSize()
Ensure we have a recent size, the size is considered as recent if it's younger than 2 second, otherwise send a get size message.


execute

void execute()

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

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
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
Returns:
true if the usual buffer is shown

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

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(Chunk element)
             throws IOException
Throws:
IOException

getConsumedType

public Class<Chunk> getConsumedType()

flush

public void flush()
Specified by:
flush in interface Flushable

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


Copyright © 2013 eXo Platform SAS. All Rights Reserved.