Save This Page
Home » openjdk-7 » javax » print » [javadoc | source]
    1   /*
    2    * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package javax.print;
   27   
   28   import javax.print.attribute.AttributeSet;
   29   import javax.print.attribute.PrintJobAttributeSet;
   30   import javax.print.attribute.PrintRequestAttributeSet;
   31   import javax.print.event.PrintJobAttributeListener;
   32   import javax.print.event.PrintJobListener;
   33   import javax.print.PrintException;
   34   
   35   /**
   36    *
   37    * This interface represents a print job that can print a specified
   38    * document with a set of job attributes.  An object implementing
   39    * this interface is obtained from a print service.
   40    *
   41    */
   42   
   43   public interface DocPrintJob {
   44   
   45       /**
   46        * Determines the {@link PrintService} object to which this print job
   47        * object is bound.
   48        *
   49        * @return  <code>PrintService</code> object.
   50        *
   51        */
   52       public PrintService getPrintService();
   53   
   54       /**
   55        * Obtains this Print Job's set of printing attributes.
   56        * The returned attribute set object is unmodifiable.
   57        * The returned attribute set object is a "snapshot" of this Print Job's
   58        * attribute set at the time of the {@link #getAttributes()} method
   59        * call; that is, the returned attribute set's object's contents will
   60        * not be updated if this Print Job's attribute set's contents change
   61        * in the future. To detect changes in attribute values, call
   62        * <code>getAttributes()</code> again and compare the new attribute
   63        * set to the previous attribute set; alternatively, register a
   64        * listener for print job events.
   65        * The returned value may be an empty set but should not be null.
   66        * @return the print job attributes
   67        */
   68        public PrintJobAttributeSet getAttributes();
   69   
   70       /**
   71        * Registers a listener for event occurring during this print job.
   72        * If listener is null, no exception is thrown and no action is
   73        * performed.
   74        * If listener is already registered, it will be registered again.
   75        * @see #removePrintJobListener
   76        *
   77        * @param listener  The object implementing the listener interface
   78        *
   79        */
   80       public void addPrintJobListener(PrintJobListener listener);
   81   
   82       /**
   83        * Removes a listener from this print job.
   84        * This method performs no function, nor does it throw an exception,
   85        * if the listener specified by the argument was not previously added
   86        * to this component. If listener is null, no exception is thrown and
   87        * no action is performed. If a listener was registered more than once
   88        * only one of the registrations will be removed.
   89        * @see #addPrintJobListener
   90        *
   91        * @param listener  The object implementing the listener interface
   92        */
   93       public void removePrintJobListener(PrintJobListener listener);
   94   
   95       /**
   96        * Registers a listener for changes in the specified attributes.
   97        * If listener is null, no exception is thrown and no action is
   98        * performed.
   99        * To determine the attribute updates that may be reported by this job,
  100        * a client can call <code>getAttributes()</code> and identify the
  101        * subset that are interesting and likely to be reported to the
  102        * listener. Clients expecting to be updated about changes in a
  103        * specific job attribute should verify it is in that set, but
  104        * updates about an attribute will be made only if it changes and this
  105        * is detected by the job. Also updates may be subject to batching
  106        * by the job. To minimise overhead in print job processing it is
  107        * recommended to listen on only that subset of attributes which
  108        * are likely to change.
  109        * If the specified set is empty no attribute updates will be reported
  110        * to the listener.
  111        * If the attribute set is null, then this means to listen on all
  112        * dynamic attributes that the job supports. This may result in no
  113        * update notifications if a job can not report any attribute updates.
  114        *
  115        * If listener is already registered, it will be registered again.
  116        * @see #removePrintJobAttributeListener
  117        *
  118        * @param listener  The object implementing the listener interface
  119        * @param attributes The attributes to listen on, or null to mean
  120        * all attributes that can change, as determined by the job.
  121        */
  122       public void addPrintJobAttributeListener(
  123                                     PrintJobAttributeListener listener,
  124                                     PrintJobAttributeSet attributes);
  125   
  126       /**
  127        * Removes an attribute listener from this print job.
  128        * This method performs no function, nor does it throw an exception,
  129        * if the listener specified by the argument was not previously added
  130        * to this component. If the listener is null, no exception is thrown
  131        * and no action is performed.
  132        * If a listener is registered more than once, even for a different
  133        * set of attributes, no guarantee is made which listener is removed.
  134        * @see #addPrintJobAttributeListener
  135        *
  136        * @param listener  The object implementing the listener interface
  137        *
  138        */
  139       public void removePrintJobAttributeListener(
  140                                         PrintJobAttributeListener listener);
  141   
  142       /**
  143        * Prints a document with the specified job attributes.
  144        * This method should only be called once for a given print job.
  145        * Calling it again will not result in a new job being spooled to
  146        * the printer. The service implementation will define policy
  147        * for service interruption and recovery.
  148        * When the print method returns, printing may not yet have completed as
  149        * printing may happen asynchronously, perhaps in a different thread.
  150        * Application clients which  want to monitor the success or failure
  151        * should register a PrintJobListener.
  152        * <p>
  153        * Print service implementors should close any print data streams (ie
  154        * Reader or InputStream implementations) that they obtain
  155        * from the client doc. Robust clients may still wish to verify this.
  156        * An exception is always generated if a <code>DocFlavor</code> cannot
  157        * be printed.
  158        *
  159        * @param doc       The document to be printed. If must be a flavor
  160        *                                  supported by this PrintJob.
  161        *
  162        * @param attributes The job attributes to be applied to this print job.
  163        *        If this parameter is null then the default attributes are used.
  164        * @throws PrintException The exception additionally may implement
  165        * an interface that more precisely describes the cause of the
  166        * exception
  167        * <ul>
  168        * <li>FlavorException.
  169        *  If the document has a flavor not supported by this print job.
  170        * <li>AttributeException.
  171        *  If one or more of the attributes are not valid for this print job.
  172        * </ul>
  173        */
  174       public void print(Doc doc, PrintRequestAttributeSet attributes)
  175             throws PrintException;
  176   
  177   }

Save This Page
Home » openjdk-7 » javax » print » [javadoc | source]