Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/compact on MAIN
SystemIDMap.java+24-211.1 -> 1.2
JM: fix nesting of error checks

GeomConverter/src/org/lcsim/geometry/compact
SystemIDMap.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SystemIDMap.java	7 Feb 2006 18:47:10 -0000	1.1
+++ SystemIDMap.java	8 Feb 2006 01:03:47 -0000	1.2
@@ -4,43 +4,46 @@
 import java.util.Map;
 
 /**
- * A map of system ID to Subdetectors, used by org.lcsim.geometry.compact.Detector.
+ * A map of system ID to Subdetectors, used by
+ * org.lcsim.geometry.compact.Detector.
  * 
  * @author jeremym
- *
  */
 class SystemIDMap
 {
-    Map<Integer, Subdetector> _subdetectors = new HashMap<Integer, Subdetector>();
+    private Map<Integer, Subdetector> _subdetectors = new HashMap<Integer, Subdetector>();
 
-    /** 
-     * Add an entry mapping system id to a Subdetector. 
-     * @param sysid System ID which must be > 0
-     * @param subdetector Subdetector with this sysid 
+    /**
+     * Add an entry mapping system id to a Subdetector.
+     * 
+     * @param sysid
+     *            System ID which must be > 0
+     * @param subdetector
+     *            Subdetector with this sysid
      */
-    void add(int sysid, Subdetector subdetector)
+    protected void add(int sysid, Subdetector subdetector)
     {
-        if (_subdetectors.containsKey(sysid))
+        if (sysid > 0)
         {
-            System.err.println("WARNING: The System ID " + sysid + " of " + subdetector.getName()
-                    + " is already used in this Detector.  System ID was NOT assigned.");
-        }
-        else
-        {
-            if (sysid > 0)
+            if (_subdetectors.containsKey(sysid))
             {
-                _subdetectors.put(sysid, subdetector);
+                throw new RuntimeException("The System ID " + sysid + " of " + subdetector.getName()
+                        + " is already used by " + _subdetectors.get(sysid).getName());
             }
-            else {
-                System.err.println("WARNING: The system id <" + sysid + "> of Subdetector <" 
-                        + subdetector.getName() 
-                        + "> was ignored, because it is not greater than zero.");
+            else
+            {
+                _subdetectors.put(sysid, subdetector);                
             }
         }
+        else
+        {
+            System.err.println("WARNING: The system id <" + sysid + "> of Subdetector <" + subdetector.getName()
+                    + "> was ignored, because it is not greater than zero.");
+        }
     }
 
     /** Retrieve a Subdetector by system ID. */
-    Subdetector get(int sysid)
+    protected Subdetector get(int sysid)
     {
         return _subdetectors.get(sysid);
     }
CVSspam 0.2.8