Java Doc for ConsoleReader.java in  » Development » jLine » jline » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » jLine » jline 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jline.ConsoleReader

ConsoleReader
public class ConsoleReader implements ConsoleOperations(Code)
A reader for console applications. It supports custom tab-completion, saveable command history, and command line editing. On some platforms, platform-specific commands will need to be issued before the reader will function properly. See Terminal.initializeTerminal for convenience methods for issuing platform-specific setup commands.
author:
   Marc Prud'hommeaux


Field Summary
final public static  StringCR
    
public static  SortedMapKEYMAP_NAMES
     Map that contains the operation name to keymay operation mapping.
final static  intTAB_WIDTH
    
final  CursorBufferbuf
    
final  Listcompletors
    
static  PrintWriterdebugger
    
 Historyhistory
    
 InputStreamin
    
final  Writerout
    
 Stringprompt
    

Constructor Summary
public  ConsoleReader()
     Create a new reader using FileDescriptor.in for input and System.out for output.
public  ConsoleReader(InputStream in, Writer out)
     Create a new reader using the specified InputStream for input and the specific writer for output, using the default keybindings resource.
public  ConsoleReader(InputStream in, Writer out, InputStream bindings)
    
public  ConsoleReader(InputStream in, Writer out, InputStream bindings, Terminal term)
     Create a new reader.

Method Summary
public  booleanaddCompletor(Completor completor)
     Add the specified Completor to the list of handlers for tab-completion.
public  voidaddTriggeredAction(char c, ActionListener listener)
     Adding a triggered Action allows to give another curse of action if a character passed the preprocessing.
final public  booleanbackspace()
     Issue a backspace.
final public  voidbeep()
     Issue an audible keyboard bell, if ConsoleReader.getBellEnabled return true.
 intclearEcho(int c)
     Clear the echoed characters for the specified character code.
public  booleanclearScreen()
     Clear the screen by issuing the ANSI "clear screen" code.
 intcountEchoCharacters(char c)
    
public static  voiddebug(String str)
     debug.
final public  booleandelete()
     Issue a delete.
final public  voiddrawLine()
    
final  StringfinishBuffer()
     Clear the buffer and add its contents to the history.
final public  voidflushConsole()
     Flush the console output stream.
public  intgetAutoprintThreshhold()
    
public  booleangetBellEnabled()
    
public  CompletionHandlergetCompletionHandler()
    
public  CollectiongetCompletors()
     Returns an unmodifiable list of all the completors.
public  CursorBuffergetCursorBuffer()
    
 intgetCursorPosition()
    
public  StringgetDefaultPrompt()
     The default prompt that will be issued.
public  CharactergetEchoCharacter()
     Returns the echo character.
public  HistorygetHistory()
    
public  InputStreamgetInput()
     Returns the stream used for console input.
 intgetKeyForAction(short logicalAction)
    
 StringBuffergetPrintableCharacters(char ch)
     Return the number of characters that will be printed when the specified character is echoed to the screen.
public  intgetTermheight()
    
public  TerminalgetTerminal()
    
public  intgetTermwidth()
    
public  booleangetUseHistory()
     Whether or not to add new commands to the history buffer.
public  booleangetUsePagination()
     Whether to use pagination when the number of rows of candidates exceeds the height of the temrinal.
public  booleankillLine()
     Kill the buffer ahead of the current cursor position.
final public  intmoveCursor(int num)
     Move the cursor where characters.
Parameters:
  where - if less than 0, move abs(where) to the left,otherwise move where to the right.
public  booleanpaste()
    
public  voidprintColumns(Collection stuff)
     Output the specified Collection in proper columns.
final public  voidprintNewline()
     Output a platform-dependant newline.
final public  voidprintString(String str)
     Output the specified string to the output stream (but not the buffer).
final public  voidputString(String str)
     Write out the specified string to the buffer and the output stream.
final public  intreadCharacter(char[] allowed)
    
public  StringreadLine()
     Read the next line and return the contents of the buffer.
public  StringreadLine(Character mask)
     Read the next line with the specified character mask.
public  StringreadLine(String prompt)
    
public  StringreadLine(String prompt, Character mask)
     Read a line from the in InputStream , and return the line (without any trailing newlines).
Parameters:
  prompt - the prompt to issue to the console, may be null.
final public  intreadVirtualKey()
     Read a character from the console.
final public  voidredrawLine()
     Clear the line and redraw it.
public  booleanremoveCompletor(Completor completor)
     Remove the specified Completor from the list of handlers for tab-completion.
final public  booleanreplace(int num, String replacement)
    
final  booleanresetLine()
     Erase the current line.
public  voidsetAutoprintThreshhold(int autoprintThreshhold)
    
