--- /dev/null
+package com.hexidec.util;\r
+\r
+/*\r
+GNU General Public License\r
+\r
+PatternReplacer - Simple Pattern Replacement Class\r
+Copyright (C) 2001 Howard A Kistler\r
+\r
+This program is free software; you can redistribute it and/or\r
+modify it under the terms of the GNU General Public License\r
+as published by the Free Software Foundation; either version 2\r
+of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program; if not, write to the Free Software\r
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+*/\r
+\r
+import java.util.Hashtable;\r
+\r
+/** PatternReplacer\r
+ * Utility class for replacing patterns in script strings\r
+ *\r
+ * @author Howard Kistler\r
+ * @version 0.2\r
+ *\r
+ * VERSION HISTORY\r
+ * 0.1 (04/04/2001) - initial creation (04/04/2001)\r
+ * 0.2 (04/09/2001) - separation into own class (04/09/2001)\r
+ */\r
+\r
+public class PatternReplacer {\r
+\r
+ private Hashtable patternTable;\r
+\r
+ public PatternReplacer(Hashtable patterns) {\r
+ patternTable = patterns;\r
+ }\r
+\r
+ public PatternReplacer() {\r
+ patternTable = new Hashtable();\r
+ }\r
+\r
+ public void addPattern(String pattern, String replacement) {\r
+ if(patternTable.containsKey(pattern)) {\r
+ patternTable.remove(pattern);\r
+ }\r
+ patternTable.put(pattern, replacement);\r
+ }\r
+\r
+ public void removePattern(String pattern) {\r
+ if(patternTable.containsKey(pattern)) {\r
+ patternTable.remove(pattern);\r
+ }\r
+ }\r
+\r
+ public String getPattern(String pattern) {\r
+ if(patternTable.containsKey(pattern)) {\r
+ return (String)(patternTable.get(pattern));\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public void clearPatterns() {\r
+ patternTable.clear();\r
+ }\r
+\r
+ public int patternCount() {\r
+ return patternTable.size();\r
+ }\r
+\r
+}\r
+\r