Print

Print


Commit in GeomConverter/src/org/lcsim on MAIN
geometry/compact/CompactReader.java+5-41.37 -> 1.38
geometry/compact/converter/lcdd/LCDDDetector.java+4-21.19 -> 1.20
                               /Main.java+1-11.17 -> 1.18
geometry/subdetector/PolyhedraBarrelCalorimeter.java+1-11.7 -> 1.8
util/xml/ClasspathEntityResolver.java+22-251.1 -> 1.2
+33-33
5 modified files
JM: fix offline build

GeomConverter/src/org/lcsim/geometry/compact
CompactReader.java 1.37 -> 1.38
diff -u -r1.37 -r1.38
--- CompactReader.java	8 Jan 2008 23:50:52 -0000	1.37
+++ CompactReader.java	12 Mar 2008 23:21:05 -0000	1.38
@@ -15,10 +15,11 @@
 import org.lcsim.geometry.util.BaseIDDecoder;
 import org.lcsim.material.XMLMaterialManager;
 import org.lcsim.units.clhep.Constants;
+import org.lcsim.util.xml.ClasspathEntityResolver;
 import org.lcsim.util.xml.ElementFactory;
 import org.lcsim.util.xml.JDOMExpressionFactory;
 import org.lcsim.util.xml.ElementFactory.ElementCreationException;
-import org.lcsim.util.xml.ClasspathEntityResolver;
+import org.xml.sax.InputSource;
 
 /**
  * A tool for reading xml files containing compact detector descriptions.
@@ -28,7 +29,7 @@
  * org.lcsim.geometry.GeometryReader class, which extends this.
  *
  * @author tonyj
- * @version $Id: CompactReader.java,v 1.37 2008/01/08 23:50:52 jeremy Exp $
+ * @version $Id: CompactReader.java,v 1.38 2008/03/12 23:21:05 jeremy Exp $
  *
  */
 public class CompactReader
@@ -77,8 +78,8 @@
         
         // Add an EntityResolver that caches to ~/.cache
         //builder.setEntityResolver(new CachingEntityResolver());
-        builder.setEntityResolver(new ClasspathEntityResolver("/org/lcsim"));
-       
+        builder.setEntityResolver(new ClasspathEntityResolver());
+        
         doc = builder.build(in);
         
         Element lccdd = doc.getRootElement();

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
LCDDDetector.java 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- LCDDDetector.java	14 Dec 2007 21:57:51 -0000	1.19
+++ LCDDDetector.java	12 Mar 2008 23:21:05 -0000	1.20
@@ -1,5 +1,6 @@
 package org.lcsim.geometry.compact.converter.lcdd;
 
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URL;
@@ -37,6 +38,7 @@
 import org.lcsim.geometry.compact.converter.lcdd.util.VisAttributes;
 import org.lcsim.geometry.util.IDDescriptor;
 import org.lcsim.material.XMLMaterialManager;
+import org.lcsim.util.cache.FileCache;
 
 /**
  *
@@ -209,10 +211,10 @@
             ((LCDDField) field).addToLCDD(lcdd);
         }
         
-        // Merge in referenced GDML files from includes block.
+        FileCache cache = new FileCache();
         for (URL gdmlFile : getGDMLReferences())
         {
-            lcdd.mergeGDML(gdmlFile.openStream());
+            lcdd.mergeGDML(new FileInputStream(cache.getCachedFile(gdmlFile)));
         }
                 
         lcdd.cleanUp();

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
Main.java 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- Main.java	8 Jan 2008 23:50:53 -0000	1.17
+++ Main.java	12 Mar 2008 23:21:05 -0000	1.18
@@ -63,7 +63,7 @@
          stream.close();
          
          SAXBuilder builder = new SAXBuilder();
-         builder.setEntityResolver(new ClasspathEntityResolver("/org/lcsim"));
+         builder.setEntityResolver(new ClasspathEntityResolver());
          builder.setValidation(true);
          builder.setFeature("http://apache.org/xml/features/validation/schema",true);
          builder.build(new ByteArrayInputStream(stream.toByteArray()));

GeomConverter/src/org/lcsim/geometry/subdetector
PolyhedraBarrelCalorimeter.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- PolyhedraBarrelCalorimeter.java	15 Feb 2008 02:14:52 -0000	1.7
+++ PolyhedraBarrelCalorimeter.java	12 Mar 2008 23:21:05 -0000	1.8
@@ -29,7 +29,7 @@
     
     public void appendHepRep(HepRepFactory factory, HepRep heprep)
     {
-    	System.out.println("PolyhedraBarrelCalorimeter.appendHepRep");
+    	//System.out.println("PolyhedraBarrelCalorimeter.appendHepRep");
     	DetectorElementToHepRepConverter.convert(getDetectorElement(), factory, heprep, 0, -1);
     }
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/util/xml
ClasspathEntityResolver.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ClasspathEntityResolver.java	14 Dec 2007 21:59:00 -0000	1.1
+++ ClasspathEntityResolver.java	12 Mar 2008 23:21:05 -0000	1.2
@@ -1,48 +1,45 @@
 package org.lcsim.util.xml;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
 
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 /**
- * Finds an XML schema in a jar file.
+ * Resolves URIs to class resources.
+ * 
+ * For instance, the URI <code>http://www.lcsim.org/example/example.txt</code> would 
+ * be resolved to <code>/org/lcsim/example/example.txt</code>.
  *
  * @author Jeremy McCormick
- * @version $Id: ClasspathEntityResolver.java,v 1.1 2007/12/14 21:59:00 jeremy Exp $
+ * @version $Id: ClasspathEntityResolver.java,v 1.2 2008/03/12 23:21:05 jeremy Exp $
  */
-// FIXME: Duplicates functionality of freehep's ClasspathEntityResolver.
 public class ClasspathEntityResolver
 implements EntityResolver
 {    
-    String basePath;
-    
-    public ClasspathEntityResolver(String basePath)
-    {
-        this.basePath = basePath;
-    }
-    
-    /**
-     * Resolves the <tt>systemId</tt> by stripping out the base URL and then
-     * looking for the remaining path under a base package name.
-     * 
-     * ex. - http://www.lcsim.org/schemas/compact/1.0/compact.xsd -> /org/lcsim/schemas/compact/1.0/compact.xsd
-     * 
-     */
     public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
-    {                        
-        // Strip out the base URL.
-        String path = systemId.substring(systemId.indexOf("/", systemId.indexOf("//") + 1));
-                
-        // Resolve the path component.
-        InputStream in = this.getClass().getResourceAsStream(basePath + "/" + path);
+    {                    
+    	URL url = new URL(systemId);
+    	String[] hostTokens = url.getHost().split("\\.");
+    	String org = "";
+    	for (int i = hostTokens.length - 1; i >= 0; i--)
+    	{
+    		if (!hostTokens[i].equals("www"))
+    			org += "/" + hostTokens[i];
+    	}
+    	
+    	String path = (new URL(systemId)).getPath();     
+        InputStream in = this.getClass().getResourceAsStream(org + "/" + path);
         
-        // Make an InputSource from the stream.
         InputSource src = new InputSource(in);
         src.setSystemId(systemId);
-        
+        src.setPublicId(publicId);
+                
         return src;
     }
 }
CVSspam 0.2.8