Iterator(JFIS)

 
 
Iterator (迭代器)、 Set
public Set getModelsByPowers(Set powers) throws SQLException {
 
Set models = new HashSet();
Iterator powersIterator = powers.iterator();
ModelDAO modelDAO = new ModelDAO();
// 添加三级模块
while (powersIterator.hasNext()) {
PowerBean powerBean = (PowerBean) powersIterator.next();
ModelBean modelBean = modelDAO.model_bean(powerBean.getModelId());
String parentModeId = modelBean.getParentModelId();
ModelBean mb = new ModelBean();
models.add(modelBean);
// 添加一、二级模块
while (!(parentModeId.equals( "-1" ))) {
ModelBean modelbean = modelDAO.model_bean(parentModeId);
parentModeId = modelbean.getParentModelId();
models.add(modelbean);
}
}
return models;
}
 

你可能感兴趣的:(Iterator(JFIS))