Debian Codegraph @

net/sf/saxon/trans/rules/RuleChain.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 package net.sf.saxon.trans.rules;
9
10 /**
11 * A chain of rules: actually in this incarnation just a pointer to the first rule in the chain, the others
12 * being linked together each to the next.
13 */
14 public class RuleChain {
15
16 private Rule head;
17 public Object optimizationData; // give this a better type
18
19 /**
20 * Create an empty rule chain
21 */
22
23 public RuleChain() {
24 head = null;
25 }
26
27 /**
28 * Create an rule chain with a give rule as the head of the chain
29 * @param head the head of a chain of rules
30 */
31
32 public RuleChain(Rule head) {
33 this.head = head;
34 }
35
36 /**
37 * Get the first rule in the chain, or null if the chain is empty
38 * @return the first rule in the chain, or null if empty
39 */
40
41 public Rule head() {
42 return head;
43 }
44
45 /**
46 * Set the first rule in the chain, or null if the chain is empty
47 * @param head the first rule in the chain, or null if empty
48 */
49
50 public void setHead(Rule head) {
51 this.head = head;
52 }
53
54 /**
55 * Get the length of the rule chain
56 * @return the number of rules in the chain
57 */
58
59 public int getLength() {
60 int i = 0;
61 Rule r = head();
62 while (r != null) {
63 i++;
64 r = r.getNext();
65 }
66 return i;
67 }
68 }
69