javax.comm
Class ParallelPort

java.lang.Object
  extended byjavax.comm.CommPort
      extended byjavax.comm.ParallelPort

public abstract class ParallelPort
extends CommPort

A parallel communications port. ParallelPort describes the low-level interface to a parallel communications port made available by the underlying system. ParallelPort defines the minimum required functionality for parallel communications ports.

Author:
Jagane Sundar
See Also:
CommPort, CommPortIdentifier

Field Summary
static int LPT_MODE_ANY
          Picks the best available mode.
static int LPT_MODE_ECP
          Enhanced capabilities port.
static int LPT_MODE_EPP
          Extended parallel port.
static int LPT_MODE_NIBBLE
          Nibble Mode.
static int LPT_MODE_PS2
          Byte mode.
static int LPT_MODE_SPP
          Compatibility mode.
 
Fields inherited from class javax.comm.CommPort
name
 
Constructor Summary
ParallelPort()
           
 
Method Summary
abstract  void addEventListener(ParallelPortEventListener lsnr)
          Registers a ParallelPortEventListener object for ParallelPortEvents.
abstract  int getMode()
          Gets the currently configured mode.
abstract  int getOutputBufferFree()
          Gets the number of bytes available in the output buffer.
abstract  boolean isPaperOut()
          Checks if the port is indicating an "Out of Paper" state.
abstract  boolean isPrinterBusy()
          Checks if the port is indicating a "Printer Busy" state.
abstract  boolean isPrinterError()
          Checks if the printer has encountered an error.
abstract  boolean isPrinterSelected()
          Checks if the printer is in selected state.
abstract  boolean isPrinterTimedOut()
          Checks if the printer has timed out.
abstract  void notifyOnBuffer(boolean notify)
          Expresses interest in being notified when the output buffer is empty.
abstract  void notifyOnError(boolean notify)
          Expresses interest in being notified of port errors.
abstract  void removeEventListener()
          Deregisters event listener registered using addEventListener.
abstract  void restart()
          Restarts output after an error.
abstract  int setMode(int mode)
          Sets the printer port mode.
abstract  void suspend()
          Suspends output.
 
Methods inherited from class javax.comm.CommPort
close, disableReceiveFraming, disableReceiveThreshold, disableReceiveTimeout, enableReceiveFraming, enableReceiveThreshold, enableReceiveTimeout, getInputBufferSize, getInputStream, getName, getOutputBufferSize, getOutputStream, getReceiveFramingByte, getReceiveThreshold, getReceiveTimeout, isReceiveFramingEnabled, isReceiveThresholdEnabled, isReceiveTimeoutEnabled, setInputBufferSize, setOutputBufferSize, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LPT_MODE_ANY

public static final int LPT_MODE_ANY
Picks the best available mode.

See Also:
Constant Field Values

LPT_MODE_SPP

public static final int LPT_MODE_SPP
Compatibility mode. Unidirectional.

See Also:
Constant Field Values

LPT_MODE_PS2

public static final int LPT_MODE_PS2
Byte mode. Bi-directional.

See Also:
Constant Field Values

LPT_MODE_EPP

public static final int LPT_MODE_EPP
Extended parallel port.

See Also:
Constant Field Values

LPT_MODE_ECP

public static final int LPT_MODE_ECP
Enhanced capabilities port.

See Also:
Constant Field Values

LPT_MODE_NIBBLE

public static final int LPT_MODE_NIBBLE
Nibble Mode. Bi-directional. HP Bi-tronics. 4 bits at a time. Since CommAPI 1.1

See Also:
Constant Field Values
Constructor Detail

ParallelPort

public ParallelPort()
Method Detail

addEventListener

public abstract void addEventListener(ParallelPortEventListener lsnr)
                               throws java.util.TooManyListenersException
Registers a ParallelPortEventListener object for ParallelPortEvents. Interest in specific events may be expressed by using the notifyOnError and notifyOnBuffer methods.

Only one listener per ParallelPort is supported. Calling addEventListener multiple times will simply replace the current ParallelPortEventListener object.

After the port is closed, no more event will be generated. Another call to open() of the port's CommPortIdentifier object will return a new CommPort object, and the lsnr has to be added again to the new CommPort object to receive event from this port.

Parameters:
lsnr - A ParallelPortEventListener object whose parallelEvent method will be called to indicate an event.

Throws:
java.util.TooManyListenersException - If an initial attempt to attach a listener succeeds, subsequent attempts will throw TooManyListenersException without effecting the first listener.

removeEventListener

public abstract void removeEventListener()
Deregisters event listener registered using addEventListener. This is done automatically when a port is closed.


notifyOnError

public abstract void notifyOnError(boolean notify)
Expresses interest in being notified of port errors.

Parameters:
notify - enable or disable error notification based on whether notify is true or false

notifyOnBuffer

public abstract void notifyOnBuffer(boolean notify)
Expresses interest in being notified when the output buffer is empty.

Parameters:
notify - true enables notification; false disables notification.

getOutputBufferFree

public abstract int getOutputBufferFree()
Gets the number of bytes available in the output buffer.

Returns:
integer value corresponding to the number of bytes available in the output buffer

isPaperOut

public abstract boolean isPaperOut()
Checks if the port is indicating an "Out of Paper" state.

Returns:
true if printer has run out of paper, false if printer does not report "Out of paper".

isPrinterBusy

public abstract boolean isPrinterBusy()
Checks if the port is indicating a "Printer Busy" state.

Returns:
true if printer is busy, false if printer is idle

isPrinterSelected

public abstract boolean isPrinterSelected()
Checks if the printer is in selected state.

Note: This method is platform dependent.

Returns:
true if printer is selected, false if printer is in deselected mode

isPrinterTimedOut

public abstract boolean isPrinterTimedOut()
Checks if the printer has timed out.

Note: This method is platform dependent.

Returns:
true if printer has timed out, false if printer does not report "Out of paper".

isPrinterError

public abstract boolean isPrinterError()
Checks if the printer has encountered an error.

Note: This method is platform dependent.

Returns:
true if printer has encountered an error, false if printer does not report "Out of paper".

restart

public abstract void restart()
Restarts output after an error.


suspend

public abstract void suspend()
Suspends output.


getMode

public abstract int getMode()
Gets the currently configured mode.

Returns:
mode returned is one of LPT_MODE_SPP, LPT_MODE_PS2, LPT_MODE_EPP, or LPT_MODE_ECP

setMode

public abstract int setMode(int mode)
                     throws UnsupportedCommOperationException
Sets the printer port mode.

Parameters:
mode - one of LPT_MODE_ANY, LPT_MODE_SPP, LPT_MODE_PS2, LPT_MODE_EPP, or LPT_MODE_ECP

Throws:
UnsupportedCommOperationException - is thrown if the mode is not supported by the underline driver.