1 14 15 package org.quickserver.util.xmlreader; 16 17 import java.util.*; 18 26 public class IpFilterConfig implements java.io.Serializable { 27 private ArrayList ipCollection=null; 28 private boolean enable = false; 29 private boolean allowAccess = false; 30 31 public IpFilterConfig() { 32 ipCollection = new ArrayList(); 33 } 34 35 38 public void addClientIpAddress(String clientIpAddress) { 39 if(clientIpAddress!=null) { 40 ipCollection.add(clientIpAddress); 41 } 42 } 43 44 47 public ArrayList getIpCollection() { 48 return ipCollection; 49 } 50 51 public Iterator iterator() { 52 return ipCollection.iterator(); 53 } 54 55 61 public void setEnable(boolean enable) { 62 this.enable = enable; 63 } 64 68 public boolean getEnable() { 69 return enable; 70 } 71 72 78 public void setAllowAccess(boolean enable) { 79 this.allowAccess = enable; 80 } 81 85 public boolean getAllowAccess() { 86 return allowAccess; 87 } 88 89 93 public String toXML(String pad) { 94 if(pad==null) pad=""; 95 StringBuffer sb = new StringBuffer (); 96 sb.append(pad+"<ip-filter>\n"); 97 sb.append(pad+"\t<enable>"+getEnable()+"</enable>\n"); 98 sb.append(pad+"\t<allow-access>"+getAllowAccess()+"</allow-access>\n"); 99 sb.append(pad+"\t<ip-collection>\n"); 100 Iterator iterator = iterator(); 101 while(iterator.hasNext()) { 102 String cip = (String )iterator.next(); 103 sb.append(pad+"\t\t<client-ip-address>"+cip+"</client-ip-address>\n"); 104 } 105 sb.append(pad+"\t</ip-collection>\n"); 106 sb.append(pad+"</ip-filter>\n"); 107 return sb.toString(); 108 } 109 } 110 | Popular Tags |