2362N/A * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 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 * 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, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Interface MultiDoc specifies the interface for an object that supplies more 0N/A * than one piece of print data for a Print Job. "Doc" is a short, 0N/A * easy-to-pronounce term that means "a piece of print data," and a "multidoc" 0N/A * is a group of several docs. The client passes to the Print Job an object 0N/A * that implements interface MultiDoc, and the Print Job calls methods on 0N/A * that object to obtain the print data. 0N/A * Interface MultiDoc provides an abstraction similar to a "linked list" of 0N/A * docs. A multidoc object is like a node in the linked list, containing the 0N/A * current doc in the list and a pointer to the next node (multidoc) in the 0N/A * list. The Print Job can call the multidoc's {@link #getDoc() 0N/A * <CODE>getDoc()</CODE>} method to get the current doc. When it's ready to go 0N/A * on to the next doc, the Print Job can call the multidoc's {@link #next() 0N/A * <CODE>next()</CODE>} method to get the next multidoc, which contains the 0N/A * next doc. So Print Job code for accessing a multidoc might look like this: 0N/A * void processMultiDoc(MultiDoc theMultiDoc) { 0N/A * MultiDoc current = theMultiDoc; 0N/A * while (current != null) { 0N/A * processDoc (current.getDoc()); 0N/A * current = current.next(); 0N/A * Of course, interface MultiDoc can be implemented in any way that fulfills 0N/A * the contract; it doesn't have to use a linked list in the implementation. 0N/A * To get all the print data for a multidoc print job, a Print Service 0N/A * proxy could use either of two patterns: 0N/A * The <B>interleaved</B> pattern: Get the doc from the current multidoc. Get 0N/A * the print data representation object from the current doc. Get all the print 0N/A * data from the print data representation object. Get the next multidoc from 0N/A * the current multidoc, and repeat until there are no more. (The code example 0N/A * above uses the interleaved pattern.) 0N/A * The <B>all-at-once</B> pattern: Get the doc from the current multidoc, and 0N/A * save the doc in a list. Get the next multidoc from the current multidoc, and 0N/A * repeat until there are no more. Then iterate over the list of saved docs. Get 0N/A * the print data representation object from the current doc. Get all the print 0N/A * data from the print data representation object. Go to the next doc in the 0N/A * list, and repeat until there are no more. 0N/A * Now, consider a printing client that is generating print data on the fly and 0N/A * does not have the resources to store more than one piece of print data at a 0N/A * time. If the print service proxy used the all-at-once pattern to get the 0N/A * print data, it would pose a problem for such a client; the client would have 0N/A * to keep all the docs' print data around until the print service proxy comes 0N/A * back and asks for them, which the client is not able to do. To work with such 0N/A * a client, the print service proxy must use the interleaved pattern. 0N/A * To address this problem, and to simplify the design of clients providing 0N/A* multiple docs to a Print Job, every Print Service proxy that supports 0N/A * multidoc print jobs is required to access a MultiDoc object using the 0N/A * interleaved pattern. That is, given a MultiDoc object, the print service 0N/A * proxy will call {@link #getDoc() <CODE>getDoc()</CODE>} one or more times 0N/A * until it successfully obtains the current Doc object. The print service proxy 0N/A * will then obtain the current doc's print data, not proceeding until all the 0N/A * print data is obtained or an unrecoverable error occurs. If it is able to 0N/A * continue, the print service proxy will then call {@link #next() 0N/A * <CODE>next()</CODE>} one or more times until it successfully obtains either 0N/A * the next MultiDoc object or an indication that there are no more. An 0N/A * implementation of interface MultiDoc can assume the print service proxy will 0N/A * follow this interleaved pattern; for any other pattern of usage, the MultiDoc 0N/A * implementation's behavior is unspecified. 0N/A * There is no restriction on the number of client threads that may be 0N/A * simultaneously accessing the same multidoc. Therefore, all implementations of 0N/A * interface MultiDoc must be designed to be multiple thread safe. In fact, a 0N/A * client thread could be adding docs to the end of the (conceptual) list while 0N/A * a Print Job thread is simultaneously obtaining docs from the beginning of the 0N/A * list; provided the multidoc object synchronizes the threads properly, the two 0N/A * threads will not interfere with each other 0N/A * Obtain the current doc object. 0N/A * @return Current doc object. 0N/A * @exception IOException 0N/A * Thrown if a error ocurred reading the document. 0N/A * Go to the multidoc object that contains the next doc object in the 0N/A * sequence of doc objects. 0N/A * @return Multidoc object containing the next doc object, or null if 0N/A * there are no further doc objects. 0N/A * @exception IOException 0N/A * Thrown if an error occurred locating the next document