DocPrintJob.java revision 2362
0N/A/*
2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/Apackage javax.print;
0N/A
0N/Aimport javax.print.attribute.PrintJobAttributeSet;
0N/Aimport javax.print.attribute.PrintRequestAttributeSet;
0N/Aimport javax.print.event.PrintJobAttributeListener;
0N/Aimport javax.print.event.PrintJobListener;
0N/Aimport javax.print.PrintException;
0N/A
0N/A/**
0N/A *
0N/A * This interface represents a print job that can print a specified
0N/A * document with a set of job attributes. An object implementing
0N/A * this interface is obtained from a print service.
0N/A *
0N/A */
0N/A
0N/Apublic interface DocPrintJob {
0N/A
0N/A /**
0N/A * Determines the {@link PrintService} object to which this print job
0N/A * object is bound.
0N/A *
0N/A * @return <code>PrintService</code> object.
0N/A *
0N/A */
0N/A public PrintService getPrintService();
0N/A
0N/A /**
0N/A * Obtains this Print Job's set of printing attributes.
0N/A * The returned attribute set object is unmodifiable.
0N/A * The returned attribute set object is a "snapshot" of this Print Job's
0N/A * attribute set at the time of the {@link #getAttributes()} method
0N/A * call; that is, the returned attribute set's object's contents will
0N/A * not be updated if this Print Job's attribute set's contents change
0N/A * in the future. To detect changes in attribute values, call
0N/A * <code>getAttributes()</code> again and compare the new attribute
0N/A * set to the previous attribute set; alternatively, register a
0N/A * listener for print job events.
0N/A * The returned value may be an empty set but should not be null.
0N/A * @return the print job attributes
0N/A */
0N/A public PrintJobAttributeSet getAttributes();
0N/A
0N/A /**
0N/A * Registers a listener for event occurring during this print job.
0N/A * If listener is null, no exception is thrown and no action is
0N/A * performed.
0N/A * If listener is already registered, it will be registered again.
0N/A * @see #removePrintJobListener
0N/A *
0N/A * @param listener The object implementing the listener interface
0N/A *
0N/A */
0N/A public void addPrintJobListener(PrintJobListener listener);
0N/A
0N/A /**
0N/A * Removes a listener from this print job.
0N/A * This method performs no function, nor does it throw an exception,
0N/A * if the listener specified by the argument was not previously added
0N/A * to this component. If listener is null, no exception is thrown and
0N/A * no action is performed. If a listener was registered more than once
0N/A * only one of the registrations will be removed.
0N/A * @see #addPrintJobListener
1324N/A *
1324N/A * @param listener The object implementing the listener interface
1324N/A */
1324N/A public void removePrintJobListener(PrintJobListener listener);
1324N/A
1324N/A /**
0N/A * Registers a listener for changes in the specified attributes.
0N/A * If listener is null, no exception is thrown and no action is
0N/A * performed.
0N/A * To determine the attribute updates that may be reported by this job,
0N/A * a client can call <code>getAttributes()</code> and identify the
0N/A * subset that are interesting and likely to be reported to the
0N/A * listener. Clients expecting to be updated about changes in a
0N/A * specific job attribute should verify it is in that set, but
0N/A * updates about an attribute will be made only if it changes and this
0N/A * is detected by the job. Also updates may be subject to batching
0N/A * by the job. To minimise overhead in print job processing it is
0N/A * recommended to listen on only that subset of attributes which
0N/A * are likely to change.
0N/A * If the specified set is empty no attribute updates will be reported
0N/A * to the listener.
0N/A * If the attribute set is null, then this means to listen on all
0N/A * dynamic attributes that the job supports. This may result in no
0N/A * update notifications if a job can not report any attribute updates.
0N/A *
0N/A * If listener is already registered, it will be registered again.
0N/A * @see #removePrintJobAttributeListener
0N/A *
0N/A * @param listener The object implementing the listener interface
0N/A * @param attributes The attributes to listen on, or null to mean
0N/A * all attributes that can change, as determined by the job.
0N/A */
0N/A public void addPrintJobAttributeListener(
0N/A PrintJobAttributeListener listener,
0N/A PrintJobAttributeSet attributes);
0N/A
0N/A /**
0N/A * Removes an attribute listener from this print job.
0N/A * This method performs no function, nor does it throw an exception,
0N/A * if the listener specified by the argument was not previously added
0N/A * to this component. If the listener is null, no exception is thrown
0N/A * and no action is performed.
0N/A * If a listener is registered more than once, even for a different
0N/A * set of attributes, no guarantee is made which listener is removed.
0N/A * @see #addPrintJobAttributeListener
0N/A *
0N/A * @param listener The object implementing the listener interface
0N/A *
0N/A */
0N/A public void removePrintJobAttributeListener(
0N/A PrintJobAttributeListener listener);
0N/A
0N/A /**
0N/A * Prints a document with the specified job attributes.
0N/A * This method should only be called once for a given print job.
0N/A * Calling it again will not result in a new job being spooled to
0N/A * the printer. The service implementation will define policy
0N/A * for service interruption and recovery.
0N/A * When the print method returns, printing may not yet have completed as
0N/A * printing may happen asynchronously, perhaps in a different thread.
0N/A * Application clients which want to monitor the success or failure
0N/A * should register a PrintJobListener.
0N/A * <p>
0N/A * Print service implementors should close any print data streams (ie
0N/A * Reader or InputStream implementations) that they obtain
0N/A * from the client doc. Robust clients may still wish to verify this.
0N/A * An exception is always generated if a <code>DocFlavor</code> cannot
0N/A * be printed.
0N/A *
* @param doc The document to be printed. If must be a flavor
* supported by this PrintJob.
*
* @param attributes The job attributes to be applied to this print job.
* If this parameter is null then the default attributes are used.
* @throws PrintException The exception additionally may implement
* an interface that more precisely describes the cause of the
* exception
* <ul>
* <li>FlavorException.
* If the document has a flavor not supported by this print job.
* <li>AttributeException.
* If one or more of the attributes are not valid for this print job.
* </ul>
*/
public void print(Doc doc, PrintRequestAttributeSet attributes)
throws PrintException;
}