📄 chainedfactory.java
字号:
/* * ChainedFactory.java * * Created on 11 luglio 2004, 21.26 */package org.joone.dte.factory;import java.util.*;import org.joone.dte.TaskFactory;import org.joone.net.NeuralNet;/** * This TaskFactory calls in sequence all the TaskFactory objects * contained in the Chain parameter, and returns the sum of * the generated tasks. * @author paolo */public class ChainedFactory implements TaskFactory { private ArrayList chain; private int currElem; /** Creates a new instance of ChainedFactory */ public ChainedFactory() { chain = new ArrayList(); } public void initialize() { currElem = 0; for (int i=0; i < chain.size(); ++i) { TaskFactory fact = (TaskFactory)chain.get(i); fact.initialize(); } } /** * Getter for property chain. * @return Value of property chain. */ public ArrayList getChain() { return chain; } /** * Setter for property chain. * Used to fill the internal list of TaskFactory object to call in sequence * @param chain an ArrayList of taskFactory objects */ public void setChain(ArrayList chain) { this.chain = chain; } public org.joone.net.NeuralNet getNextTask() { if ((chain == null) || (chain.size() == 0)) return null; NeuralNet nnet = null; while ((nnet == null) && (currElem < chain.size())) { TaskFactory fact = (TaskFactory)chain.get(currElem); nnet = fact.getNextTask(); if (nnet == null) // the current TaskFactory has finished; we take the next one ++currElem; } return nnet; } public int getTotTasks() { if ((chain == null) || (chain.size() == 0)) return 0; int sum = 0; for (int i=0; i < chain.size(); ++i) { TaskFactory fact = (TaskFactory)chain.get(i); sum += fact.getTotTasks(); } return sum; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -