24
24
import org .w3c .dom .Node ;
25
25
import org .w3c .dom .NodeList ;
26
26
27
- import java .util .ArrayList ;
28
- import java .util .Collections ;
29
- import java .util .List ;
30
27
import java .util .Properties ;
31
28
32
29
/**
@@ -119,14 +116,13 @@ private String getStringAttribute(Node node, String name) {
119
116
* @return variables context from include instance (no inherited values)
120
117
*/
121
118
private Properties getVariablesContext (Node node , Properties inheritedVariablesContext ) {
122
- List <Node > subElements = getSubElements (node );
123
- if (subElements .isEmpty ()) {
124
- return new Properties ();
125
- } else {
126
- Properties variablesContext = new Properties ();
127
- for (Node variableValue : subElements ) {
128
- String name = getStringAttribute (variableValue , "name" );
129
- String value = getStringAttribute (variableValue , "value" );
119
+ Properties variablesContext = new Properties ();
120
+ NodeList children = node .getChildNodes ();
121
+ for (int i = 0 ; i < children .getLength (); i ++) {
122
+ Node n = children .item (i );
123
+ if (n .getNodeType () == Node .ELEMENT_NODE ) {
124
+ String name = getStringAttribute (n , "name" );
125
+ String value = getStringAttribute (n , "value" );
130
126
// Replace variables inside
131
127
value = PropertyParser .parse (value , inheritedVariablesContext );
132
128
// Push new value
@@ -135,24 +131,8 @@ private Properties getVariablesContext(Node node, Properties inheritedVariablesC
135
131
throw new BuilderException ("Variable " + name + " defined twice in the same include definition" );
136
132
}
137
133
}
138
- return variablesContext ;
139
- }
140
- }
141
-
142
- private List <Node > getSubElements (Node node ) {
143
- NodeList children = node .getChildNodes ();
144
- if (children .getLength () == 0 ) {
145
- return Collections .emptyList ();
146
- } else {
147
- List <Node > elements = new ArrayList <Node >();
148
- for (int i = 0 ; i < children .getLength (); i ++) {
149
- Node n = children .item (i );
150
- if (n .getNodeType () == Node .ELEMENT_NODE ) {
151
- elements .add (n );
152
- }
153
- }
154
- return elements ;
155
134
}
135
+ return variablesContext ;
156
136
}
157
137
158
138
}
0 commit comments