1 64 65 package com.jcorporate.expresso.core.security.filters; 66 67 68 95 public class Filter { 96 97 int maxReplaceLength = 0; 98 FilterTree parseTree = null; 99 FilterTree stripTree = null; 100 101 104 public Filter() { 105 throw new InstantiationError ("Base Class of Filter(<no arguments>) should never be called."); 106 } 107 108 119 public Filter(String [] specialChars, String [] replacementStrings) 120 throws IllegalArgumentException { 121 parseTree = new FilterTree(); 122 stripTree = new FilterTree(); 123 124 try { 125 if (specialChars.length != replacementStrings.length) { 126 throw new IllegalArgumentException ("sepcialChars.length must be the" + 127 " same as replacementChars.length"); 128 } 129 for (int i = 0; i < specialChars.length; i++) { 130 parseTree.addFilterString(specialChars[i], 131 replacementStrings[i]); 132 133 parseTree.addFilterString(replacementStrings[i], 135 replacementStrings[i]); 136 stripTree.addFilterString(specialChars[i], ("")); 137 } 138 } catch (Exception e) { 139 throw new IllegalArgumentException ("Error Instantiating Filter: " + 140 e.getMessage()); 141 } 142 } 143 144 152 public String rawFilter(String data) { 153 return (data); 154 } 155 156 167 public String standardFilter(String data) { 168 return parseTree.replaceFilter(data.toCharArray()); 169 } 170 171 181 public String stripFilter(String data) { 182 return stripTree.replaceFilter(data.toCharArray()); 183 } 184 185 } 186 | Popular Tags |