jdk/src/share/classes/javax/print/MultiDoc.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 20451 4cedf4e1560a
child 22260 c9185e010e03
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.print;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Interface MultiDoc specifies the interface for an object that supplies more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * than one piece of print data for a Print Job. "Doc" is a short,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * easy-to-pronounce term that means "a piece of print data," and a "multidoc"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * is a group of several docs. The client passes to the Print Job an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * that implements interface MultiDoc, and the Print Job calls methods on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *  that object to obtain the print data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Interface MultiDoc provides an abstraction similar to a "linked list" of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * docs. A multidoc object is like a node in the linked list, containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * current doc in the list and a pointer to the next node (multidoc) in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * list. The Print Job can call the multidoc's {@link #getDoc()
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 5506
diff changeset
    42
 * getDoc()} method to get the current doc. When it's ready to go
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * on to the next doc, the Print Job can call the multidoc's {@link #next()
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 5506
diff changeset
    44
 * next()} method to get the next multidoc, which contains the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * next doc. So Print Job code for accessing a multidoc might look like this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      void processMultiDoc(MultiDoc theMultiDoc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *          MultiDoc current = theMultiDoc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *          while (current != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *              processDoc (current.getDoc());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *              current = current.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Of course, interface MultiDoc can be implemented in any way that fulfills
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * the contract; it doesn't have to use a linked list in the implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * To get all the print data for a multidoc print job, a Print Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * proxy could use either of two patterns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <OL TYPE=1>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * The <B>interleaved</B> pattern: Get the doc from the current multidoc. Get
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * the print data representation object from the current doc. Get all the print
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * data from the print data representation object. Get the next multidoc from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * the current multidoc, and repeat until there are no more. (The code example
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * above uses the interleaved pattern.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The <B>all-at-once</B> pattern: Get the doc from the current multidoc, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * save the doc in a list. Get the next multidoc from the current multidoc, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * repeat until there are no more. Then iterate over the list of saved docs. Get
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * the print data representation object from the current doc. Get all the print
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * data from the print data representation object. Go to the next doc in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * list, and repeat until there are no more.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Now, consider a printing client that is generating print data on the fly and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * does not have the resources to store more than one piece of print data at a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * time. If the print service proxy used the all-at-once pattern to get the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * print data, it would pose a problem for such a client; the client would have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * to keep all the docs' print data around until the print service proxy comes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * back and asks for them, which the client is not able to do. To work with such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * a client, the print service proxy must use the interleaved pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * To address this problem, and to simplify the design of clients providing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
* multiple docs to a Print Job, every Print Service proxy that supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * multidoc print jobs is required to access a MultiDoc object using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * interleaved pattern. That is, given a MultiDoc object, the print service
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 5506
diff changeset
    91
 * proxy will call {@link #getDoc() getDoc()} one or more times
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * until it successfully obtains the current Doc object. The print service proxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * will then obtain the current doc's print data, not proceeding until all the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * print data is obtained or an unrecoverable error occurs. If it is able to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * continue, the print service proxy will then call {@link #next()
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 5506
diff changeset
    96
 * next()} one or more times until it successfully obtains either
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * the next MultiDoc object or an indication that there are no more. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * implementation of interface MultiDoc can assume the print service proxy will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * follow this interleaved pattern; for any other pattern of usage, the MultiDoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * implementation's behavior is unspecified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * There is no restriction on the number of client threads that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * simultaneously accessing the same multidoc. Therefore, all implementations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * interface MultiDoc must be designed to be multiple thread safe. In fact, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * client thread could be adding docs to the end of the (conceptual) list while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * a Print Job thread is simultaneously obtaining docs from the beginning of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * list; provided the multidoc object synchronizes the threads properly, the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * threads will not interfere with each other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
public interface MultiDoc {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Obtain the current doc object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @return  Current doc object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @exception  IOException
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20451
diff changeset
   120
     *     Thrown if a error occurred reading the document.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public Doc getDoc() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Go to the multidoc object that contains the next doc object in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * sequence of doc objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return  Multidoc object containing the next doc object, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * there are no further doc objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @exception  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *     Thrown if an error occurred locating the next document
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public MultiDoc next() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
}