Debian Codegraph @

net/sf/saxon/event/EventMonitor.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
9 package net.sf.saxon.event;
10
11 import net.sf.saxon.expr.parser.Location;
12 import net.sf.saxon.om.Item;
13 import net.sf.saxon.om.NamespaceBindingSet;
14 import net.sf.saxon.om.NodeName;
15 import net.sf.saxon.trans.XPathException;
16 import net.sf.saxon.type.SchemaType;
17 import net.sf.saxon.type.SimpleType;
18
19 /**
20 * An <tt>EventMonitor</tt> is a filter that passes all events down the pipeline unchanged,
21 * keeping a note of whether any data has passed through the filter. At any stage it is possible
22 * to ask whether any data has been written.
23 * @since 9.9
24 */
25
26 public class EventMonitor extends ProxyReceiver {
27
28 boolean written = false;
29
30 public EventMonitor(Receiver next){
31 super(next);
32 }
33
34 @Override
35 public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException {
36 written = true;
37 super.startElement(elemName, typeCode, location, properties);
38 }
39
40 @Override
41 public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException {
42 written = true;
43 super.namespace(namespaceBindings, properties);
44 }
45
46 @Override
47 public void attribute(NodeName attName, SimpleType typeCode, CharSequence value, Location location, int properties) throws XPathException {
48 written = true;
49 super.attribute(attName, typeCode, value, location, properties);
50 }
51
52 @Override
53 public void characters(CharSequence chars, Location location, int properties) throws XPathException {
54 written = true;
55 super.characters(chars, location, properties);
56 }
57
58 @Override
59 public void processingInstruction(String name, CharSequence data, Location location, int properties) throws XPathException {
60 written = true;
61 super.processingInstruction(name, data, location, properties);
62 }
63
64 @Override
65 public void comment(CharSequence content, Location location, int properties) throws XPathException {
66 written = true;
67 super.comment(content, location, properties);
68 }
69
70 @Override
71 public void append(Item item, Location location, int properties) throws XPathException {
72 written = true;
73 super.append(item, location, properties);
74 }
75
76 public boolean hasBeenWrittenTo() {
77 return written;
78 }
79 }
80