View Javadoc
1   /*
2    * Copyright 2004-2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.ibatis.common.xml;
17  
18  import org.w3c.dom.Node;
19  
20  /**
21   * A nodelet is a sort of callback or event handler that can be registered to handle an XPath event registered with the
22   * NodeParser.
23   */
24  public interface Nodelet {
25  
26    /**
27     * For a registered XPath, the NodeletParser will call the Nodelet's process method for processing.
28     *
29     * @param node
30     *          The node represents any XML node that can be registered under an XPath supported by the NodeletParser.
31     *          Possible nodes are:
32     *          <ul>
33     *          <li>Text - Use node.getNodeValue() for the text value.
34     *          <li>Attribute - Use node.getNodeValue() for the attribute value.
35     *          <li>Element - This is the most flexible type. You can get the node content and iterate over the node's
36     *          child nodes if neccessary. This is useful where a single XPath registration cannot describe the complex
37     *          structure for a given XML stanza.
38     *          </ul>
39     *
40     * @throws Exception
41     *           the exception
42     */
43    void process(Node node) throws Exception;
44  
45  }