All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scriptella.configuration.QueryEl Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2006-2012 The Scriptella Project Team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package scriptella.configuration;

import org.w3c.dom.Element;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;


/**
 * TODO: Add documentation
 *
 * @author Fyodor Kupolov
 * @version 1.0
 */
public class QueryEl extends ScriptingElement {
    public static final String TAG_NAME = "query";
    private List childScriptinglElements;

    public QueryEl(XmlElement element, ScriptingElement parent) {
        super(parent);
        configure(element);
    }


    public List getChildScriptinglElements() {
        return childScriptinglElements;
    }

    public void setChildScriptinglElements(
            final List childScriptinglElements) {
        this.childScriptinglElements = childScriptinglElements;
    }

    static List loadScriptingElements(final XmlElement element, QueryEl parent) {
        final List elements = element.getChildren(new HashSet(
                Arrays.asList(QueryEl.TAG_NAME, ScriptEl.TAG_NAME)));
        List scripts = new ArrayList(elements.size());

        for (XmlElement xmlElement : elements) {
            final Element e = xmlElement.getElement();

            if (ScriptEl.TAG_NAME.equals(e.getTagName())) {
                final ScriptEl s = new ScriptEl(xmlElement, parent);
                scripts.add(s);
            } else if (QueryEl.TAG_NAME.equals(e.getTagName())) {
                final QueryEl q = new QueryEl(xmlElement, parent);
                scripts.add(q);
            }
        }

        return scripts;
    }

    public void configure(final XmlElement element) {
        super.configure(element);
        setChildScriptinglElements(loadScriptingElements(element, this));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy