1 23 package org.hammurapi.inspectors.techstack; 24 25 import java.util.Collection ; 26 import java.util.Iterator ; 27 28 import javax.xml.transform.TransformerException ; 29 30 import org.apache.xpath.CachedXPathAPI; 31 import org.w3c.dom.Element ; 32 33 37 public class Product extends Licensor { 38 39 private Publisher publisher; 40 41 public Product(TechStack stack, Publisher publisher) { 42 super(stack); 43 this.publisher=publisher; 44 publisher.addProduct(this); 45 } 46 47 52 public Product(TechStack stack, Publisher publisher, Element holder, CachedXPathAPI cxpa) throws TransformerException { 53 super(stack, holder, cxpa); 54 this.publisher=publisher; 55 publisher.addProduct(this); 56 this.stack=stack; 57 ignore="yes".equals(holder.getAttribute("ignore")); 58 } 59 60 public void addClient(String client) { 61 if (!ignore) { 62 super.addClient(client); 63 getLicense().addClient(client); 64 publisher.addClient(client); 65 } 66 } 67 68 private boolean ignore; 69 70 public boolean isIgnore() { 71 return ignore; 72 } 73 public void setIgnore(boolean ignore) { 74 this.ignore = ignore; 75 } 76 77 public void toDom(Element holder) { 78 super.toDom(holder); 79 holder.setAttribute("ignore", ignore ? "yes" : "no"); 80 } 81 82 86 public boolean match(String packageName, Collection clients) { 87 Iterator it=packages.iterator(); 88 while (it.hasNext()) { 89 String pn=(String ) it.next(); 90 if (pn.equals(packageName) || packageName.startsWith(pn+".")) { 91 Iterator cit=clients.iterator(); 92 while (cit.hasNext()) { 93 addClient((String ) cit.next()); 94 } 95 return true; 96 } 97 } 98 return false; 99 } 100 101 public BasicDescriptor getLicense() { 102 BasicDescriptor ret=super.getLicense(); 103 return ret==null ? publisher.getLicense() : ret; 104 } 105 106 public void addClients(Collection clients) { 107 Iterator it=clients.iterator(); 108 while (it.hasNext()) { 109 addClient((String ) it.next()); 110 } 111 112 } 113 } 114 | Popular Tags |