【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“ViewUtils.java”一文,供大家参考学习!
/*
* JCatalog Project
*/
package catalog.view.util;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Utility class for the presentation tier.
*
* @author <a href="mailto:derek_3710167@qq.com">Derek Y. Shen</a>
*/
public class ViewUtils {
/**
* Convert a list to a set.
*
* @param orig the list to be converted
* @return the set converted from the list
*/
public static Set convertToSet(List orig) {
Set result = new HashSet();
if (orig != null) {
Iterator ite = orig.iterator();
while (ite.hasNext()) {
result.add(ite.next());
}
}
return result;
}
/**
* Convert a set to a list.
* @param orig the set to be converted
* @return the list converted from the set
*/
public static List convertToList(Set orig) {
List result = new ArrayList();
if (orig != null) {
Iterator ite = orig.iterator();
while (ite.hasNext()) {
result.add(ite.next());
}
}
return result;
}
}