00001 package gov.nasa.arc.ase.jpf.jvm;
00002
00003
00004 import java.util.Hashtable;
00005
00006 public class StaticMap {
00007 static Hashtable mapping = new Hashtable();
00008 static int counter = 0;
00009
00010 public static int addEntry(String cname) {
00011 Integer index = (Integer)mapping.get(cname);
00012
00013 if(index != null) return index.intValue();
00014
00015 synchronized(StaticMap.class) {
00016 index = (Integer)mapping.get(cname);
00017
00018 if(index != null) return index.intValue();
00019
00020 mapping.put(cname, new Integer(counter));
00021 return counter++;
00022 }
00023 }
00024 public static int getEntry(String cname) {
00025 return ((Integer)mapping.get(cname)).intValue();
00026 }
00027 public static boolean hasEntry(String cname) {
00028 return mapping.containsKey(cname);
00029 }
00030 public static synchronized void reset() {
00031 mapping = new Hashtable();
00032 counter = 0;
00033 }
00034 }