Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/scuflworkers/java/StringSetUnion.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.scuflworkers.java;
7   
8   import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException;
9   import java.util.*;
10  import java.io.*;
11  import java.net.*;
12  import org.embl.ebi.escience.baclava.*;
13  
14  /**
15   * Provide the union of two lists of strings, the
16   * result being a string list containing all strings
17   * that occur in either of the input lists.
18   * @author Tom Oinn
19   */
20  public class StringSetUnion implements LocalWorker {
21      
22      public String[] inputNames() {
23    return new String[]{"list1","list2"};
24      }
25      public String[] inputTypes() {
26    return new String[]{LocalWorker.STRING_ARRAY,LocalWorker.STRING_ARRAY};
27      }
28      public String[] outputNames() {
29    return new String[]{"union"};
30      }
31      public String[] outputTypes() {
32    return new String[]{LocalWorker.STRING_ARRAY};
33      }
34      
35      /**
36       * Fetch the web page pointed to by the URL supplied as the 'url'
37       * parameter into the service, the 'base' parameter specifies a 
38       * URL to use as the base for relative URL resolution.
39       */
40      public Map execute(Map inputs) throws TaskExecutionException {
41    Set results = new HashSet();
42    Collection list1 = (Collection)((DataThing)inputs.get("list1")).getDataObject();
43    Collection list2 = (Collection)((DataThing)inputs.get("list2")).getDataObject();
44    results.addAll(list1);
45    results.addAll(list2);
46    List resultList = new ArrayList();
47    resultList.addAll(results);
48    Map outputs = new HashMap();
49    outputs.put("union",new DataThing(resultList));
50    return outputs;
51      }
52  
53  }