KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > configuration > QueryEl


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.configuration;
17
18 import org.w3c.dom.Element JavaDoc;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Arrays JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.List JavaDoc;
24
25
26 /**
27  * TODO: Add documentation
28  *
29  * @author Fyodor Kupolov
30  * @version 1.0
31  */

32 public class QueryEl extends ScriptingElement {
33     public static final String JavaDoc TAG_NAME = "query";
34     private List JavaDoc<ScriptingElement> childScriptinglElements;
35
36     public QueryEl(XmlElement element, ScriptingElement parent) {
37         super(parent);
38         configure(element);
39     }
40
41
42     public List JavaDoc<ScriptingElement> getChildScriptinglElements() {
43         return childScriptinglElements;
44     }
45
46     public void setChildScriptinglElements(
47             final List JavaDoc<ScriptingElement> childScriptinglElements) {
48         this.childScriptinglElements = childScriptinglElements;
49     }
50
51     static List JavaDoc<ScriptingElement> loadScriptingElements(final XmlElement element, QueryEl parent) {
52         final List JavaDoc<XmlElement> elements = element.getChildren(new HashSet JavaDoc<String JavaDoc>(
53                 Arrays.asList(QueryEl.TAG_NAME, ScriptEl.TAG_NAME)));
54         List JavaDoc<ScriptingElement> scripts = new ArrayList JavaDoc<ScriptingElement>(elements.size());
55
56         for (XmlElement xmlElement : elements) {
57             final Element JavaDoc e = xmlElement.getElement();
58
59             if (ScriptEl.TAG_NAME.equals(e.getTagName())) {
60                 final ScriptEl s = new ScriptEl(xmlElement, parent);
61                 scripts.add(s);
62             } else if (QueryEl.TAG_NAME.equals(e.getTagName())) {
63                 final QueryEl q = new QueryEl(xmlElement, parent);
64                 scripts.add(q);
65             }
66         }
67
68         return scripts;
69     }
70
71     public void configure(final XmlElement element) {
72         super.configure(element);
73         setChildScriptinglElements(loadScriptingElements(element, this));
74     }
75 }
76
Popular Tags