Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/DocPrintJob.java
38829 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print;2627import javax.print.attribute.PrintJobAttributeSet;28import javax.print.attribute.PrintRequestAttributeSet;29import javax.print.event.PrintJobAttributeListener;30import javax.print.event.PrintJobListener;31import javax.print.PrintException;3233/**34*35* This interface represents a print job that can print a specified36* document with a set of job attributes. An object implementing37* this interface is obtained from a print service.38*39*/4041public interface DocPrintJob {4243/**44* Determines the {@link PrintService} object to which this print job45* object is bound.46*47* @return <code>PrintService</code> object.48*49*/50public PrintService getPrintService();5152/**53* Obtains this Print Job's set of printing attributes.54* The returned attribute set object is unmodifiable.55* The returned attribute set object is a "snapshot" of this Print Job's56* attribute set at the time of the {@link #getAttributes()} method57* call; that is, the returned attribute set's object's contents will58* not be updated if this Print Job's attribute set's contents change59* in the future. To detect changes in attribute values, call60* <code>getAttributes()</code> again and compare the new attribute61* set to the previous attribute set; alternatively, register a62* listener for print job events.63* The returned value may be an empty set but should not be null.64* @return the print job attributes65*/66public PrintJobAttributeSet getAttributes();6768/**69* Registers a listener for event occurring during this print job.70* If listener is null, no exception is thrown and no action is71* performed.72* If listener is already registered, it will be registered again.73* @see #removePrintJobListener74*75* @param listener The object implementing the listener interface76*77*/78public void addPrintJobListener(PrintJobListener listener);7980/**81* Removes a listener from this print job.82* This method performs no function, nor does it throw an exception,83* if the listener specified by the argument was not previously added84* to this component. If listener is null, no exception is thrown and85* no action is performed. If a listener was registered more than once86* only one of the registrations will be removed.87* @see #addPrintJobListener88*89* @param listener The object implementing the listener interface90*/91public void removePrintJobListener(PrintJobListener listener);9293/**94* Registers a listener for changes in the specified attributes.95* If listener is null, no exception is thrown and no action is96* performed.97* To determine the attribute updates that may be reported by this job,98* a client can call <code>getAttributes()</code> and identify the99* subset that are interesting and likely to be reported to the100* listener. Clients expecting to be updated about changes in a101* specific job attribute should verify it is in that set, but102* updates about an attribute will be made only if it changes and this103* is detected by the job. Also updates may be subject to batching104* by the job. To minimize overhead in print job processing it is105* recommended to listen on only that subset of attributes which106* are likely to change.107* If the specified set is empty no attribute updates will be reported108* to the listener.109* If the attribute set is null, then this means to listen on all110* dynamic attributes that the job supports. This may result in no111* update notifications if a job can not report any attribute updates.112*113* If listener is already registered, it will be registered again.114* @see #removePrintJobAttributeListener115*116* @param listener The object implementing the listener interface117* @param attributes The attributes to listen on, or null to mean118* all attributes that can change, as determined by the job.119*/120public void addPrintJobAttributeListener(121PrintJobAttributeListener listener,122PrintJobAttributeSet attributes);123124/**125* Removes an attribute listener from this print job.126* This method performs no function, nor does it throw an exception,127* if the listener specified by the argument was not previously added128* to this component. If the listener is null, no exception is thrown129* and no action is performed.130* If a listener is registered more than once, even for a different131* set of attributes, no guarantee is made which listener is removed.132* @see #addPrintJobAttributeListener133*134* @param listener The object implementing the listener interface135*136*/137public void removePrintJobAttributeListener(138PrintJobAttributeListener listener);139140/**141* Prints a document with the specified job attributes.142* This method should only be called once for a given print job.143* Calling it again will not result in a new job being spooled to144* the printer. The service implementation will define policy145* for service interruption and recovery.146* When the print method returns, printing may not yet have completed as147* printing may happen asynchronously, perhaps in a different thread.148* Application clients which want to monitor the success or failure149* should register a PrintJobListener.150* <p>151* Print service implementors should close any print data streams (ie152* Reader or InputStream implementations) that they obtain153* from the client doc. Robust clients may still wish to verify this.154* An exception is always generated if a <code>DocFlavor</code> cannot155* be printed.156*157* @param doc The document to be printed. If must be a flavor158* supported by this PrintJob.159*160* @param attributes The job attributes to be applied to this print job.161* If this parameter is null then the default attributes are used.162* @throws PrintException The exception additionally may implement163* an interface that more precisely describes the cause of the164* exception165* <ul>166* <li>FlavorException.167* If the document has a flavor not supported by this print job.168* <li>AttributeException.169* If one or more of the attributes are not valid for this print job.170* </ul>171*/172public void print(Doc doc, PrintRequestAttributeSet attributes)173throws PrintException;174175}176177178