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 classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stack<List<WatchManager.ClosedownAction>> protected intFields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemIdFields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidAdd a new Watch.booleanvoidAppend an arbitrary item (node or atomic value) to the outputvoidcharacters(UnicodeString chars, Location locationId, int properties) Text nodevoidclose()Notify the end of the event streamvoidcomment(UnicodeString chars, Location locationId, int properties) Output a commentvoidNotify the end of a document nodevoidNotify end of elementvoidCalled during a partitioning for-each-group whenever a group is closedlongintgetDepth()getURIForPrefix(String prefix, boolean useDefault) Get the namespace URI corresponding to a given prefix.protected booleanGet an iterator over all the prefixes declared in this namespace context.voidprocessingInstruction(String target, UnicodeString data, Location locationId, int properties) Processing InstructionvoidremoveWatch(Watch watch) Remove a watchvoidrestartElement(Watch watch) During schema validation, the startElement() event is emitted before we can examine all the streamed assertions that might apply to that element.voidsetOutputter(Outputter outputter) voidsetPipelineConfiguration(PipelineConfiguration pipelineConfiguration) Set the pipeline configurationvoidsetUnparsedEntity(String name, String systemID, String publicID) Notify an unparsed entity URI.voidsetXPathContext(XPathContext context) voidvoidstartDocument(int properties) Start of a document node.voidstartElement(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 startedvoidbooleanAsk whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute eventsvoidwatchAccumulators(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:ReceiverSet the pipeline configuration- Specified by:
setPipelineConfigurationin interfaceReceiver- Overrides:
setPipelineConfigurationin classSequenceReceiver- Parameters:
pipelineConfiguration- the pipeline configuration
-
isSkipValidation
protected boolean isSkipValidation() -
append
Append an arbitrary item (node or atomic value) to the output- Specified by:
appendin interfaceReceiver- Specified by:
appendin 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:
closein interfaceReceiver- Throws:
XPathException- if an error occurs
-
startDocument
Start of a document node.- Specified by:
startDocumentin 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:
startElementin 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:
charactersin 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:
endElementin interfaceReceiver- Throws:
XPathException- if an error occurs
-
endDocument
Notify the end of a document node- Specified by:
endDocumentin interfaceReceiver- Throws:
XPathException- if an error occurs
-
comment
Output a comment- Specified by:
commentin 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:
processingInstructionin 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:
setUnparsedEntityin interfaceReceiver- Overrides:
setUnparsedEntityin 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:
getURIForPrefixin 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:NamespaceResolverGet 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:
iteratePrefixesin 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:
usesTypeAnnotationsin 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
-