1 17 18 19 20 package org.apache.lenya.net; 21 22 import java.util.Vector ; 23 24 import org.apache.lenya.xml.XPointerFactory; 25 import org.w3c.dom.Element ; 26 27 28 31 public class ProxyConf { 32 String proxyHost = null; 33 String proxyPort = null; 34 Vector items = null; 35 36 41 public ProxyConf(Element proxyElement) { 42 try { 43 items = new Vector (); 44 45 XPointerFactory xpf = new XPointerFactory(); 46 47 proxyHost = proxyElement.getAttribute("host"); 48 proxyPort = proxyElement.getAttribute("port"); 49 50 Vector filterEls = xpf.select(proxyElement, "xpointer(include|exclude)"); 51 52 for (int i = 0; i < filterEls.size(); i++) { 53 ProxyItem item = new ProxyItem((Element ) filterEls.elementAt(i)); 54 items.addElement(item); 55 } 56 } catch (Exception e) { 57 System.err.println(this.getClass().getName() + ": " + e); 58 } 59 } 60 61 68 public boolean check(String hostname) { 69 boolean result = false; 70 71 for (int i = 0; i < items.size(); i++) { 72 int ires = ((ProxyItem) items.elementAt(i)).check(hostname); 73 74 if (ires > 0) { 75 result = true; 76 } else if (ires < 0) { 77 result = false; 78 } 79 } 80 81 return result; 82 } 83 84 89 public String getHostName() { 90 return proxyHost; 91 } 92 93 98 public String getHostPort() { 99 return proxyPort; 100 } 101 } 102 | Popular Tags |