Revision: 17425
          http://sourceforge.net/p/gate/code/17425
Author:   markagreenwood
Date:     2014-02-26 11:58:22 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
removed the deprecated annotations param from the JAPE RHS code -- fingers 
crossed this doesn't bring on the apocalypse

Modified Paths:
--------------
    gate/trunk/src/main/gate/jape/RhsAction.java
    gate/trunk/src/main/gate/jape/RightHandSide.java

Modified: gate/trunk/src/main/gate/jape/RhsAction.java
===================================================================
--- gate/trunk/src/main/gate/jape/RhsAction.java        2014-02-26 11:01:11 UTC 
(rev 17424)
+++ gate/trunk/src/main/gate/jape/RhsAction.java        2014-02-26 11:58:22 UTC 
(rev 17425)
@@ -32,15 +32,12 @@
    * @param doc the document the RHS action will be run on
    * @param bindings A map containing the matching results from the LHS in 
    * the form label(String) -> matched annotations (AnnotationSet)
-   * @param annotations copy of the outputAS value provided for backward
-   * compatibility
    * @param inputAS the input annotation set
    * @param outputAS the output annotation set
    * @param ontology
    * @throws JapeException
    */
   public void doit(Document doc, Map<String, AnnotationSet> bindings,
-                   AnnotationSet annotations,
                    AnnotationSet inputAS, AnnotationSet outputAS,
                    Ontology ontology)
               throws JapeException;

Modified: gate/trunk/src/main/gate/jape/RightHandSide.java
===================================================================
--- gate/trunk/src/main/gate/jape/RightHandSide.java    2014-02-26 11:01:11 UTC 
(rev 17424)
+++ gate/trunk/src/main/gate/jape/RightHandSide.java    2014-02-26 11:58:22 UTC 
(rev 17425)
@@ -139,7 +139,7 @@
       "  public ActionContext getActionContext() { return ctx; }"+nl+
       "  public void doit(gate.Document doc, " + nl +
       "                   java.util.Map<java.lang.String, gate.AnnotationSet> 
bindings, " + nl +
-      "                   gate.AnnotationSet annotations, " + nl +
+      //"                   gate.AnnotationSet annotations, " + nl +
       "                   gate.AnnotationSet inputAS, gate.AnnotationSet 
outputAS, " + nl +
       "                   gate.creole.ontology.Ontology ontology) throws 
gate.jape.JapeException {" + nl
     );
@@ -304,70 +304,11 @@
     if(theActionObject == null) {
       instantiateActionClass();
     }
-
-    // the 'annotations' parameter of the RhSAction.doIt method has been
-    // deprecated. As there is no way in Java to deprecate a parameter
-    // we will have to be a little clever/sneaky! We will create a proxy
-    // around the outputAS and pass the proxy to the Jape RHS. If the RHS
-    // code calls any method on the annotations proxy the following
-    // handler will be called instead so we can warn about the
-    // deprecation and then forward the method onwards to the outputAS
-    // so that the JAPE code will still work.
-    AnnotationSet annotations = (AnnotationSet)Proxy.newProxyInstance(
-            getClass().getClassLoader(), new Class[] {AnnotationSet.class},
-            new InvocationHandler() {
-
-              public Object invoke(Object proxy, Method method, Object[] args)
-                      throws Throwable {
-
-                StackTraceElement japeSTE = null;
-                int lineNumber = -1;
-
-                // find the stack trace element corresponding to the
-                // call on the annotations proxy. This should always be
-                // the third element but just to be on the safe side we
-                // will find it by looping
-                for(StackTraceElement ste : (new Throwable()).getStackTrace()) 
{
-                  if(ste.getClassName().equals(actionClassQualifiedName)) {
-
-                    if(ste.getLineNumber() >= 0 && sourceInfo != null) {
-                      japeSTE = 
sourceInfo.getStackTraceElement(ste.getLineNumber());
-                      lineNumber = ste.getLineNumber();
-                    }
-                    else {
-                      // this will happen if we are running from a
-                      // serialised jape grammar as we don't keep the
-                      // source info
-                      japeSTE = new StackTraceElement(getPhaseName(),
-                              getRuleName(), null, -1);
-                    }
-
-                    break;
-                  }
-                }                
-
-                if(!warnings.contains(japeSTE)) {
-                  // we only want to warn about each use once per
-                  // invocation of GATE so we keep a cache of the stack
-                  // trace elements we have already warned about
-                  Err.println(nl + "WARNING: the JAPE 'annotations' parameter 
has been deprecated. Please use 'inputAS' or 'outputAS' instead.");
-                  Err.println(japeSTE);
-                  if(lineNumber >= 0)
-                    Err.println("\t" + 
sourceInfo.getSource(getActionClassString(), lineNumber).trim());
-
-                  warnings.add(japeSTE);
-                }
-
-                //pass the method on so that the JAPE code still works
-                return method.invoke(outputAS, args);
-              }
-            });
-    
+        
     // run the action class
     try {
       ((RhsAction) theActionObject).setActionContext(actionContext);
-      ((RhsAction) theActionObject).doit(doc, bindings, annotations,
-                                         inputAS, outputAS, ontology);
+      ((RhsAction) theActionObject).doit(doc, bindings, inputAS, outputAS, 
ontology);
     } catch (NonFatalJapeException e) {
       // if the action class throws a non-fatal exception then respond by
       // dumping a whole bunch of useful debug information but then allow

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


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to