Revision: 19648
          http://sourceforge.net/p/gate/code/19648
Author:   markagreenwood
Date:     2016-10-07 15:42:09 +0000 (Fri, 07 Oct 2016)
Log Message:
-----------
some more bug fixes and performance improvements

Modified Paths:
--------------
    
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/UimaDocumentFormat.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ConditionalSerialController.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleAnnotationHandler.java
    gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/annic/HTMLGenerator.java

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/UimaDocumentFormat.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/UimaDocumentFormat.java
 2016-10-07 01:22:25 UTC (rev 19647)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/UimaDocumentFormat.java
 2016-10-07 15:42:09 UTC (rev 19648)
@@ -100,11 +100,11 @@
     if (sofaSet.size() > 1) {
       Out.prln("More than one UIMA SOFA, annotation offsets won't be 
correct.");
     }
-    String documentContent = "";
+    StringBuilder documentContent = new StringBuilder();
     for (Annotation annotation : sofaSet) {
-      documentContent += (String) annotation.getFeatures().get("sofaString");
+      documentContent.append((String) 
annotation.getFeatures().get("sofaString"));
     }
-    doc.setContent(new DocumentContentImpl(documentContent));
+    doc.setContent(new DocumentContentImpl(documentContent.toString()));
 
     // remove SOFA annotations
     inputAS.removeAll(sofaSet);

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ConditionalSerialController.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ConditionalSerialController.java
 2016-10-07 01:22:25 UTC (rev 19647)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ConditionalSerialController.java
 2016-10-07 15:42:09 UTC (rev 19648)
@@ -14,9 +14,18 @@
 
 package gate.creole;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
-import gate.*;
+import gate.Factory;
+import gate.LanguageAnalyser;
+import gate.ProcessingResource;
+import gate.Resource;
 import gate.creole.RunningStrategy.UnconditionalRunningStrategy;
 import gate.creole.metadata.CreoleResource;
 import gate.event.ControllerEvent;
@@ -170,9 +179,9 @@
       long timeTakenByThePR = System.currentTimeMillis() - startTime;
       Long time = prTimeMap.get(currentPR.getName());
       if(time == null) {
-        time = new Long(0);
+        time = 0L;
       }
-      time = new Long(time.longValue() + timeTakenByThePR);
+      time += timeTakenByThePR;
       prTimeMap.put(currentPR.getName(), time);
     }
 

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleAnnotationHandler.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleAnnotationHandler.java
     2016-10-07 01:22:25 UTC (rev 19647)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleAnnotationHandler.java
     2016-10-07 15:42:09 UTC (rev 19648)
@@ -59,6 +59,7 @@
 import org.apache.log4j.Logger;
 import org.jdom.Document;
 import org.jdom.Element;
+import org.jdom.JDOMException;
 import org.jdom.xpath.XPath;
 
 /**
@@ -137,10 +138,10 @@
           url = new URL(plugin.getBaseURL(), urlString);
         }
 
-        Gate.getCreoleRegister().registerDirectories(url);
+        Gate.getCreoleRegister().registerPlugin(new Plugin.Directory(url));
       }
-    } catch(Exception e) {
-      throw new IOException("Unable to load required plugin", e);
+    } catch(GateException | JDOMException e) {
+      throw new IOException("Unable to load required plugin",e);
     }
   }
 
@@ -151,6 +152,7 @@
    * @param creoleDoc
    *          JDOM document representing a parsed creole.xml file.
    */
