Search in sources :

Example 96 with Iterator

use of java.util.Iterator in project cogtool by cogtool.

the class JListBinding method put.

public void put(IValidatable bean) {
    try {
        DefaultListModel model = new DefaultListModel();
        List list = (List) PropertyUtils.getProperty(bean, _property);
        if (list != null) {
            for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                model.addElement(iter.next());
            }
        }
        _list.setModel(model);
    } catch (Exception e) {
        throw new BindingException(e);
    }
}
Also used : Iterator(java.util.Iterator) DefaultListModel(javax.swing.DefaultListModel) List(java.util.List) JList(javax.swing.JList) ArrayList(java.util.ArrayList)

Example 97 with Iterator

use of java.util.Iterator in project cglib by cglib.

the class BridgeMethodResolver method resolveAll.

/**
     * Finds all bridge methods that are being called with invokespecial &
     * returns them.
     */
public Map resolveAll() {
    Map resolved = new HashMap();
    for (Iterator entryIter = declToBridge.entrySet().iterator(); entryIter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) entryIter.next();
        Class owner = (Class) entry.getKey();
        Set bridges = (Set) entry.getValue();
        try {
            new ClassReader(classLoader.getResourceAsStream(owner.getName().replace('.', '/') + ".class")).accept(new BridgedFinder(bridges, resolved), ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
        } catch (IOException ignored) {
        }
    }
    return resolved;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ClassReader(org.objectweb.asm.ClassReader) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 98 with Iterator

use of java.util.Iterator in project lucida by claritylab.

the class FeatureExtractor method printFeaturesFromQuestions.

/**
     * Prints the features generated for each example in an input file.  If feature
     * types are included as command-line arguments, only those types are printed. 
     * Otherwise, all features are printed.
     * 
     * @param questionSetFileName the name of the file containing the dataset to load
     * @param features a List of the features to print
     */
public void printFeaturesFromQuestions(String questionSetFileName, List<String> features) {
    String questions = IOUtil.readFile(questionSetFileName);
    for (String question : questions.split("[\\n\\r\\f]")) {
        Instance instance = createInstance(question);
        StringBuilder sb = new StringBuilder();
        if (features.size() > 0) {
            for (Iterator it = instance.binaryFeatureIterator(); it.hasNext(); ) {
                Feature feat = (Feature) it.next();
                String name = "";
                for (String s : feat.getName()) name += "." + s;
                name = name.replaceFirst(".", "");
                if (features.contains(feat.getName()[0]))
                    sb.append(name + "  ");
            }
            System.out.println(sb.toString() + " " + question);
        } else
            System.out.println(instance + " " + question);
    }
}
Also used : Instance(edu.cmu.minorthird.classify.Instance) Iterator(java.util.Iterator) Feature(edu.cmu.minorthird.classify.Feature)

Example 99 with Iterator

use of java.util.Iterator in project cogtool by cogtool.

the class ProjectController method getTraces.

// getTraces
/**
     * Utility to accumulate all of the (ACT-R) trace lines for the given
     * selected task and design intersections and the given algorithm.
     * <p>
     * If there are no selected tasks, accumulate all trace lines for the
     * selected design and all tasks.  If there is no selected design,
     * accumulate all trace lines for selected tasks and all designs.
     * An empty list is returned if nothing is selected.
     *
     * @param sel the selected tasks and design for which to find results
     *            associated with the given algorithm
     * @param modelGen the algorithm for generating cognitive models (i.e.,
     *                 scripts) from demonstrations
     * @param computeAlg the algorithm for generating results from
     *                      cognitive models
     * @author mlh/alex
     */
protected List<String> getTraces(ProjectSelectionState sel, CognitiveModelGenerator modelGen, IPredictionAlgo computeAlg) {
    Design design = sel.getSelectedDesign();
    AUndertaking[] tasks = sel.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION);
    List<String> traces = new ArrayList<String>();
    // either for selected tasks or for all tasks (if none selected).
    if (design != null) {
        traces.add("For Design " + design.getName());
        // Get for selected tasks
        if ((tasks != null) && (tasks.length > 0)) {
            for (AUndertaking task : tasks) {
                traces.addAll(getTraces(task, design, modelGen, computeAlg));
            }
        } else {
            // No tasks selected; get traces from all undertakings
            Iterator<AUndertaking> allTasks = project.getUndertakings().iterator();
            while (allTasks.hasNext()) {
                traces.addAll(getTraces(allTasks.next(), design, modelGen, computeAlg));
            }
        }
    } else if ((tasks != null) && (tasks.length > 0)) {
        // Design was null, get for selected tasks and all designs.
        for (AUndertaking task : tasks) {
            Iterator<Design> allDesigns = project.getDesigns().iterator();
            while (allDesigns.hasNext()) {
                Design d = allDesigns.next();
                traces.add("For Design " + d.getName());
                traces.addAll(getTraces(task, d, modelGen, computeAlg));
            }
        }
    }
    return traces;
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 100 with Iterator

use of java.util.Iterator in project cogtool by cogtool.

the class ProjectController method createDisplayTraces.

// Action for DisplayTraces
protected IListenerAction createDisplayTraces() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return ProjectSelectionState.class;
        }

        public boolean performAction(Object actionParms) {
            ProjectSelectionState sel = (ProjectSelectionState) actionParms;
            Design design = sel.getSelectedDesign();
            AUndertaking[] tasks = sel.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION);
            if (design != null) {
                if ((tasks != null) && (tasks.length > 0)) {
                    for (AUndertaking task : tasks) {
                        displayTraces(task, design);
                    }
                } else {
                    Iterator<AUndertaking> allTasks = project.getUndertakings().iterator();
                    while (allTasks.hasNext()) {
                        displayTraces(allTasks.next(), design);
                    }
                }
            } else if ((tasks != null) && (tasks.length > 0)) {
                for (AUndertaking task : tasks) {
                    Iterator<Design> allDesigns = project.getDesigns().iterator();
                    while (allDesigns.hasNext()) {
                        displayTraces(task, allDesigns.next());
                    }
                }
            }
            return true;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) ProjectSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) Iterator(java.util.Iterator)

Aggregations

Iterator (java.util.Iterator)7939 ArrayList (java.util.ArrayList)2053 Set (java.util.Set)1744 HashMap (java.util.HashMap)1678 HashSet (java.util.HashSet)1526 Map (java.util.Map)1486 List (java.util.List)1463 Test (org.junit.Test)576 IOException (java.io.IOException)465 Collection (java.util.Collection)320 Region (org.apache.geode.cache.Region)240 SSOException (com.iplanet.sso.SSOException)227 LinkedList (java.util.LinkedList)196 File (java.io.File)187 TreeSet (java.util.TreeSet)187 SMSException (com.sun.identity.sm.SMSException)169 LinkedHashMap (java.util.LinkedHashMap)146 IdRepoException (com.sun.identity.idm.IdRepoException)133 NoSuchElementException (java.util.NoSuchElementException)130 Session (org.hibernate.Session)126