You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2010/08/06 21:44:29 UTC

svn commit: r983107 - in /uima/uimaj/trunk: uima-docbook-tools/src/docbook/tools.jcasgen.xml uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java

Author: schor
Date: Fri Aug  6 19:44:29 2010
New Revision: 983107

URL: http://svn.apache.org/viewvc?rev=983107&view=rev
Log:
[UIMA-1793] committed patch with minor change. Didn't do any improvement to error messages, that can come later. Add documentation to Tools book.

Modified:
    uima/uimaj/trunk/uima-docbook-tools/src/docbook/tools.jcasgen.xml
    uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java

Modified: uima/uimaj/trunk/uima-docbook-tools/src/docbook/tools.jcasgen.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uima-docbook-tools/src/docbook/tools.jcasgen.xml?rev=983107&r1=983106&r2=983107&view=diff
==============================================================================
--- uima/uimaj/trunk/uima-docbook-tools/src/docbook/tools.jcasgen.xml (original)
+++ uima/uimaj/trunk/uima-docbook-tools/src/docbook/tools.jcasgen.xml Fri Aug  6 19:44:29 2010
@@ -79,6 +79,10 @@ under the License.
     generated Java source code should go. If it isn't given, JCasGen generates its
     output into a subfolder called JCas (or sometimes JCasNew – see below), of the first
     argument&apos;s path.</para>
+    
+  <para>The first argument, the input file, can be written as
+    <literal>jar:&lt;url>!{entry}</literal>, for example:
+    <literal>jar:http://www.foo.com/bar/baz.jar!/COM/foo/quux.class</literal></para>
   
   <para>If no arguments are given to JCasGen, then it launches a GUI to interact with the user
     and ask for the same input. The GUI will remember the arguments you previously used.

Modified: uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java?rev=983107&r1=983106&r2=983107&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java (original)
+++ uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java Fri Aug  6 19:44:29 2010
@@ -29,6 +29,7 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -425,20 +426,37 @@ public class Jg {
         }
 
         xmlSourceFileName = inputFile.replaceAll("\\\\", "/");
-        File file = new File(inputFile);
-        if (!file.exists()) {
-          error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null);
-        }
-
-        if (null == outputDirectory || outputDirectory.equals("")) {
-          File dir = file.getParentFile();
-          if (null == dir) {
-            error.newError(IError.ERROR, getString("sourceArgNeedsDirectory",
-                    new Object[] { inputFile }), null);
+        URL url;
+        if(inputFile.substring(0, 4).equalsIgnoreCase("jar:")) {
+        	try {
+        		url = new URL(inputFile);
+          	if (null == url) {
+          		error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null);
+          	}
+          	if(null == outputDirectory || outputDirectory.equals("")) {
+          		error.newError(IError.ERROR, getString("sourceArgNeedsDirectory", new Object[] { inputFile }), null);
+          	}
+        	} catch (MalformedURLException e) {
+        		error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null);
+        		url = null;  // never get here, the previous statement throws.  Needed, though for java path analysis.
+        	}
+        } else {
+        	File file = new File(inputFile);
+          if (!file.exists()) {
+              error.newError(IError.ERROR, getString("fileNotFound", new Object[] { inputFile }), null);
           }
-          outputDirectory = dir.getPath() + File.separator + "JCas"
-                  + ((null != merger) ? "" : "New");
+          if (null == outputDirectory || outputDirectory.equals("")) {
+            File dir = file.getParentFile();
+            if (null == dir) {
+              error.newError(IError.ERROR, getString("sourceArgNeedsDirectory",
+                      new Object[] { inputFile }), null);
+            }
+            outputDirectory = dir.getPath() + File.separator + "JCas"
+                    + ((null != merger) ? "" : "New");
+          }
+          url = file.toURI().toURL();
         }
+
         progressMonitor.beginTask("", 5);
         progressMonitor.subTask("Output going to '" + outputDirectory + "'");
         progressMonitor.subTask(getString("ReadingDescriptorAndCreatingTypes",
@@ -447,7 +465,7 @@ public class Jg {
         CASImpl casLocal = null;
         // handle classpath
         try {
-          XMLInputSource in = new XMLInputSource(file);
+          XMLInputSource in = new XMLInputSource(url);
           XMLizable specifier = UIMAFramework.getXMLParser().parse(in);
 
           mergedTypesAddingFeatures.clear();