| 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.event; |
| 9 | |
| 10 | import net.sf.saxon.om.NodeInfo; |
| 11 | |
| 12 | /** |
| 13 | * A BuilderMonitor can be inserted into a pipeline immediately in front of a Builder. During tree construction, |
| 14 | * the method markNextNode() can be called to request that the next node to be created is treated specially by |
| 15 | * remembering the current position on the tree; on completion of the tree construction, the method getMarkedNode() |
| 16 | * can be called to return the NodeInfo that was created immediately after calling markNextNode(). |
| 17 | */ |
| 18 | public abstract class BuilderMonitor extends ProxyReceiver { |
| 19 | |
| 20 | public BuilderMonitor(Receiver next) { |
| 21 | super(next); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Indicate that the next node to be created will be of a given type, and request the monitor to remember |
| 26 | * the identity of this node. |
| 27 | * |
| 28 | * @param nodeKind the kind of node that will be created next. This will always be an element, text, comment, |
| 29 | * or processing-instruction node |
| 30 | */ |
| 31 | |
| 32 | public abstract void markNextNode(int nodeKind); |
| 33 | |
| 34 | /** |
| 35 | * Indicate that the most recently written attribute whose name matches that of the supplied node |
| 36 | * is to act as the marked node |
| 37 | * @param origin the attribute in the input corresponding to the marked node in the output |
| 38 | */ |
| 39 | |
| 40 | public abstract void markAttributeNode(NodeInfo origin); |
| 41 | |
| 42 | /** |
| 43 | * Indicate that the most recently written attribute whose name matches that of the supplied node |
| 44 | * is to act as the marked node |
| 45 | * @param origin the attribute in the input corresponding to the marked node in the output |
| 46 | */ |
| 47 | |
| 48 | public abstract void markNamespaceNode(NodeInfo origin); |
| 49 | |
| 50 | /** |
| 51 | * On completion of tree building, get the node that was marked using markNextNode(). |
| 52 | * |
| 53 | * @return the marked node, or null if none was marked |
| 54 | */ |
| 55 | |
| 56 | public abstract NodeInfo getMarkedNode(); |
| 57 | } |
| 58 |