org.crsh.term
Class BaseTerm

java.lang.Object
  extended by org.crsh.term.BaseTerm
All Implemented Interfaces:
Closeable, Term

public class BaseTerm
extends Object
implements Term

Version:
$Revision$
Author:
Julien Viet

Field Summary
private  Console console
          .
private  LinkedList<CharSequence> history
          .
private  CharSequence historyBuffer
          .
private  int historyCursor
          .
private  TermIO io
          .
private  org.slf4j.Logger log
          .
 
Constructor Summary
BaseTerm(TermIO io)
           
 
Method Summary
 void addToHistory(CharSequence line)
          Append a line to the term history.
 void close()
          Close the term.
 CharSequence getBuffer()
          Returns the current buffer;
 Appendable getInsertBuffer()
          Returns the insert buffer, any char appended in the returned appendable will translate into an insertion in the buffer.
 String getProperty(String name)
          Retrieves the value of a property specified by this Term
 int getWidth()
          Returns the term width in chars.
 TermEvent read()
          Read the next term event.
 void setEcho(boolean echo)
          Set the echo mode on the term.
 void write(CharSequence msg)
          Write a message on the console, the text will be appended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final org.slf4j.Logger log
.


history

private final LinkedList<CharSequence> history
.


historyBuffer

private CharSequence historyBuffer
.


historyCursor

private int historyCursor
.


io

private final TermIO io
.


console

private final Console console
.

Constructor Detail

BaseTerm

public BaseTerm(TermIO io)
Method Detail

getWidth

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

getProperty

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

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

setEcho

public void setEcho(boolean echo)
Description copied from interface: Term
Set the echo mode on the term.

Specified by:
setEcho in interface Term
Parameters:
echo - the echo mode

read

public TermEvent read()
               throws IOException
Description copied from interface: Term
Read the next term event. This operation is a blocking operation that blocks until data is available or until term is closed.

Specified by:
read in interface Term
Returns:
the next term event
Throws:
IOException - any io exception

getInsertBuffer

public Appendable getInsertBuffer()
Description copied from interface: Term
Returns the insert buffer, any char appended in the returned appendable will translate into an insertion in the buffer.

Specified by:
getInsertBuffer in interface Term
Returns:
the insert buffer.

addToHistory

public void addToHistory(CharSequence line)
Description copied from interface: Term
Append a line to the term history.

Specified by:
addToHistory in interface Term
Parameters:
line - the history line to append

getBuffer

public CharSequence getBuffer()
Description copied from interface: Term
Returns the current buffer;

Specified by:
getBuffer in interface Term
Returns:
the buffer

close

public void close()
Description copied from interface: Term
Close the term. If threads are blocked in the Term.read() operation, those thread should be unblocked.

Specified by:
close in interface Closeable
Specified by:
close in interface Term

write

public void write(CharSequence msg)
           throws IOException
Description copied from interface: Term
Write a message on the console, the text will be appended.

Specified by:
write in interface Term
Parameters:
msg - the message to write
Throws:
IOException - any io exception


Copyright © 2012 eXo Platform SAS. All Rights Reserved.