public  voidsetBellEnabled(boolean bellEnabled)
    
public  voidsetCompletionHandler(CompletionHandler completionHandler)
    
final public  booleansetCursorPosition(int position)
     Move the cursor position to the specified absolute index.
public  voidsetDebug(PrintWriter debugger)
     Set the stream for debugging.
public  voidsetDefaultPrompt(String prompt)
     The default prompt that will be issued.
public  voidsetEchoCharacter(Character echoCharacter)
    

Set the echo character.

public  voidsetHistory(History history)
    
public  voidsetInput(InputStream in)
     Set the stream to be used for console input.
public  voidsetUseHistory(boolean useHistory)
     Whether or not to add new commands to the history buffer.
public  voidsetUsePagination(boolean usePagination)
     Whether to use pagination when the number of rows of candidates exceeds the height of the temrinal.

Field Detail
CR
final public static String CR(Code)



KEYMAP_NAMES
public static SortedMap KEYMAP_NAMES(Code)
Map that contains the operation name to keymay operation mapping.



TAB_WIDTH
final static int TAB_WIDTH(Code)



buf
final CursorBuffer buf(Code)



completors
final List completors(Code)



debugger
static PrintWriter debugger(Code)



history
History history(Code)



in
InputStream in(Code)



out
final Writer out(Code)



prompt
String prompt(Code)




Constructor Detail
ConsoleReader
public ConsoleReader() throws IOException(Code)
Create a new reader using FileDescriptor.in for input and System.out for output. FileDescriptor.in is used because it has a better chance of being unbuffered.



ConsoleReader
public ConsoleReader(InputStream in, Writer out) throws IOException(Code)
Create a new reader using the specified InputStream for input and the specific writer for output, using the default keybindings resource.



ConsoleReader
public ConsoleReader(InputStream in, Writer out, InputStream bindings) throws IOException(Code)



ConsoleReader
public ConsoleReader(InputStream in, Writer out, InputStream bindings, Terminal term) throws IOException(Code)
Create a new reader.
Parameters:
  in - the input
Parameters:
  out - the output
Parameters:
  bindings - the key bindings to use
Parameters:
  term - the terminal to use




Method Detail
addCompletor
public boolean addCompletor(Completor completor)(Code)
Add the specified Completor to the list of handlers for tab-completion.
Parameters:
  completor - the Completor to add true if it was successfully added



addTriggeredAction
public void addTriggeredAction(char c, ActionListener listener)(Code)
Adding a triggered Action allows to give another curse of action if a character passed the preprocessing. Say you want to close the application if the user enter q. addTriggerAction('q', new ActionListener(){ System.exit(0); }); would do the trick.
Parameters:
  c -
Parameters:
  listener -



backspace
final public boolean backspace() throws IOException(Code)
Issue a backspace. true if successful



beep
final public void beep() throws IOException(Code)
Issue an audible keyboard bell, if ConsoleReader.getBellEnabled return true.



clearEcho
int clearEcho(int c) throws IOException(Code)
Clear the echoed characters for the specified character code.



clearScreen
public boolean clearScreen() throws IOException(Code)
Clear the screen by issuing the ANSI "clear screen" code.



countEchoCharacters
int countEchoCharacters(char c)(Code)



debug
public static void debug(String str)(Code)
debug.
Parameters:
  str - the message to issue.



delete
final public boolean delete() throws IOException(Code)
Issue a delete. true if successful



drawLine
final public void drawLine() throws IOException(Code)
Output put the prompt + the current buffer



finishBuffer
final String finishBuffer()(Code)
Clear the buffer and add its contents to the history. the former contents of the buffer.



flushConsole
final public void flushConsole() throws IOException(Code)
Flush the console output stream. This is important for printout out single characters (like a backspace or keyboard) that we want the console to handle immedately.



getAutoprintThreshhold
public int getAutoprintThreshhold()(Code)
the number of candidates to print without issing a warning.



getBellEnabled
public boolean getBellEnabled()(Code)
true is audible keyboard bell is enabled.



getCompletionHandler
public CompletionHandler getCompletionHandler()(Code)



getCompletors
public Collection getCompletors()(Code)
Returns an unmodifiable list of all the completors.



getCursorBuffer
public CursorBuffer getCursorBuffer()(Code)



getCursorPosition
int getCursorPosition()(Code)



getDefaultPrompt
public String getDefaultPrompt()(Code)
The default prompt that will be issued.



getEchoCharacter
public Character getEchoCharacter()(Code)
Returns the echo character.



getHistory
public History getHistory()(Code)



getInput
public InputStream getInput()(Code)
Returns the stream used for console input.



getKeyForAction
int getKeyForAction(short logicalAction)(Code)



