Debian Codegraph @

net/sf/saxon/lib/RawResult.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2017 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.lib;
9
10 import net.sf.saxon.om.Item;
11 import net.sf.saxon.om.Sequence;
12 import net.sf.saxon.value.SequenceExtent;
13
14 import javax.xml.transform.Result;
15 import java.util.ArrayList;
16 import java.util.List;
17
18
19 /**
20 * This class is an implementation of the JAXP Result interface. It can be used to indicate that
21 * the output of a transformation (either the principal result, or a secondary result) should be
22 * delivered in "raw" form, that is, without building a tree (equivalently, without performing
23 * "sequence normalization"). Once output has been written to a RawResult, it is available to
24 * the caller in the form of a {@link Sequence}.
25 *
26 * @author Michael H. Kay
27 */
28
29 public class RawResult implements Result {
30
31 private String systemId;
32 private List<Item> content = new ArrayList<Item>();
33
34 /**
35 * Set the system identifier for this Result.
36 * <p>
37 * <p>If the Result is not to be written to a file, the system identifier is optional.
38 * The application may still want to provide one, however, for use in error messages
39 * and warnings, or to resolve relative output identifiers.</p>
40 *
41 * @param systemId The system identifier as a URI string.
42 */
43 @Override
44 public void setSystemId(String systemId) {
45 this.systemId = systemId;
46 }
47
48 /**
49 * Get the system identifier that was set with setSystemId.
50 *
51 * @return The system identifier that was set with setSystemId,
52 * or null if setSystemId was not called.
53 */
54 @Override
55 public String getSystemId() {
56 return systemId;
57 }
58
59 /**
60 * Method intended for internal use to append an item to the result
61 */
62
63 public void append(Item item) {
64 content.add(item);
65 }
66
67 /**
68 * On completion, get the sequence that has been written to this result object
69 */
70
71 public Sequence<?> getResultSequence() {
72 return new SequenceExtent<>(content);
73 }
74 }
75