1 package net.sf.invicta.handler; 2 3 import java.io.File ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 import java.util.Map ; 7 8 import net.sf.invicta.InvictaException; 9 import net.sf.invicta.api.Product; 10 import net.sf.invicta.api.ProductContainer; 11 12 16 public class RelatedProductListHandler extends InvictaBasicHandler { 17 private final static String LIST_SEPARATOR = " "; 18 private final static boolean DEFAULT_INCLUDE_SELF = false; 19 20 23 public String getName() { 24 return "relatedProductList"; 25 } 26 27 28 31 public String handle(List params) throws InvictaException { 32 return getProductsList(DEFAULT_INCLUDE_SELF); 33 } 34 35 38 public String handle(Map paramsMap) throws InvictaException { 39 boolean includeSelf = getBooleanParameter("includeSelf", DEFAULT_INCLUDE_SELF); 40 41 return getProductsList(includeSelf); 42 } 43 44 47 protected String getProductsList(boolean includeSelf) { 48 ProductContainer products; 49 if (includeSelf) 50 products =getComponent().getRecursiveProducts(); 51 else 52 products =getComponent().getRecursiveProductsWithoutSelf(); 53 String productList = ""; 54 for (Iterator iter = products.iterator(); iter.hasNext();) { 55 Product product = (Product) iter.next(); 56 if (product.getType().equals("jar")) { 57 58 File file = new File (product.getFile()); 59 productList += file.getName(); 60 61 if (iter.hasNext()) 62 productList += LIST_SEPARATOR; 63 } 64 } 65 return productList; 66 } 67 68 } 69 | Popular Tags |