1
1
/*
2
- * Copyright 2002-2007 the original author or authors.
2
+ * Copyright 2002-2008 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -46,19 +46,22 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler {
46
46
* Stores the {@link BeanDefinitionParser} implementations keyed by the
47
47
* local name of the {@link Element Elements} they handle.
48
48
*/
49
- private final Map parsers = new HashMap ();
49
+ private final Map <String , BeanDefinitionParser > parsers =
50
+ new HashMap <String , BeanDefinitionParser >();
50
51
51
52
/**
52
53
* Stores the {@link BeanDefinitionDecorator} implementations keyed by the
53
54
* local name of the {@link Element Elements} they handle.
54
55
*/
55
- private final Map decorators = new HashMap ();
56
+ private final Map <String , BeanDefinitionDecorator > decorators =
57
+ new HashMap <String , BeanDefinitionDecorator >();
56
58
57
59
/**
58
- * Stores the {@link BeanDefinitionParser } implementations keyed by the local
60
+ * Stores the {@link BeanDefinitionDecorator } implementations keyed by the local
59
61
* name of the {@link Attr Attrs} they handle.
60
62
*/
61
- private final Map attributeDecorators = new HashMap ();
63
+ private final Map <String , BeanDefinitionDecorator > attributeDecorators =
64
+ new HashMap <String , BeanDefinitionDecorator >();
62
65
63
66
64
67
/**
@@ -74,29 +77,14 @@ public final BeanDefinition parse(Element element, ParserContext parserContext)
74
77
* the local name of the supplied {@link Element}.
75
78
*/
76
79
private BeanDefinitionParser findParserForElement (Element element , ParserContext parserContext ) {
77
- BeanDefinitionParser parser = ( BeanDefinitionParser ) this .parsers .get (element .getLocalName ());
80
+ BeanDefinitionParser parser = this .parsers .get (element .getLocalName ());
78
81
if (parser == null ) {
79
82
parserContext .getReaderContext ().fatal (
80
83
"Cannot locate BeanDefinitionParser for element [" + element .getLocalName () + "]" , element );
81
84
}
82
85
return parser ;
83
86
}
84
87
85
- /**
86
- * Locate the {@link BeanDefinitionParser} from the register implementations using
87
- * the local name of the supplied {@link Element}.
88
- * @deprecated as of Spring 2.0.2; there should be no need to call this directly.
89
- */
90
- @ Deprecated
91
- protected final BeanDefinitionParser findParserForElement (Element element ) {
92
- BeanDefinitionParser parser = (BeanDefinitionParser ) this .parsers .get (element .getLocalName ());
93
- if (parser == null ) {
94
- throw new IllegalStateException (
95
- "Cannot locate BeanDefinitionParser for element [" + element .getLocalName () + "]" );
96
- }
97
- return parser ;
98
- }
99
-
100
88
/**
101
89
* Decorates the supplied {@link Node} by delegating to the {@link BeanDefinitionDecorator} that
102
90
* is registered to handle that {@link Node}.
@@ -115,10 +103,10 @@ public final BeanDefinitionHolder decorate(
115
103
private BeanDefinitionDecorator findDecoratorForNode (Node node , ParserContext parserContext ) {
116
104
BeanDefinitionDecorator decorator = null ;
117
105
if (node instanceof Element ) {
118
- decorator = ( BeanDefinitionDecorator ) this .decorators .get (node .getLocalName ());
106
+ decorator = this .decorators .get (node .getLocalName ());
119
107
}
120
108
else if (node instanceof Attr ) {
121
- decorator = ( BeanDefinitionDecorator ) this .attributeDecorators .get (node .getLocalName ());
109
+ decorator = this .attributeDecorators .get (node .getLocalName ());
122
110
}
123
111
else {
124
112
parserContext .getReaderContext ().fatal (
@@ -131,32 +119,6 @@ else if (node instanceof Attr) {
131
119
return decorator ;
132
120
}
133
121
134
- /**
135
- * Locate the {@link BeanDefinitionParser} from the register implementations using
136
- * the local name of the supplied {@link Node}. Supports both {@link Element Elements}
137
- * and {@link Attr Attrs}.
138
- * @deprecated as of Spring 2.0.2; there should be no need to call this directly.
139
- */
140
- @ Deprecated
141
- protected final BeanDefinitionDecorator findDecoratorForNode (Node node ) {
142
- BeanDefinitionDecorator decorator = null ;
143
- if (node instanceof Element ) {
144
- decorator = (BeanDefinitionDecorator ) this .decorators .get (node .getLocalName ());
145
- }
146
- else if (node instanceof Attr ) {
147
- decorator = (BeanDefinitionDecorator ) this .attributeDecorators .get (node .getLocalName ());
148
- }
149
- else {
150
- throw new IllegalStateException (
151
- "Cannot decorate based on Nodes of type [" + node .getClass ().getName () + "]" );
152
- }
153
- if (decorator == null ) {
154
- throw new IllegalStateException ("Cannot locate BeanDefinitionDecorator for " +
155
- (node instanceof Element ? "element" : "attribute" ) + " [" + node .getLocalName () + "]" );
156
- }
157
- return decorator ;
158
- }
159
-
160
122
161
123
/**
162
124
* Subclasses can call this to register the supplied {@link BeanDefinitionParser} to
@@ -172,19 +134,17 @@ protected final void registerBeanDefinitionParser(String elementName, BeanDefini
172
134
* handle the specified element. The element name is the local (non-namespace qualified)
173
135
* name.
174
136
*/
175
- protected final void registerBeanDefinitionDecorator (String elementName , BeanDefinitionDecorator decorator ) {
176
- this .decorators .put (elementName , decorator );
137
+ protected final void registerBeanDefinitionDecorator (String elementName , BeanDefinitionDecorator dec ) {
138
+ this .decorators .put (elementName , dec );
177
139
}
178
140
179
141
/**
180
142
* Subclasses can call this to register the supplied {@link BeanDefinitionDecorator} to
181
143
* handle the specified attribute. The attribute name is the local (non-namespace qualified)
182
144
* name.
183
145
*/
184
- protected final void registerBeanDefinitionDecoratorForAttribute (
185
- String attributeName , BeanDefinitionDecorator decorator ) {
186
-
187
- this .attributeDecorators .put (attributeName , decorator );
146
+ protected final void registerBeanDefinitionDecoratorForAttribute (String attrName , BeanDefinitionDecorator dec ) {
147
+ this .attributeDecorators .put (attrName , dec );
188
148
}
189
149
190
150
}
0 commit comments