Example usage for org.apache.commons.collections CollectionUtils addAll

List of usage examples for org.apache.commons.collections CollectionUtils addAll

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils addAll.

Prototype

public static void addAll(Collection collection, Object[] elements) 

Source Link

Document

Adds all elements in the array to the given collection.

Usage

From source file:com.cyclopsgroup.waterview.jelly.JellyRunner.java

/**
 * Main entry to run a script//w w w. jav a  2 s . c o m
 * 
 * @param args Script paths
 * @throws Exception Throw it out
 */
public static final void main(String[] args) throws Exception {
    List scripts = new ArrayList();
    for (int i = 0; i < args.length; i++) {
        String path = args[i];
        File file = new File(path);
        if (file.isFile()) {
            scripts.add(file.toURL());
        } else {
            Enumeration enu = JellyRunner.class.getClassLoader().getResources(path);
            CollectionUtils.addAll(scripts, enu);
        }
    }
    if (scripts.isEmpty()) {
        System.out.println("No script to run, return!");
        return;
    }

    String basedir = new File("").getAbsolutePath();
    Properties initProperties = new Properties(System.getProperties());
    initProperties.setProperty("basedir", basedir);
    initProperties.setProperty("plexus.home", basedir);

    WaterviewPlexusContainer container = new WaterviewPlexusContainer();
    for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) {
        String initPropertyName = (String) j.next();
        container.addContextValue(initPropertyName, initProperties.get(initPropertyName));
    }

    container.addContextValue(Waterview.INIT_PROPERTIES, initProperties);
    container.initialize();
    container.start();

    JellyEngine je = (JellyEngine) container.lookup(JellyEngine.ROLE);
    JellyContext jc = new JellyContext(je.getGlobalContext());

    for (Iterator i = scripts.iterator(); i.hasNext();) {
        URL script = (URL) i.next();
        System.out.print("Running script " + script);
        jc.runScript(script, XMLOutput.createDummyXMLOutput());
        System.out.println("... Done!");
    }
    container.dispose();
}

From source file:com.cyclopsgroup.waterview.jelly.JellyScriptsRunner.java

/**
 * Main entry to run a script/*from   w w  w .j  a v  a  2s .  co m*/
 *
 * @param args Script paths
 * @throws Exception Throw it out
 */
public static final void main(String[] args) throws Exception {
    List scripts = new ArrayList();
    for (int i = 0; i < args.length; i++) {
        String path = args[i];
        File file = new File(path);
        if (file.isFile()) {
            scripts.add(file.toURL());
        } else {
            Enumeration enu = JellyScriptsRunner.class.getClassLoader().getResources(path);
            CollectionUtils.addAll(scripts, enu);
        }
    }
    if (scripts.isEmpty()) {
        System.out.println("No script to run, return!");
        return;
    }

    String basedir = new File("").getAbsolutePath();
    Properties initProperties = new Properties(System.getProperties());
    initProperties.setProperty("basedir", basedir);
    initProperties.setProperty("plexus.home", basedir);

    WaterviewPlexusContainer container = new WaterviewPlexusContainer();
    for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) {
        String initPropertyName = (String) j.next();
        container.addContextValue(initPropertyName, initProperties.get(initPropertyName));
    }

    container.addContextValue(Waterview.INIT_PROPERTIES, initProperties);
    container.initialize();
    container.start();

    JellyEngine je = (JellyEngine) container.lookup(JellyEngine.ROLE);
    JellyContext jc = new JellyContext(je.getGlobalContext());
    XMLOutput output = XMLOutput.createXMLOutput(System.out);
    for (Iterator i = scripts.iterator(); i.hasNext();) {
        URL script = (URL) i.next();
        System.out.print("Running script " + script);
        ExtendedProperties ep = new ExtendedProperties();
        ep.putAll(initProperties);
        ep.load(script.openStream());
        for (Iterator j = ep.getKeys("script"); j.hasNext();) {
            String name = (String) j.next();
            if (name.endsWith(".file")) {
                File file = new File(ep.getString(name));
                if (file.exists()) {
                    System.out.println("Runner jelly file " + file);
                    jc.runScript(file, output);
                }
            } else if (name.endsWith(".resource")) {
                Enumeration k = JellyScriptsRunner.class.getClassLoader().getResources(ep.getString(name));
                while (j != null && k.hasMoreElements()) {
                    URL s = (URL) k.nextElement();
                    System.out.println("Running jelly script " + s);
                    jc.runScript(s, output);
                }
            }
        }
        //jc.runScript( script, XMLOutput.createDummyXMLOutput() );
        System.out.println("... Done!");
    }
    container.dispose();
}

From source file:info.magnolia.beanmerger.BeanMergerUtil.java

public static <T> T merge(Object... sources) {
    final ArrayList list = new ArrayList();
    CollectionUtils.addAll(list, sources);
    return (T) merger.merge(list);
}

From source file:com.redhat.rhn.testing.ServletTestUtils.java

private static Set createQueryStringParameterSet(String queryString) {
    Set parameterSet = new TreeSet();
    CollectionUtils.addAll(parameterSet, queryString.split("&"));

    return parameterSet;
}

From source file:com.creditcloud.interestbearing.ta.message.platform.PlatformQueryAllResponseMessage.java

public void setPlatforms(PlatformMetadata[] platforms) {
    List<PlatformMetadata> list = new ArrayList<>();
    CollectionUtils.addAll(list, platforms);
    this.platforms = list;
}

From source file:com.creditcloud.interestbearing.ta.message.asset.QueryPlatformAssetGapResponseMessage.java

public void setFundGaps(ProductAssetGapMetadata[] fundGaps) {
    List<ProductAssetGapMetadata> list = new ArrayList<>();
    CollectionUtils.addAll(list, fundGaps);
    this.fundGaps = list;
}

From source file:com.mycollab.db.arguments.SetSearchField.java

public SetSearchField(T... vals) {
    if (ArrayUtils.isNotEmpty(vals)) {
        CollectionUtils.addAll(values, vals);
    }

    this.operation = AND;
}

From source file:com.esofthead.mycollab.core.arguments.SetSearchField.java

public SetSearchField(String oper, T... vals) {
    if (!ArrayUtils.isEmpty(vals)) {
        CollectionUtils.addAll(values, vals);
    }

    this.operation = oper;
}

From source file:com.eryansky.common.orm.core.MatchValue.java

/**
 * andValueSeparatororValueSeparator()//from  www .ja v a2  s  .  com
 * 
 * @param matchValue 
 * @param type 
 * @param andValueSeparator 
 * @param orValueSeparator 
 * 
 * @return {@link com.eryansky.common.orm.core.MatchValue}
 */
public static MatchValue createMatchValueModel(String matchValue, Class<?> type, String andValueSeparator,
        String orValueSeparator) {

    List<Object> values = new ArrayList<Object>();

    if (StringUtils.contains(matchValue, andValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, andValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(false, values);
    } else if (StringUtils.contains(matchValue, orValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, orValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(true, values);
    } else {
        values.add(ConvertUtils.convertToObject(matchValue, type));
        return new MatchValue(false, values);
    }

}

From source file:com.cyclopsgroup.waterview.web.taglib.CollectionTabularDataTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*  w w  w.  j a  v a 2s .  com*/
protected void processTag(XMLOutput output) throws Exception {
    requireAttribute("items");
    requireParent(TableControlTag.class);

    List list = new ArrayList();
    CollectionUtils.addAll(list, TypeUtils.iterate(getItems()));
    ((TableControlTag) getParent()).setTabularData(new CollectionLargeList(list));
}