Debian Codegraph @

net/sf/saxon/s9api/TeeDestination.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.s9api;
9
10 import net.sf.saxon.event.PipelineConfiguration;
11 import net.sf.saxon.event.Receiver;
12 import net.sf.saxon.event.TeeOutputter;
13 import net.sf.saxon.serialize.SerializationProperties;
14
15 /**
16 * A TeeDestination allows writing to two destinations at once. For example the output of a transformation
17 * can be written simultaneously to a Serializer and to a second Transformation. By chaining together a number
18 * of TeeDestinations it is possible to write to any number of destinations at once.
19 *
20 * @since 9.1
21 */
22
23 public class TeeDestination extends AbstractDestination {
24
25 private Destination dest0;
26 private Destination dest1;
27
28 /**
29 * Create a TeeDestination: a destination which copies everything that is sent to it to two
30 * separate destinations
31 *
32 * @param destination0 the first destination
33 * @param destination1 the second destination
34 */
35
36 public TeeDestination(Destination destination0, Destination destination1) {
37 dest0 = destination0;
38 dest1 = destination1;
39 }
40
41 /**
42 * Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends
43 * a sequence of events representing the content of an XML document.
44 *
45 * @param pipe The Saxon configuration. This is supplied so that the destination can
46 * use information from the configuration (for example, a reference to the name pool)
47 * to construct or configure the returned Receiver.
48 * @param params
49 * @return the Receiver to which events are to be sent. It is the caller's responsibility to
50 * initialize this Receiver with a {@link net.sf.saxon.event.PipelineConfiguration} before calling
51 * its <code>open()</code> method.
52 * @throws net.sf.saxon.s9api.SaxonApiException
53 * if the Receiver cannot be created
54 */
55
56 /*@NotNull*/
57 public Receiver getReceiver(PipelineConfiguration pipe, SerializationProperties params) throws SaxonApiException {
58 return new TeeOutputter(dest0.getReceiver(pipe, params), dest1.getReceiver(pipe, params));
59 }
60
61 /**
62 * Close the destination, allowing resources to be released. Saxon calls this method when
63 * it has finished writing to the destination.
64 */
65
66 public void close() throws SaxonApiException {
67 dest0.close();
68 dest1.close();
69 }
70 }
71