org.crsh.term.spi.net
Class TermIOClient

java.lang.Object
  extended by org.crsh.term.spi.net.TermIOClient
All Implemented Interfaces:
Closeable, TermIO

public class TermIOClient
extends Object
implements TermIO

Author:
Julien Viet

Field Summary
private  ByteBuffer buffer
          .
private  byte[] bytes
          .
private  InputStream in
          .
private  OutputStream out
          .
private  int port
          .
private  Socket socket
          .
private static Charset UTF_8
          .
 
Constructor Summary
TermIOClient(int port)
           
 
Method Summary
private  byte _read()
           
private  int _read(byte[] buffer, int off, int len)
           
 void close()
           
 void connect()
           
 CodeType decode(int code)
          Decode the intput value.
 void flush()
          Flush output.
 String getProperty(String name)
          Retrieves the value of a property specified by this TermIO
 int getWidth()
          Returns the term width in chars.
 boolean moveLeft()
          Move the cursor left.
 boolean moveRight(char c)
          Move the cursor right.
private  void put(byte b)
           
 int read()
          Reads an input value.
 void write(char c)
          Write a char.
 void write(String s)
          Write a string.
 void writeCRLF()
          Write a CRLF.
 void writeDel()
          Delete the char under the cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF_8

private static final Charset UTF_8
.


port

private int port
.


socket

private Socket socket
.


in

private InputStream in
.


out

private OutputStream out
.


bytes

private byte[] bytes
.


buffer

private ByteBuffer buffer
.

Constructor Detail

TermIOClient

public TermIOClient(int port)
Method Detail

connect

public void connect()
             throws IOException
Throws:
IOException

put

private void put(byte b)

_read

private int _read(byte[] buffer,
                  int off,
                  int len)
           throws IOException,
                  Done
Throws:
IOException
Done

_read

private byte _read()
            throws IOException,
                   Done
Throws:
IOException
Done

read

public int read()
         throws IOException
Description copied from interface: TermIO
Reads an input value.

Specified by:
read in interface TermIO
Returns:
the value read
Throws:
IOException - any io exception

getWidth

public int getWidth()
Description copied from interface: TermIO
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 TermIO
Returns:
the term width

getProperty

public String getProperty(String name)
Description copied from interface: TermIO
Retrieves the value of a property specified by this TermIO

Specified by:
getProperty in interface TermIO
Parameters:
name - the name of the property
Returns:
value of the property

decode

public CodeType decode(int code)
Description copied from interface: TermIO
Decode the intput value.

Specified by:
decode in interface TermIO
Parameters:
code - the code
Returns:
the input value type

close

public void close()
Specified by:
close in interface Closeable

flush

public void flush()
           throws IOException
Description copied from interface: TermIO
Flush output.

Specified by:
flush in interface TermIO
Throws:
IOException - any io exception

write

public void write(char c)
           throws IOException
Description copied from interface: TermIO
Write a char.

Specified by:
write in interface TermIO
Parameters:
c - the char to write
Throws:
IOException - any io exception

write

public void write(String s)
           throws IOException
Description copied from interface: TermIO
Write a string.

Specified by:
write in interface TermIO
Parameters:
s - the string to write
Throws:
IOException - any io exception

writeDel

public void writeDel()
              throws IOException
Description copied from interface: TermIO
Delete the char under the cursor.

Specified by:
writeDel in interface TermIO
Throws:
IOException - any io exception

writeCRLF

public void writeCRLF()
               throws IOException
Description copied from interface: TermIO
Write a CRLF.

Specified by:
writeCRLF in interface TermIO
Throws:
IOException - any io exception

moveRight

public boolean moveRight(char c)
                  throws IOException
Description copied from interface: TermIO
Move the cursor right.

Specified by:
moveRight in interface TermIO
Parameters:
c - the char skipped over
Returns:
true if the cursor moved.
Throws:
IOException - any io exception

moveLeft

public boolean moveLeft()
                 throws IOException
Description copied from interface: TermIO
Move the cursor left.

Specified by:
moveLeft in interface TermIO
Returns:
true if the cursor moved
Throws:
IOException - any io exception


Copyright © 2012 eXo Platform SAS. All Rights Reserved.