ClientNetworkWrapper.java (Example JavaDoc)
Description: Java source code
Keywords: Java, source code

File | Doc | Category | Size | Date | Package
--- | --- | --- | --- | --- | ---
ClientNetworkWrapper.java | API Doc | Example | 2389 | Thu Nov 08 00:23:44 GMT 2001 | com.ora.rmibook.chapter3
# ClientNetworkWrapper java.lang.Object NetworkBaseClass public 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);
> Test Test Test
>     ABC
>     DEF
TEST TEST TEST
> 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);