ClientNetworkWrapperpublic class ClientNetworkWrapper extends NetworkBaseClass implements PrinterConstants
Fields Summary |
---|
private String | _serverMachine | private int | _serverPort |
Constructors Summary |
---|
public ClientNetworkWrapper()
this (DEFAULT_SERVER_NAME, DEFAULT_SERVER_PORT);
| public ClientNetworkWrapper(String serverMachine, int serverPort)
_serverMachine = serverMachine;
_serverPort = serverPort;
|
Methods Summary |
---|
private void | readStatusFromSocket(java.net.Socket connection)
InputStream inputStream = connection.getInputStream();
DataInputStream dataInputStream = new DataInputStream(inputStream);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
boolean response = dataInputStream.readBoolean();
if (response) {
return;
}
PrinterException error = new PrinterException(inputStream);
throw error;
| public void | sendDocumentToPrinter(java.io.InputStream actualDocument)
sendDocumentToPrinter(actualDocument, DEFAULT_DOCUMENT_TYPE,
DEFAULT_PRINT_TWO_SIDED, DEFAULT_PRINT_QUALITY);
| public void | sendDocumentToPrinter(java.io.InputStream actualDocument, int documentType, boolean printTwoSided, int printQuality)
DocumentDescription documentToSend;
try {
documentToSend = new DocumentDescription(actualDocument, documentType, printTwoSided, printQuality);
} catch (IOException e) {
throw new ConnectionException();
}
sendDocumentToPrinter(documentToSend);
| public void | sendDocumentToPrinter(DocumentDescription documentDescription)
Socket connection = null;
try {
connection = new Socket(_serverMachine, _serverPort);
documentDescription.writeToStream(connection.getOutputStream());
readStatusFromSocket(connection);
} catch (IOException e) {
e.printStackTrace();
throw new ConnectionException();
}
closeSocket(connection);
|
|