1 16 package scriptella.configuration; 17 18 import org.w3c.dom.Element ; 19 20 import java.util.ArrayList ; 21 import java.util.Arrays ; 22 import java.util.HashSet ; 23 import java.util.List ; 24 25 26 32 public class QueryEl extends ScriptingElement { 33 public static final String TAG_NAME = "query"; 34 private List <ScriptingElement> childScriptinglElements; 35 36 public QueryEl(XmlElement element, ScriptingElement parent) { 37 super(parent); 38 configure(element); 39 } 40 41 42 public List <ScriptingElement> getChildScriptinglElements() { 43 return childScriptinglElements; 44 } 45 46 public void setChildScriptinglElements( 47 final List <ScriptingElement> childScriptinglElements) { 48 this.childScriptinglElements = childScriptinglElements; 49 } 50 51 static List <ScriptingElement> loadScriptingElements(final XmlElement element, QueryEl parent) { 52 final List <XmlElement> elements = element.getChildren(new HashSet <String >( 53 Arrays.asList(QueryEl.TAG_NAME, ScriptEl.TAG_NAME))); 54 List <ScriptingElement> scripts = new ArrayList <ScriptingElement>(elements.size()); 55 56 for (XmlElement xmlElement : elements) { 57 final Element 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 |