2 * Copyright (C) 2007 Universitat d'Alacant / Universidad de Alicante
3 * Author: Enrique Benimeli Bofarull
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 package dictools
.crossmodel
;
23 import java
.io
.DataOutputStream
;
24 import java
.io
.IOException
;
25 import java
.util
.HashMap
;
26 import java
.util
.Iterator
;
31 * @author Enrique Benimeli Bofarull
34 public class ConstantMap
extends HashMap
<String
, String
> {
39 static final long serialVersionUID
= 0;
46 public final String
insert(final String key
, final String value
) {
47 if (!containsKey(key
)) {
59 public final void print() {
60 final Set keySet
= keySet();
61 final Iterator it
= keySet
.iterator();
63 System
.out
.print("constants: ");
64 while (it
.hasNext()) {
65 final String key
= (String
) it
.next();
66 final String value
= get(key
);
67 System
.out
.print("<" + key
+ "," + value
+ "> ");
69 System
.out
.println("");
76 public final void printXML(DataOutputStream dos
) throws IOException
{
77 final Set keySet
= keySet();
78 final Iterator it
= keySet
.iterator();
80 dos
.writeBytes("\t<constants>\n");
81 while (it
.hasNext()) {
82 final String key
= (String
) it
.next();
83 final String value
= get(key
);
84 dos
.writeBytes("\t\t<constant n=\"" + value
+ "\">" + key
87 dos
.writeBytes("\t<constants>\n");
95 public final String
getKey(final String value
) {
96 final Set keySet
= keySet();
97 final Iterator it
= keySet
.iterator();
99 while (it
.hasNext()) {
100 final String key
= (String
) it
.next();
101 final String v
= get(key
);
102 if (v
.equals(value
)) {