Package org.gnu.readline
Class ReadlineReader
- java.lang.Object
-
- java.io.Reader
-
- org.gnu.readline.ReadlineReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public class ReadlineReader extends java.io.Reader
AReader
wrapper for the Readline classes. This seems to work fine in conjunction with such classes as BufferedReader, but it hasn't been tested well enough to see if this will work well in all cases. This was implemented to make it easier to supplant Readline's functionality [shrug] anywhere and everywhere, but specifically in BeanShell.- Version:
- $Revision$
- Author:
- Shane Celis
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_PROMPT
-
Constructor Summary
Constructors Constructor Description ReadlineReader(java.io.File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file.ReadlineReader(java.lang.String prompt, java.io.File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file and prompt.ReadlineReader(java.lang.String prompt, ReadlineLibrary lib)
Constructs a ReadlineReader object with the given prompt.ReadlineReader(ReadlineLibrary lib)
Constructs a ReadlineReader object with the default prompt.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Nullifies all buffers and writes history file if one was given at construction time.java.lang.String
getPrompt()
Returns the current prompt.static void
main(java.lang.String[] args)
int
read(char[] cbuf, int off, int len)
Reads what's given fromreadline()
into a buffer.void
setPrompt(java.lang.String prompt)
Sets the prompt to the given value.
-
-
-
Field Detail
-
DEFAULT_PROMPT
public static final java.lang.String DEFAULT_PROMPT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReadlineReader
public ReadlineReader(java.lang.String prompt, ReadlineLibrary lib)
Constructs a ReadlineReader object with the given prompt.
-
ReadlineReader
public ReadlineReader(ReadlineLibrary lib)
Constructs a ReadlineReader object with the default prompt.
-
ReadlineReader
public ReadlineReader(java.io.File history, ReadlineLibrary lib) throws java.io.IOException
Constructs a ReadlineReader object with an associated history file.- Throws:
java.io.IOException
-
ReadlineReader
public ReadlineReader(java.lang.String prompt, java.io.File history, ReadlineLibrary lib) throws java.io.IOException
Constructs a ReadlineReader object with an associated history file and prompt.- Throws:
java.io.IOException
-
-
Method Detail
-
getPrompt
public java.lang.String getPrompt()
Returns the current prompt.
-
setPrompt
public void setPrompt(java.lang.String prompt)
Sets the prompt to the given value.
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException
Reads what's given fromreadline()
into a buffer. When that buffer is emptied,readline()
is called again to replenish that buffer. This seems to work fine in conjunction with such classes as BufferedReader, but it hasn't been tested well enough to see if this will work well in all cases.- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Nullifies all buffers and writes history file if one was given at construction time.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-