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);
}
}
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;
}
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);
}
}
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;
}
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;
}
};
}
Aggregations