Package com.saxonica.ee.stream.watch
Class WatchManager
java.lang.Object
net.sf.saxon.event.SequenceReceiver
com.saxonica.ee.stream.watch.WatchManager
- All Implemented Interfaces:
Result
,Receiver
,NamespaceResolver
- Direct Known Subclasses:
ConstraintChecker
This class sits on a push pipeline and evaluates the passing element and attribute
nodes. One or more Watch objects can be registered with the pipeline at any time; element
and attribute events are notified to the active Watch objects. A watch that is added immediately
after a startElement call is automatically dropped at the corresponding endElement call. If
a Watch matches a startElement call, then it becomes an active Watch; it is automatically deactivated
(but not dropped) at the corresponding endElement call.
A Watch is not itself a receiver, but it can nominate a Receiver to receive all events while it is active. It will stop receiving events when it is deactivated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stack
<List<WatchManager.ClosedownAction>> protected int
Fields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemId
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
Add a new Watch.boolean
void
Append an arbitrary item (node or atomic value) to the outputvoid
characters
(UnicodeString chars, Location locationId, int properties) Text nodevoid
close()
Notify the end of the event streamvoid
comment
(UnicodeString chars, Location locationId, int properties) Output a commentvoid
Notify the end of a document nodevoid
Notify end of elementvoid
Called during a partitioning for-each-group whenever a group is closedlong
int
getDepth()
getURIForPrefix
(String prefix, boolean useDefault) Get the namespace URI corresponding to a given prefix.protected boolean
Get an iterator over all the prefixes declared in this namespace context.void
processingInstruction
(String target, UnicodeString data, Location locationId, int properties) Processing Instructionvoid
removeWatch
(Watch watch) Remove a watchvoid
restartElement
(Watch watch) During schema validation, the startElement() event is emitted before we can examine all the streamed assertions that might apply to that element.void
setOutputter
(Outputter outputter) void
setPipelineConfiguration
(PipelineConfiguration pipelineConfiguration) Set the pipeline configurationvoid
setUnparsedEntity
(String name, String systemID, String publicID) Notify an unparsed entity URI.void
setXPathContext
(XPathContext context) void
void
startDocument
(int properties) Start of a document node.void
startElement
(NodeName elementName, SchemaType typeCode, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) Output element start tagCalled during a partitioning for-each-group whenever a new group is startedvoid
boolean
Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute eventsvoid
watchAccumulators
(MultiAccumulatorWatch multiWatch) Methods inherited from class net.sf.saxon.event.SequenceReceiver
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, open, setSystemId
-
Field Details
-
elementStackTop
protected int elementStackTop -
watchList
-
activeWatchStack
-
-
Constructor Details
-
WatchManager
Create a WatchManager- Parameters:
pipe
- the pipeline configuration
-
-
Method Details
-
setXPathContext
-
getXPathContext
-
setOutputter
-
getOutputter
-
setPipelineConfiguration
Description copied from interface:Receiver
Set the pipeline configuration- Specified by:
setPipelineConfiguration
in interfaceReceiver
- Overrides:
setPipelineConfiguration
in classSequenceReceiver
- Parameters:
pipelineConfiguration
- the pipeline configuration
-
isSkipValidation
protected boolean isSkipValidation() -
append
Append an arbitrary item (node or atomic value) to the output- Specified by:
append
in interfaceReceiver
- Specified by:
append
in classSequenceReceiver
- Parameters:
item
- the item to be appendedlocationId
- the location of the calling instruction, for diagnosticscopyNamespaces
- if the item is an element node, this indicates whether its namespaces need to be copied. Values areReceiverOption.ALL_NAMESPACES
; the default (0) means- Throws:
XPathException
- if an error occurs
-
close
Notify the end of the event stream- Specified by:
close
in interfaceReceiver
- Throws:
XPathException
- if an error occurs
-
startDocument
Start of a document node.- Specified by:
startDocument
in interfaceReceiver
- Parameters:
properties
- properties of the document node- Throws:
XPathException
- if an error occurs
-
startElement
public void startElement(NodeName elementName, SchemaType typeCode, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) throws XPathException Output element start tag- Specified by:
startElement
in interfaceReceiver
- Parameters:
elementName
- the name of the element.typeCode
- the type annotation of the element.attributes
- the attributes of this elementnamespaces
- the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elementslocation
- an object providing information about the module, line, and column where the node originatedproperties
- bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in classReceiverOption
- Throws:
XPathException
- if an error occurs
-
restartElement
During schema validation, the startElement() event is emitted before we can examine all the streamed assertions that might apply to that element. So this method can be used to process a Watch against the most recent start element event, on the basis that we might have missed it the first time round.- Throws:
XPathException
-
getDepth
public int getDepth() -
getCurrentNode
-
getCurrentEventNumber
public long getCurrentEventNumber() -
addPrearrangedWatches
- Throws:
XPathException
-
characters
public void characters(UnicodeString chars, Location locationId, int properties) throws XPathException Text node- Specified by:
characters
in interfaceReceiver
- Parameters:
chars
- The characterslocationId
- provides information such as line number and system ID.properties
- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this text node
- USE_CDATA
- Output as a CDATA section
- Throws:
XPathException
- if an error occurs
-
endElement
Notify end of element- Specified by:
endElement
in interfaceReceiver
- Throws:
XPathException
- if an error occurs
-
endDocument
Notify the end of a document node- Specified by:
endDocument
in interfaceReceiver
- Throws:
XPathException
- if an error occurs
-
comment
Output a comment- Specified by:
comment
in interfaceReceiver
- Parameters:
chars
- The content of the commentlocationId
- provides information such as line number and system ID.properties
- Additional information about the comment.- Throws:
XPathException
- if an error occurs
-
processingInstruction
public void processingInstruction(String target, UnicodeString data, Location locationId, int properties) throws XPathException Processing Instruction- Specified by:
processingInstruction
in interfaceReceiver
- Parameters:
target
- The PI name. This must be a legal name (it will not be checked).data
- The data portion of the processing instructionlocationId
- provides information such as line number and system ID.properties
- Additional information about the PI.- Throws:
XPathException
- if an error occurs
-
setUnparsedEntity
Notify an unparsed entity URI.- Specified by:
setUnparsedEntity
in interfaceReceiver
- Overrides:
setUnparsedEntity
in classSequenceReceiver
- Parameters:
name
- The name of the unparsed entitysystemID
- The system identifier of the unparsed entitypublicID
- The public identifier of the unparsed entity- Throws:
XPathException
- if an error occurs
-
addWatch
Add a new Watch. This is associated with the current level in the element stack, and is automatically closed and dropped when the current element goes out of scope.- Parameters:
watch
- the watch to be addedautoClose
- set to true if the watch is to be automatically opened as soon as it is registered, and is to be automatically closed when it goes out of scope.- Throws:
XPathException
- if any error occurs
-
removeWatch
Remove a watch- Parameters:
watch
- the watch to be removed. No error occurs if the watch is unknown or inactive.
-
getURIForPrefix
Get the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope.- Specified by:
getURIForPrefix
in interfaceNamespaceResolver
- Parameters:
prefix
- the namespace prefix. May be the zero-length string, indicating that there is no prefix. This indicates either the default namespace or the null namespace, depending on the value of useDefault.useDefault
- true if the default namespace is to be used when the prefix is "". If false, the method returns "" when the prefix is "".- Returns:
- the uri for the namespace, or null if the prefix is not in scope. The "null namespace" is represented by the pseudo-URI "".
-
iteratePrefixes
Description copied from interface:NamespaceResolver
Get an iterator over all the prefixes declared in this namespace context. This will include the default namespace (prefix="") and the XML namespace where appropriate- Specified by:
iteratePrefixes
in interfaceNamespaceResolver
- Returns:
- an iterator over all the prefixes for which a namespace binding exists, including the zero-length string to represent the null/absent prefix if it is bound
-
usesTypeAnnotations
public boolean usesTypeAnnotations()Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events- Specified by:
usesTypeAnnotations
in interfaceReceiver
- Returns:
- true if the Receiver makes any use of this information. If false, the caller may supply untyped nodes instead of supplying the type annotation
-
allowsEarlyExit
public boolean allowsEarlyExit() -
getDocumentNode
-
getMultiAccumulatorWatch
-
watchAccumulators
- Throws:
XPathException
-
startGroupingScope
Called during a partitioning for-each-group whenever a new group is started -
endGroupingScope
Called during a partitioning for-each-group whenever a group is closed- Throws:
XPathException
- if a failure occurs
-
startCapturingGroupingWatches
-
stopCapturingGroupingWatches
-