1 package org.apache.commons.digester3.xmlrules;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Stack;
23
24 import org.apache.commons.digester3.binder.LinkedRuleBuilder;
25 import org.apache.commons.digester3.binder.RulesBinder;
26 import org.apache.commons.digester3.binder.RulesModule;
27
28
29
30
31 final class NameSpaceURIRulesBinder
32 implements RulesBinder
33 {
34
35
36 private final Stack<String> namespaceURIs = new Stack<String>();
37
38 private final RulesBinder wrappedBinder;
39
40 public NameSpaceURIRulesBinder( RulesBinder wrappedBinder )
41 {
42 this.wrappedBinder = wrappedBinder;
43 }
44
45
46
47
48
49 public void addNamespaceURI( String namespaceURI )
50 {
51 namespaceURIs.push( namespaceURI );
52 }
53
54
55
56
57 public void removeNamespaceURI()
58 {
59 namespaceURIs.pop();
60 }
61
62
63
64
65 public ClassLoader getContextClassLoader()
66 {
67 return wrappedBinder.getContextClassLoader();
68 }
69
70
71
72
73 public void addError( String messagePattern, Object... arguments )
74 {
75 wrappedBinder.addError( messagePattern, arguments );
76 }
77
78
79
80
81 public void addError( Throwable t )
82 {
83 wrappedBinder.addError( t );
84 }
85
86
87
88
89 public void install( RulesModule rulesModule )
90 {
91 wrappedBinder.install( rulesModule );
92 }
93
94
95
96
97 public LinkedRuleBuilder forPattern( String pattern )
98 {
99 return wrappedBinder.forPattern( pattern ).withNamespaceURI( namespaceURIs.peek() );
100 }
101
102 }