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

java.lang.Object
  extended by net.sf.lpr.daemon.commands.spi.AbstractSendQueueState
All Implemented Interfaces:
DaemonCommand
Direct Known Subclasses:
SendQueueStateLong, SendQueueStateShort

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

This class houses the shared code that is used for querying the LPD server for it's state. Since the only part of the request to the server that changes is the numeric code all the work can be done here leaving the code for the command to subclasses.

Author:
x_sid

Constructor Summary
protected AbstractSendQueueState(java.io.PrintStream print, java.io.InputStream serverIn, java.lang.String queue, java.io.Writer response)
          Constructor for creating the parent class that does the boiler plate work.
 
Method Summary
protected abstract  java.lang.String getCode()
          Concrete subclasses must implement this method to return the two digit code encoded with \0XX
 void print()
          A call to this method will send the query and read the response from the LPD server that is pointed at by the constructor provided PrintStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSendQueueState

protected AbstractSendQueueState(java.io.PrintStream print,
                                 java.io.InputStream serverIn,
                                 java.lang.String queue,
                                 java.io.Writer response)
Constructor for creating the parent class that does the boiler plate work.

Parameters:
print - stream to write out the query for the state of the queue to.
serverIn - the response stream to read responses from the server.
queue - that is to have it's state queried for.
response - the Writer to which the response from the server will be written.
Method Detail

getCode

protected abstract java.lang.String getCode()
Concrete subclasses must implement this method to return the two digit code encoded with \0XX

Returns:
String that is the \0XX code that is to be used to send the request for the state of the queue

print

public void print()
           throws IORuntimeException
A call to this method will send the query and read the response from the LPD server that is pointed at by the constructor provided PrintStream

Specified by:
print in interface DaemonCommand
Throws:
IORuntimeException - if an IO error occurs or the response from the LPD server is not the expected 2 bytes of 0