+  @Deprecated
   private void addIvyDependencies(GateClassLoader gcl, Document creoleDoc)
       throws IOException {
 

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java
===================================================================
--- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java   
2016-10-07 01:22:25 UTC (rev 19647)
+++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java   
2016-10-07 15:42:09 UTC (rev 19648)
@@ -24,6 +24,7 @@
 import gate.util.Strings;
 
 import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -208,10 +209,13 @@
         try{
           fm = paramClass.asSubclass(FeatureMap.class).getConstructor(new 
Class<?>[]{}).
                                     newInstance(new Object[]{});
-        } catch(Exception ex){
-            throw new ParameterException("Could not construct an object of 
type "
+        } catch(InstantiationException | IllegalAccessException
+            | IllegalArgumentException | InvocationTargetException
+            | NoSuchMethodException | SecurityException e) {
+          
+          throw new ParameterException("Could not construct an object of type "
               + typeName + " for param " + name +
-              "\nProblem was: " + ex.toString());
+              "\nProblem was: " + e.toString());
         }
       }
       
@@ -361,10 +365,10 @@
   String helpURL;
   
   /** Set the helpURL for this parameter */
-  public void sethelpURL(String helpURL) { this.helpURL = helpURL; }
+  public void setHelpURL(String helpURL) { this.helpURL = helpURL; }
   
   /** Get the helpURL for this parameter */
-  public String gethelpURL() { return helpURL; }
+  public String getHelpURL() { return helpURL; }
   
   /** Name for the parameter */
   String name;

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/annic/HTMLGenerator.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/annic/HTMLGenerator.java
 2016-10-07 01:22:25 UTC (rev 19647)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/annic/HTMLGenerator.java
 2016-10-07 15:42:09 UTC (rev 19648)
@@ -27,7 +27,7 @@
     PatternAnnotation[] patternAnnotations = pattern.getPatternAnnotations();
 
     // for each table we create a separate html code