getPrintableCharacters
StringBuffer getPrintableCharacters(char ch)(Code)
Return the number of characters that will be printed when the specified character is echoed to the screen. Adapted from cat by Torbjorn Granlund, as repeated in stty by David MacKenzie.



getTermheight
public int getTermheight()(Code)
Query the terminal to find the current width;
See Also:   Terminal.getTerminalHeight the height of the current terminal.



getTerminal
public Terminal getTerminal()(Code)



getTermwidth
public int getTermwidth()(Code)
Query the terminal to find the current width;
See Also:   Terminal.getTerminalWidth the width of the current terminal.



getUseHistory
public boolean getUseHistory()(Code)
Whether or not to add new commands to the history buffer.



getUsePagination
public boolean getUsePagination()(Code)
Whether to use pagination when the number of rows of candidates exceeds the height of the temrinal.



killLine
public boolean killLine() throws IOException(Code)
Kill the buffer ahead of the current cursor position. true if successful



moveCursor
final public int moveCursor(int num) throws IOException(Code)
Move the cursor where characters.
Parameters:
  where - if less than 0, move abs(where) to the left,otherwise move where to the right. the number of spaces we moved



paste
public boolean paste() throws IOException(Code)
Paste the contents of the clipboard into the console buffer true if clipboard contents pasted



printColumns
public void printColumns(Collection stuff) throws IOException(Code)
Output the specified Collection in proper columns.
Parameters:
  stuff - the stuff to print



printNewline
final public void printNewline() throws IOException(Code)
Output a platform-dependant newline.



printString
final public void printString(String str) throws IOException(Code)
Output the specified string to the output stream (but not the buffer).



putString
final public void putString(String str) throws IOException(Code)
Write out the specified string to the buffer and the output stream.



readCharacter
final public int readCharacter(char[] allowed) throws IOException(Code)



readLine
public String readLine() throws IOException(Code)
Read the next line and return the contents of the buffer.



readLine
public String readLine(Character mask) throws IOException(Code)
Read the next line with the specified character mask. If null, then characters will be echoed. If 0, then no characters will be echoed.



readLine
public String readLine(String prompt) throws IOException(Code)



readLine
public String readLine(String prompt, Character mask) throws IOException(Code)
Read a line from the in InputStream , and return the line (without any trailing newlines).
Parameters:
  prompt - the prompt to issue to the console, may be null. a line that is read from the terminal, or null if there was nullinput (e.g., CTRL-D was pressed).



readVirtualKey
final public int readVirtualKey() throws IOException(Code)
Read a character from the console. the character, or -1 if an EOF is received.



redrawLine
final public void redrawLine() throws IOException(Code)
Clear the line and redraw it.



removeCompletor
public boolean removeCompletor(Completor completor)(Code)
Remove the specified Completor from the list of handlers for tab-completion.
Parameters:
  completor - the Completor to remove true if it was successfully removed



replace
final public boolean replace(int num, String replacement)(Code)



resetLine
final boolean resetLine() throws IOException(Code)
Erase the current line. false if we failed (e.g., the buffer was empty)



setAutoprintThreshhold
public void setAutoprintThreshhold(int autoprintThreshhold)(Code)

Parameters:
  autoprintThreshhold - the number of candidates to print without issuing a warning.



setBellEnabled
public void setBellEnabled(boolean bellEnabled)(Code)

Parameters:
  bellEnabled - if true, enable audible keyboard bells if an alert isrequired.



setCompletionHandler
public void setCompletionHandler(CompletionHandler completionHandler)(Code)



setCursorPosition
final public boolean setCursorPosition(int position) throws IOException(Code)
Move the cursor position to the specified absolute index.



setDebug
public void setDebug(PrintWriter debugger)(Code)
Set the stream for debugging. Development use only.



setDefaultPrompt
public void setDefaultPrompt(String prompt)(Code)
The default prompt that will be issued.



setEchoCharacter
public void setEchoCharacter(Character echoCharacter)(Code)

Set the echo character. For example, to have "*" entered when a password is typed:

 myConsoleReader.setEchoCharacter(new Character('*'));
 

Setting the character to

 null
 
will restore normal character echoing. Setting the character to
 new Character(0)
 
will cause nothing to be echoed.


Parameters:
  echoCharacter - the character to echo to the console in place of the typedcharacter.



setHistory
public void setHistory(History history)(Code)



setInput
public void setInput(InputStream in)(Code)
Set the stream to be used for console input.



setUseHistory
public void setUseHistory(boolean useHistory)(Code)
Whether or not to add new commands to the history buffer.



setUsePagination
public void setUsePagination(boolean usePagination)(Code)
Whether to use pagination when the number of rows of candidates exceeds the height of the temrinal.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.