Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Statistics.java

00001 package gov.nasa.arc.ase.util;
00002 
00003 import java.io.PrintStream;
00004 //#ifdef JDK11
00005 
00006 
00007 
00008 
00009 
00010 
00011 //#else JDK11
00012 import java.util.*;
00013 //#endif JDK11
00014 
00015 public class Statistics {
00016   private Hashtable ht = new Hashtable();
00017 
00018   public Object get(Category c) {
00019     if(ht.containsKey(c))
00020       return ht.get(c);
00021     return null;
00022   }  
00023   public Object get(String s) {
00024     return get(new Category(s));
00025   }  
00026   public void print() {
00027 //#ifdef JDK11
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 //#else JDK11
00043     List l = new ArrayList(ht.entrySet());
00044     Collections.sort(l, new Comparator() {
00045       public int compare(Object obj1, Object obj2) {
00046         Map.Entry m1 = (Map.Entry)obj1;
00047         Map.Entry m2 = (Map.Entry)obj2;
00048 
00049         return ((Comparable)m1.getKey()).compareTo(m2.getKey());
00050       }
00051     });
00052 //#endif JDK11
00053 
00054     Category last = null;
00055 
00056     for(Iterator i = l.iterator(); i.hasNext(); ) {
00057 //#ifdef JDK11
00058 
00059 //#else JDK11
00060       Map.Entry e = (Map.Entry)i.next();
00061 //#endif JDK11
00062       Object value = e.getValue();
00063       Category category = (Category)e.getKey();
00064 
00065       category.print(last);
00066       if(value != null)
00067     Debug.print(Debug.WARNING, ": " + value);
00068       Debug.println(Debug.WARNING);
00069 
00070       last = category;
00071     }
00072   }  
00073   public void save(PrintStream out) {
00074 //#ifdef JDK11
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 //#else JDK11
00090     Set entries = ht.entrySet();
00091 //#endif JDK11
00092 
00093     for(Iterator i = entries.iterator(); i.hasNext(); ) {
00094 //#ifdef JDK11
00095 
00096 //#else JDK11
00097       Map.Entry e = (Map.Entry)i.next();
00098 //#endif JDK11
00099       Object value = e.getValue();
00100       Category category = (Category)e.getKey();
00101 
00102       out.print(category);
00103       if(value != null)
00104     out.print(": " + value);
00105       out.println();
00106     }
00107   }  
00108   public void set(Category c, Object o) {
00109     if(ht.containsKey(c))
00110       ht.remove(c);
00111     ht.put(c, o);
00112   }  
00113   public void set(String s, Object o) {
00114     set(new Category(s), o);
00115   }  
00116 }

Generated at Thu Feb 7 06:55:53 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001