Revision: 20023
          http://sourceforge.net/p/gate/code/20023
Author:   markagreenwood
Date:     2017-01-31 11:13:40 +0000 (Tue, 31 Jan 2017)
Log Message:
-----------
JAPE grammars are now created from ResourceReference instances and not URLs

Modified Paths:
--------------
    
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java
    
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
    
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java
    gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java

Modified: 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java
===================================================================
--- 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java
 2017-01-31 10:41:20 UTC (rev 20022)
+++ 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java
 2017-01-31 11:13:40 UTC (rev 20023)
@@ -67,7 +67,7 @@
     defaultValue = "resources/NE/main.jape"
   )
   @Override
-  public void setGrammarURL(java.net.URL newGrammarURL) {
+  public void setGrammarURL(ResourceReference newGrammarURL) {
     super.setGrammarURL(newGrammarURL);
   }
 

Modified: 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
===================================================================
--- 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java  
    2017-01-31 10:41:20 UTC (rev 20022)
+++ 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java  
    2017-01-31 11:13:40 UTC (rev 20023)
@@ -114,7 +114,7 @@
         }
       } else if(grammarURL != null) {
         if(encoding != null) {
-          batch = new Batch(grammarURL, encoding, new 
InternalStatusListener());
+          batch = new Batch(grammarURL.toURL(), encoding, new 
InternalStatusListener());
           if(enableDebugging != null) {
             batch.setEnableDebugging(enableDebugging.booleanValue());
           } else {
@@ -349,7 +349,7 @@
     disjunction = "grammar",
     priority = 1
   )
-  public void setGrammarURL(java.net.URL newGrammarURL) {
+  public void setGrammarURL(ResourceReference newGrammarURL) {
     grammarURL = newGrammarURL;
   }
 
@@ -358,7 +358,7 @@
    *
    * @return a {@link java.net.URL} pointing to the grammar file.
    */
-  public java.net.URL getGrammarURL() {
+  public ResourceReference getGrammarURL() {
     return grammarURL;
   }
 
@@ -504,7 +504,7 @@
   /**
    * The URL to the jape file used as grammar by this transducer.
    */
-  protected java.net.URL grammarURL;
+  protected ResourceReference grammarURL;
 
   /**
    * The URL to the serialized jape file used as grammar by this transducer.

Modified: 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java
===================================================================
--- 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java
    2017-01-31 10:41:20 UTC (rev 20022)
+++ 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java
    2017-01-31 11:13:40 UTC (rev 20023)
@@ -6,6 +6,7 @@
 import gate.creole.AbstractProcessingResource;
 import gate.creole.AbstractVisualResource;
 import gate.creole.ResourceInstantiationException;
+import gate.creole.ResourceReference;
 import gate.creole.metadata.CreoleResource;
 import gate.creole.metadata.GuiType;
 import gate.event.ProgressListener;
@@ -223,9 +224,9 @@
         URL japeFileURL = null;
         
         try {
-          japeFileURL = (URL)transducer.getParameterValue("grammarURL");
+          japeFileURL = 
((ResourceReference)transducer.getParameterValue("grammarURL")).toURL();
         }
-        catch (ResourceInstantiationException rie) {
+        catch (ResourceInstantiationException | IOException rie) {
           //ignore this for now and let the null catch take over
           rie.printStackTrace();
         }

Modified: 
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java  
2017-01-31 10:41:20 UTC (rev 20022)
+++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java  
2017-01-31 11:13:40 UTC (rev 20023)
@@ -19,6 +19,7 @@
 import java.io.*;
 import java.net.URL;
 import gate.Gate;
+import gate.creole.ResourceReference;
 import gate.creole.Transducer;
 
 /**
@@ -70,7 +71,7 @@
   public static void compile(URL jape, File ser) throws Exception {
 
     Transducer transducer = new Transducer();
-    transducer.setGrammarURL(jape);
+    transducer.setGrammarURL(new ResourceReference(jape));
     transducer.setEncoding(defaultEncoding);
     transducer.init();
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
GATE-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to