-
public interface MultiDoc
Interface MultiDoc specifies the interface for an object that supplies more than one piece of print data for a Print Job. "Doc" is a short, easy-to-pronounce term that means "a piece of print data," and a "multidoc" is a group of several docs. The client passes to the Print Job an object that implements interface MultiDoc, and the Print Job calls methods on that object to obtain the print data.Interface MultiDoc provides an abstraction similar to a "linked list" of docs. A multidoc object is like a node in the linked list, containing the current doc in the list and a pointer to the next node (multidoc) in the list. The Print Job can call the multidoc's
method to get the current doc. When it's ready to go on to the next doc, the Print Job can call the multidoc'sgetDoc()
method to get the next multidoc, which contains the next doc. So Print Job code for accessing a multidoc might look like this:next()
void processMultiDoc(MultiDoc theMultiDoc) { MultiDoc current = theMultiDoc; while (current != null) { processDoc (current.getDoc()); current = current.next(); } }
Of course, interface MultiDoc can be implemented in any way that fulfills the contract; it doesn't have to use a linked list in the implementation.
To get all the print data for a multidoc print job, a Print Service proxy could use either of two patterns:
-
The interleaved pattern: Get the doc from the current multidoc. Get
the print data representation object from the current doc. Get all the print
data from the print data representation object. Get the next multidoc from
the current multidoc, and repeat until there are no more. (The code example
above uses the interleaved pattern.)
- The all-at-once pattern: Get the doc from the current multidoc, and save the doc in a list. Get the next multidoc from the current multidoc, and repeat until there are no more. Then iterate over the list of saved docs. Get the print data representation object from the current doc. Get all the print data from the print data representation object. Go to the next doc in the list, and repeat until there are no more.
To address this problem, and to simplify the design of clients providing multiple docs to a Print Job, every Print Service proxy that supports multidoc print jobs is required to access a MultiDoc object using the interleaved pattern. That is, given a MultiDoc object, the print service proxy will call
one or more times until it successfully obtains the current Doc object. The print service proxy will then obtain the current doc's print data, not proceeding until all the print data is obtained or an unrecoverable error occurs. If it is able to continue, the print service proxy will then callgetDoc()
one or more times until it successfully obtains either the next MultiDoc object or an indication that there are no more. An implementation of interface MultiDoc can assume the print service proxy will follow this interleaved pattern; for any other pattern of usage, the MultiDoc implementation's behavior is unspecified.next()
There is no restriction on the number of client threads that may be simultaneously accessing the same multidoc. Therefore, all implementations of interface MultiDoc must be designed to be multiple thread safe. In fact, a client thread could be adding docs to the end of the (conceptual) list while a Print Job thread is simultaneously obtaining docs from the beginning of the list; provided the multidoc object synchronizes the threads properly, the two threads will not interfere with each other
-
The interleaved pattern: Get the doc from the current multidoc. Get
the print data representation object from the current doc. Get all the print
data from the print data representation object. Get the next multidoc from
the current multidoc, and repeat until there are no more. (The code example
above uses the interleaved pattern.)
-
-
Method Detail
-
getDoc
Doc getDoc() throws IOException
Obtain the current doc object.- Returns:
- Current doc object.
- Throws:
IOException
- Thrown if a error ocurred reading the document.
-
next
MultiDoc next() throws IOException
Go to the multidoc object that contains the next doc object in the sequence of doc objects.- Returns:
- Multidoc object containing the next doc object, or null if there are no further doc objects.
- Throws:
IOException
- Thrown if an error occurred locating the next document
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/print/multidoc.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.