Josh
Native console access wrapper for Java

com.yifanlu.Josh
Class JoshInBuffer

java.lang.Object
  extended by com.yifanlu.Josh.JoshBuffer
      extended by com.yifanlu.Josh.JoshInBuffer

public class JoshInBuffer
extends JoshBuffer

Provides native access to the input buffer. This allows access to events in the console.
Do not call this class directly, use Josh.inBuffer.

Since:
0.1
Version:
1.3, 05/29/10
Author:
Yifan Lu

Constructor Summary
JoshInBuffer(ConsoleHandle handle)
          Creates a new input buffer for reading console events.
 
Method Summary
 int getNumberOfConsoleInputEvents()
          Retrieves the number of unread input records in the console's input buffer.
 ConsoleEvent peekConsoleInput()
          Reads data from the specified console input buffer without removing it from the buffer.
 ConsoleEvent readConsoleInput()
          Reads data from a console input buffer and removes it from the buffer.
 void writeConsoleInput(ConsoleEvent event)
          Writes data directly to the console input buffer.
 
Methods inherited from class com.yifanlu.Josh.JoshBuffer
equals, getHandle, hashCode, setHandle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoshInBuffer

public JoshInBuffer(ConsoleHandle handle)
Creates a new input buffer for reading console events. This class should, except in rare cases, never be called alone. Use Josh.inBuffer to access, as there is only one input buffer needed for a console. You must have the GENERIC_READ permission in the handle for the buffer to use the methods below.

Parameters:
handle - A memory location that this buffer represents. Usually the STD_INPUT_HANDLE from Josh.
Method Detail

getNumberOfConsoleInputEvents

public int getNumberOfConsoleInputEvents()
Retrieves the number of unread input records in the console's input buffer.

Returns:
The number of unread input records in the console's input buffer.
See Also:
Windows' GetNumberOfConsoleInputEvents function

peekConsoleInput

public ConsoleEvent peekConsoleInput()
Reads data from the specified console input buffer without removing it from the buffer.

Returns:
The top-most console event, without removing it from the stack.
See Also:
Windows' PeekConsoleInput function

readConsoleInput

public ConsoleEvent readConsoleInput()
Reads data from a console input buffer and removes it from the buffer.

Returns:
The top-most console event, and pops it off the stack.
See Also:
Windows' ReadConsoleInput function

writeConsoleInput

public void writeConsoleInput(ConsoleEvent event)
Writes data directly to the console input buffer.

Parameters:
event - Contains data to be written to the input buffer
See Also:
Windows' WriteConsoleInput function

Copyright © 2010 Yifan Lu