1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1.ber.digester ;
18
19
20 import java.util.ArrayList;
21 import java.util.Collections;
22 import java.util.List;
23
24 import org.apache.commons.collections.primitives.IntStack;
25
26
27 /***
28 * A base Rules implementation using a fast pattern match.
29 *
30 * @author <a href="mailto:dev@directory.apache.org">
31 * Apache Directory Project</a>
32 * @version $Rev: 157644 $
33 */
34 public class RulesBase implements Rules
35 {
36 private TagTree tagTree ;
37 private ArrayList rules ;
38 private BERDigester digester ;
39
40
41 /***
42 * Creates a base Rules instance.
43 */
44 public RulesBase()
45 {
46 tagTree = new TagTree() ;
47 rules = new ArrayList() ;
48 }
49
50
51
52
53
54
55 public void setDigester( BERDigester digester )
56 {
57 this.digester = digester ;
58 }
59
60
61
62
63
64 public BERDigester getDigester()
65 {
66 return digester ;
67 }
68
69
70
71
72
73
74 public void add( int[] pattern, Rule rule )
75 {
76 tagTree.addRule( pattern, rule ) ;
77 rules.add( rule ) ;
78 }
79
80
81
82
83
84 public void clear()
85 {
86 tagTree = new TagTree() ;
87 rules.clear() ;
88 }
89
90
91
92
93
94 public List match( int[] pattern )
95 {
96 return tagTree.match( new IntStack( pattern ) ) ;
97 }
98
99
100
101
102
103 public List match( IntStack pattern )
104 {
105 return tagTree.match( pattern ) ;
106 }
107
108
109
110
111
112 public List rules()
113 {
114 return Collections.unmodifiableList( rules ) ;
115 }
116 }