3fadfb048a9bad0c49791c74a6d4e6a5792fad5d
1 package com
.hexidec
.util
;
4 GNU General Public License
6 PatternReplacer - Simple Pattern Replacement Class
7 Copyright (C) 2001 Howard A Kistler
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 import java
.util
.Hashtable
;
27 * Utility class for replacing patterns in script strings
29 * @author Howard Kistler
33 * 0.1 (04/04/2001) - initial creation (04/04/2001)
34 * 0.2 (04/09/2001) - separation into own class (04/09/2001)
37 public class PatternReplacer
{
39 private Hashtable patternTable
;
41 public PatternReplacer(Hashtable patterns
) {
42 patternTable
= patterns
;
45 public PatternReplacer() {
46 patternTable
= new Hashtable();
49 public void addPattern(String pattern
, String replacement
) {
50 if(patternTable
.containsKey(pattern
)) {
51 patternTable
.remove(pattern
);
53 patternTable
.put(pattern
, replacement
);
56 public void removePattern(String pattern
) {
57 if(patternTable
.containsKey(pattern
)) {
58 patternTable
.remove(pattern
);
62 public String
getPattern(String pattern
) {
63 if(patternTable
.containsKey(pattern
)) {
64 return (String
)(patternTable
.get(pattern
));
69 public void clearPatterns() {
73 public int patternCount() {
74 return patternTable
.size();