net.sf.lpr.daemon.commands.spi
Class AbstractDaemonCommand

java.lang.Object
  extended by net.sf.lpr.daemon.commands.spi.AbstractDaemonCommand
All Implemented Interfaces:
DaemonCommand
Direct Known Subclasses:
AbortJob, PrintAnyWaitingJobs, ReceivePrinterJob

public abstract class AbstractDaemonCommand
extends java.lang.Object
implements DaemonCommand

Basic boiler plate code for LPD commands to the server.

Author:
x_sid

Constructor Summary
protected AbstractDaemonCommand(java.io.PrintStream print, java.io.InputStream in)
          Constructs the basic object for sending a single daemon command to the LPD server
 
Method Summary
 void print()
          A call to this method will write the request to the constructor provided print parameter and read the response from the provided in parameter.
protected abstract  void printCommand(java.io.PrintStream print)
          This method needs to be implemented for the daemon command that actually sends the request to the LPD server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDaemonCommand

protected AbstractDaemonCommand(java.io.PrintStream print,
                                java.io.InputStream in)
Constructs the basic object for sending a single daemon command to the LPD server

Parameters:
print -
in -
Method Detail

printCommand

protected abstract void printCommand(java.io.PrintStream print)
                              throws java.io.IOException
This method needs to be implemented for the daemon command that actually sends the request to the LPD server. There is no need to check the response from the server because that is handled by the code in the implemented print() method

Parameters:
print -
Throws:
java.io.IOException

print

public final void print()
                 throws IORuntimeException
A call to this method will write the request to the constructor provided print parameter and read the response from the provided in parameter. Once this method returns the request will have been sent and the response will have been read and evaluated.

Specified by:
print in interface DaemonCommand
Throws:
IORuntimeException - if an IO error occurs of the LPD server does not send back the expected two bytes of 0.