1 17 18 19 20 package org.apache.lenya.net; 21 22 import org.apache.lenya.xml.XPointerFactory; 23 import org.apache.regexp.RE; 24 import org.apache.regexp.RESyntaxException; 25 import org.w3c.dom.Element ; 26 27 28 31 public class ProxyItem { 32 RE filter = null; 33 boolean action = false; 34 35 40 public ProxyItem(Element itemElement) { 41 XPointerFactory xpf = new XPointerFactory(); 42 43 if (itemElement.getNodeName().equals("include")) { 44 action = true; 45 } else { 46 action = false; 47 } 48 49 try { 50 filter = new RE(xpf.getElementValue(itemElement)); 51 } catch (RESyntaxException e) { 52 System.err.println(this.getClass().getName() + ": " + e); 53 } 54 } 55 56 63 public int check(String hostname) { 64 if (filter.match(hostname)) { 65 if (action) { 66 return 1; 67 } else { 68 return -1; 69 } 70 } else { 71 return 0; 72 } 73 } 74 } 75 | Popular Tags |