-    String html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" 
width=\"100%\" style=\"border-collapse: collapse; border: medium none; 
background: #E6E6E6\">";
+    StringBuilder html = new StringBuilder("<table cellpadding=\"0\" 
cellspacing=\"0\" border=\"1\" width=\"100%\" style=\"border-collapse: 
collapse; border: medium none; background: #E6E6E6\">");
 
     // at the begining we find out number of rows we need to create for
     // this
@@ -47,29 +47,31 @@
 
     patternAnnotations = sort(patternAnnotations);
 
-    html += "\n"
-            + "<tr> " +
-            "<td style=\"width: 85.25pt; border-left: medium none; 
border-right: 1.0pt dashed blue; " +
-            "border-top: 1.0pt dashed blue; border-bottom: 1.0pt dashed blue; 
padding-left: 5.4pt; " +
-            "padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm\">" +
-            "<p class=\"MsoNormal\" align=\"center\">Pattern Text : </td>";
+    html.append("\n").append("<tr> ")
+        .append(
+            "<td style=\"width: 85.25pt; border-left: medium none; 
border-right: 1.0pt dashed blue; ")
+        .append(
+            "border-top: 1.0pt dashed blue; border-bottom: 1.0pt dashed blue; 
padding-left: 5.4pt; ")
+        .append(
+            "padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm\">")
+        .append("<p class=\"MsoNormal\" align=\"center\">Pattern Text : 
</td>");
     int endPos = patternAnnotations[0].getStartOffset();
     int startPos = 0;
     for(int j = 1; j < colPositions.size(); j++) {
       startPos = endPos;
       endPos = Integer.parseInt(colPositions.get(j));
       String text = pattern.getPatternText(startPos, endPos);
-      html += "\n"
-              + "<td style=\"border: 1.0pt dashed blue;\" align=\"center\">"
-              + text + "</td>";
+      html.append("\n")
+          .append("<td style=\"border: 1.0pt dashed blue;\" align=\"center\">")
+          .append(text).append("</td>");
     }
 
     // and now for each type we create a new Row
     for(int j = 0; j < rows.size(); j++) {
 
       // first column is the annotation Type
-      html += "\n" + "<tr width=\"100%\" height=\"19\"> <td>"
-              + rows.get(j) + "</td>";
+      html.append("\n").append("<tr width=\"100%\" height=\"19\"> <td>")
+          .append(rows.get(j)).append("</td>");
       List<PatternAnnotation> rowAnnotations = 
findOutAnnotationsOfType(patternAnnotations,
               rows.get(j));
 
@@ -79,9 +81,8 @@
         PatternAnnotation annot = rowAnnotations.get(k);
 
         // we may need to draw few columns before this annotations
-        html += "\n"
-                + columnsToDraw(patternAnnotations, rowAnnotations, k,
-                        colPositions);
+        html.append("\n").append(columnsToDraw(patternAnnotations, 
rowAnnotations, k,
+                        colPositions));
         columnsDrawn += noOfColumnsToDraw;
 
         // now lets find out the annotations at the same starting
@@ -113,35 +114,37 @@
                 colPositions);
 
         if(colSpan > 0) {
-          html += "\n"
-                  + "<td style=\"border: 1.0pt dashed blue;\" align=\"center\" 
colspan=\""
-                  + colSpan + "\" <p align=\"center\">";
+          html.append("\n")
+              .append(
+                  "<td style=\"border: 1.0pt dashed blue;\" align=\"center\" 
colspan=\"")
+              .append(colSpan + "\" <p align=\"center\">");
           columnsDrawn += colSpan;
         }
         else {
-          html += "\n"
-                  + "<td style=\"border: 1.0pt dashed blue;\" 
align=\"center\"> <p align=\"center\">";
+          html.append("\n").append(
+              "<td style=\"border: 1.0pt dashed blue;\" align=\"center\"> <p 
align=\"center\">");
           columnsDrawn += 1;
         }
 
         for(m = 0; m < tempList.size(); m++) {
-          html += addFeatures(tempList.get(m).getFeatures())
-                  + "<br>";
+          html.append(addFeatures(tempList.get(m).getFeatures()))
+              .append("<br>");
         }
 
-        html += "</td>";
+        html.append("</td>");
       }
 
       // now see how many columns are yet to be drawn
       for(int k = 0; k < colPositions.size() - columnsDrawn; k++) {
-        html += "\n" + "<td style=\"border: 1.0pt dashed blue;\">&nbsp;</td>";
+        html.append("\n")
+            .append("<td style=\"border: 1.0pt dashed blue;\">&nbsp;</td>");
       }
-      html += "\n" + "</tr>";
+      html.append("\n").append("</tr>");
     }
 
     // and finally we need to add all the annotations at the end
-    html += "\n" + "</table>";
-    return html;
+    html.append("\n").append("</table>");
+    return html.toString();
   }
 
   /**
@@ -193,11 +196,11 @@
     noOfColumnsToDraw = noOfColumnsToDraw(startPoint,
             rowAnnotations.get(currentPos)
                     .getStartOffset(), colPositions);
-    String html = "";
+    StringBuilder html = new StringBuilder();
     for(int i = 0; i < noOfColumnsToDraw; i++) {
-      html += "\n" + "<td style=\"border: 1.0pt dashed blue;\">&nbsp;</td>";
+      html.append("\n").append("<td style=\"border: 1.0pt dashed 
blue;\">&nbsp;</td>");
     }
-    return html;
+    return html.toString();
   }
 
   private static int noOfColumnsToDraw(int start, int end,
@@ -325,14 +328,11 @@
   // this method takes the features of a particular annotations
   // and returns the equivalent html code
   private static String addFeatures(Map<String, String> features) {
-    String html = "<select size=\"1\" >";
-    Iterator<String> fIter = features.keySet().iterator();
-    while(fIter.hasNext()) {
-      String key = fIter.next();
-      String value = features.get(key).toString();
-      html += "\n" + "<option>" + key + " = \"" + value + "\"</option>";
+    StringBuilder html = new StringBuilder("<select size=\"1\" >");
+    for (Map.Entry<String,String> feature : features.entrySet()) {
+      html.append("\n").append("<option>").append(feature.getKey()).append(" = 
\"").append(feature.getValue()).append("\"</option>");
     }
-    html += "\n" + "</select>";
-    return html;
+    html.append("\n").append("</select>");
+    return html.toString();
   }
 }

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