|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.lpr.LPRUtils
public class LPRUtils
Utility class for doing some of the dumb work that is needed in more than one place but makes little sense to have in a parent class.
Field Summary | |
---|---|
static byte[] |
ZERO
|
Constructor Summary | |
---|---|
LPRUtils()
|
Method Summary | |
---|---|
static void |
checkResponse(byte[] response,
java.lang.Class<?> request)
This static method is used for clarity in code to provide a way to throw an exception if the response from the server does not match the expected two bytes of zero |
static void |
copy(java.io.InputStream from,
java.io.OutputStream to)
Copies the contents of the InputStream to the OutputStream . |
static int |
generateJobId()
This method is used to in the high level API classes to generate job ID's that are required by the LPR protocol |
static java.lang.String |
getHostname()
Does it's best to return a host name for the machine that it is running on. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte[] ZERO
Constructor Detail |
---|
public LPRUtils()
Method Detail |
---|
public static void checkResponse(byte[] response, java.lang.Class<?> request) throws IORuntimeException
response
- byte array of response from the server to be compared.request
- Class
that is making a call to this method. It is used for the purpose of filling out the exception that can be thrown if the the response from the server does not match.
IORuntimeException
- if the response does not match the two bytes of zeropublic static void copy(java.io.InputStream from, java.io.OutputStream to) throws IORuntimeException
InputStream
to the OutputStream
. A call to this method will create a buffer of 4096 bytes to do the copying. If something like this is needed it would be advisable to use Apache commons IO
from
- stream to copy fromto
- the stream to copy to.
IORuntimeException
public static int generateJobId()
public static java.lang.String getHostname()
InetAddress
class and calls the getLocalHost() method and then the getHostName() method. If the final attempt fails because
of an exception being thrown then the empty string "" is returned. A patch from someone who knows more about this would be much appreciated.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |