FileDocCategorySizeDatePackage
DocumentDescription.javaAPI DocExample2742Thu Nov 08 00:23:46 GMT 2001com.ora.rmibook.chapter4

DocumentDescription

public class DocumentDescription extends Object implements Serializable, PrinterConstants

Fields Summary
private transient InputStream
_actualDocument
private int
_length
private int
_documentType
private boolean
_printTwoSided
private int
_printQuality
Constructors Summary
public DocumentDescription(InputStream actualDocument)

        this (actualDocument, DEFAULT_DOCUMENT_TYPE, DEFAULT_PRINT_TWO_SIDED,
            DEFAULT_PRINT_QUALITY);  
    
public DocumentDescription(InputStream actualDocument, int documentType, boolean printTwoSided, int printQuality)

        _documentType = documentType;
        _printTwoSided = printTwoSided;
        _printQuality = printQuality;
        BufferedInputStream buffer = new BufferedInputStream(actualDocument);
        DataInputStream dataInputStream = new DataInputStream(buffer);
        ByteArrayOutputStream temporaryBuffer = new ByteArrayOutputStream();

        _length = copy(dataInputStream, new DataOutputStream(temporaryBuffer));
        _actualDocument = new DataInputStream(new ByteArrayInputStream(temporaryBuffer.toByteArray()));
    
Methods Summary
private intcopy(java.io.InputStream source, java.io.OutputStream destination)

        int nextByte;
        int numberOfBytesCopied = 0;

        while (-1 != (nextByte = source.read())) {
            destination.write(nextByte);
            numberOfBytesCopied++;
        }
        destination.flush();
        return numberOfBytesCopied;
    
private voidcopy(java.io.InputStream source, java.io.OutputStream destination, int length)

        int counter;
        int nextByte;

        for (counter = 0; counter < length; counter++) {
            nextByte = source.read();
            destination.write(nextByte);
        }
        destination.flush();
    
public intgetDocumentType()

        return _documentType;
    
public intgetPrintQuality()

        return _printQuality;
    
public booleanisPrintTwoSided()

        return _printTwoSided;
    
private voidreadObject(java.io.ObjectInputStream in)

        in.defaultReadObject();
        ByteArrayOutputStream temporaryBuffer = new ByteArrayOutputStream();

        copy(in, temporaryBuffer, _length);
        _actualDocument = new DataInputStream(new ByteArrayInputStream(temporaryBuffer.toByteArray()));
    
private voidwriteObject(java.io.ObjectOutputStream out)

        out.defaultWriteObject();
        copy(_actualDocument, out);