Print

Print


Commit in GeomConverter/src/org/lcsim/detector on MAIN
DetectorElementStore.java+22-71.12 -> 1.13
better error method when a duplicate id occurs; overload clear in order to clear out cache (was not being done previously)

GeomConverter/src/org/lcsim/detector
DetectorElementStore.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- DetectorElementStore.java	14 Sep 2007 23:48:19 -0000	1.12
+++ DetectorElementStore.java	25 Mar 2009 00:24:14 -0000	1.13
@@ -21,20 +21,29 @@
     
     public boolean add(IDetectorElement de)
     {   
-    	// Add to the list using super, which will check for dups, etc.
+    	// Add to the list using super.
     	super.add(de);
     	    	
-    	// Check to see if the id is cacheable ...
-    	
+    	// Check to see if the id is cacheable...
     	IIdentifier id = de.getIdentifier(); 
 
     	// Is the id non-null?
     	if (id != null)
     	{
-    		// Is the id flagged as valid?
+    		// Is the id valid?
     		if (id.isValid())
-    		{
-    			// Cache this DE in the lookup map.
+    		{    		        		       		   
+    			// Check for existing.
+    		    if (cache.get(id.getValue()) != null)
+    		    {
+    		        throw new IllegalArgumentException(
+    		                "Attempting to add DetectorElement <" 
+    		                + de.getName() + ">, but an existing DetectorElement <" 
+    		                + cache.get(id.getValue()).getName() 
+    		                + "> has the same id <" + id.toHexString() + ">.");
+    		    }
+    		    
+    		    // Cache this DE in the lookup map.
     			cache.put(id.getValue(), de);
     		}
     	}
@@ -48,5 +57,11 @@
     	IDetectorElement lookup = cache.get(id.getValue());
     	if (lookup != null) match.add(lookup);
     	return match;
-    }                 
+    }      
+    
+    public void clear()
+    {
+        cache.clear();
+        super.clear();
+    }
 }
\ No newline at end of file
CVSspam 0.2.8