Revision: 19642
          http://sourceforge.net/p/gate/code/19642
Author:   markagreenwood
Date:     2016-10-06 09:52:06 +0000 (Thu, 06 Oct 2016)
Log Message:
-----------
more odd little bugs and performance enhancements

Modified Paths:
--------------
    gate/branches/sawdust2/gate-core/src/main/java/gate/CorpusExporter.java
    gate/branches/sawdust2/gate-core/src/main/java/gate/DocumentFormat.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationImpl.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationSetImpl.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentContentImpl.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentData.java
    
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentImpl.java

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/CorpusExporter.java
===================================================================
--- gate/branches/sawdust2/gate-core/src/main/java/gate/CorpusExporter.java     
2016-10-06 07:24:25 UTC (rev 19641)
+++ gate/branches/sawdust2/gate-core/src/main/java/gate/CorpusExporter.java     
2016-10-06 09:52:06 UTC (rev 19642)
@@ -17,8 +17,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.commons.io.IOUtils;
-
 /**
  * A {@link DocumentExporter} that is also capable of exporting
  * a whole corpus to a single file.
@@ -46,13 +44,9 @@
    */
   public void export(Corpus corpus, File file, FeatureMap options)
           throws IOException {
-    FileOutputStream out = null;
-    try {
-      out = new FileOutputStream(file);
+    try (FileOutputStream out = new FileOutputStream(file)){
       export(corpus, new FileOutputStream(file), options);
       out.flush();
-    } finally {
-      IOUtils.closeQuietly(out);
     }
   }
 

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/DocumentFormat.java
===================================================================
--- gate/branches/sawdust2/gate-core/src/main/java/gate/DocumentFormat.java     
2016-10-06 07:24:25 UTC (rev 19641)
+++ gate/branches/sawdust2/gate-core/src/main/java/gate/DocumentFormat.java     
2016-10-06 09:52:06 UTC (rev 19642)
@@ -103,7 +103,7 @@
   private transient Vector<StatusListener> statusListeners;
 
   /** Flag for enable/disable collecting of repositioning information */
-  private Boolean shouldCollectRepositioning = new Boolean(false);
+  private Boolean shouldCollectRepositioning = Boolean.FALSE;
 
   /** If the document format could collect repositioning information
    *  during the unpack phase this method will return <B>true</B>.
@@ -112,7 +112,7 @@
    *  document format if it could collect the repositioning information.
    */
   public Boolean supportsRepositioning() {
-    return new Boolean(false);
+    return Boolean.FALSE;
   } // supportsRepositioning
 
   public void setShouldCollectRepositioning(Boolean b) {
@@ -120,7 +120,7 @@
       shouldCollectRepositioning = b;
     }
     else {
-      shouldCollectRepositioning = new Boolean(false);
+      shouldCollectRepositioning = Boolean.FALSE;
     } // if
   } // setShouldCollectRepositioning
 

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationImpl.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationImpl.java
  2016-10-06 07:24:25 UTC (rev 19641)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationImpl.java
  2016-10-06 09:52:06 UTC (rev 19642)
@@ -20,17 +20,18 @@
 import java.util.Set;
 import java.util.Vector;
 
-import gate.*;
+import gate.Annotation;
+import gate.FeatureMap;
+import gate.Node;
 import gate.event.AnnotationEvent;
 import gate.event.AnnotationListener;
 import gate.util.AbstractFeatureBearer;
-import gate.util.FeatureBearer;
 
 /** Provides an implementation for the interface gate.Annotation
  *
  */
 public class AnnotationImpl extends AbstractFeatureBearer
-                            implements Annotation, FeatureBearer {
+                            implements Annotation {
 
   /** Freeze the serialization UID. */
   static final long serialVersionUID = -5658993256574857725L;

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationSetImpl.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationSetImpl.java
       2016-10-06 07:24:25 UTC (rev 19641)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/annotation/AnnotationSetImpl.java
       2016-10-06 09:52:06 UTC (rev 19642)
@@ -457,8 +457,8 @@
             .getId());
     // skip all the nodes that have no starting annotations
     while(annotationsToAdd == null) {
-      nextNode = nodesByOffset.getNextOf(new Long(nextNode.getOffset()
-              .longValue() + 1));
+      nextNode = nodesByOffset.getNextOf(nextNode.getOffset()
+              .longValue() + 1);
       if (nextNode==null) return emptyAS();
       annotationsToAdd = getAnnotsByStartNode(nextNode.getId());
     }
@@ -759,8 +759,7 @@
   @Override
   public Node nextNode(Node node) {
     indexByStartOffset();
-    return nodesByOffset.getNextOf(new Long(
-            node.getOffset().longValue() + 1));
+    return nodesByOffset.getNextOf(node.getOffset().longValue() + 1);
   }
 
   protected static AnnotationFactory annFactory;
@@ -1043,7 +1042,7 @@
       // the
       // removed section plus the marginal ones
       List<Node> affectedNodes = new 
ArrayList<Node>(nodesByOffset.subMap(start,
-              new Long(end.longValue() + 1)).values());
+              end.longValue() + 1).values());
       // if we have more than 1 node we need to delete all apart from
       // the first
       // and move the annotations so that they refer to the one we keep
@@ -1056,8 +1055,8 @@
         List<Annotation> endingAnnotations = new ArrayList<Annotation>();
         // now we need to find all the annotations
         // ending in the zone
-        List<Node> beforeNodes = new ArrayList<Node>(nodesByOffset.subMap(new 
Long(0),
-                new Long(end.longValue() + 1)).values());
+        List<Node> beforeNodes = new ArrayList<Node>(nodesByOffset.subMap(0L,
+                end.longValue() + 1).values());
         Iterator<Node> beforeNodesIter = beforeNodes.iterator();
         while(beforeNodesIter.hasNext()) {
           Node currentNode = beforeNodesIter.next();
@@ -1156,7 +1155,7 @@
         // if we're prepending we don't move forward
         if(shouldPrepend) newOffset = s;
       }
-      n.setOffset(new Long(newOffset));
+      n.setOffset(newOffset);
     }
     // add back to the index by offset with the new offsets
     nodesAfterReplacementIter = nodesAfterReplacement.iterator();

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentContentImpl.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentContentImpl.java
        2016-10-06 07:24:25 UTC (rev 19641)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentContentImpl.java
        2016-10-06 09:52:06 UTC (rev 19642)
@@ -41,7 +41,7 @@
 
   /** Default construction */
   public DocumentContentImpl() {
-    content = new String();
+    content = "";
   } // default construction
 
   /** Contruction from URL and offsets. */
@@ -143,7 +143,7 @@
     */
   @Override
   public Long size() {
-    return new Long(content.length());
+    return Long.valueOf(content.length());
   } // size()
 
   /** Check that an offset is valid */

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentData.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentData.java   
    2016-10-06 07:24:25 UTC (rev 19641)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentData.java   
    2016-10-06 09:52:06 UTC (rev 19642)
@@ -49,7 +49,7 @@
 
   @Override
   public String toString() {
-    return new String("DocumentData: " + docName + ", " + persistentID + ", " 
+ classType);
+    return "DocumentData: " + docName + ", " + persistentID + ", " + classType;
   }
 
   String docName;

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentImpl.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentImpl.java   
    2016-10-06 07:24:25 UTC (rev 19641)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/corpora/DocumentImpl.java   
    2016-10-06 09:52:06 UTC (rev 19642)
@@ -184,14 +184,14 @@
    * kept in the document feature. <br>
    * Default value is false to avoid the unnecessary waste of memory
    */
-  private Boolean preserveOriginalContent = new Boolean(false);
+  private Boolean preserveOriginalContent = Boolean.FALSE;
 
   /**
    * If you set this flag to true the repositioning information for the 
document
    * will be kept in the document feature. <br>
    * Default value is false to avoid the unnecessary waste of time and memory
    */
-  private Boolean collectRepositioningInfo = new Boolean(false);
+  private Boolean collectRepositioningInfo = Boolean.FALSE;
 
   /**
    * This is a variable which contains the latest crossed over annotation found
@@ -259,8 +259,8 @@
       }
     }
     if(preserveOriginalContent.booleanValue() && content != null) {
-      String originalContent = new String(((DocumentContentImpl)content)
-              .getOriginalContent());
+      String originalContent = ((DocumentContentImpl)content)
+              .getOriginalContent();
       getFeatures().put(GateConstants.ORIGINAL_DOCUMENT_CONTENT_FEATURE_NAME,
               originalContent);
     } // if
@@ -847,8 +847,7 @@
             DocumentXmlUtils.DOC_SIZE_MULTIPLICATION_FACTOR
             * (this.getContent().size().intValue()));
     // Add xml header if original format was xml
-    String mimeType = getFeatures() == null ? null : (String)getFeatures().get(
-            "MimeType");
+    String mimeType = (String)getFeatures().get("MimeType");
     boolean wasXML = mimeType != null && mimeType.equalsIgnoreCase("text/xml");
     if(wasXML) {
       xmlDoc.append("<?xml version=\"1.0\" encoding=\"");
@@ -1004,7 +1003,7 @@
           boolean includeFeatures) {
     String content = null;
     if(this.getContent() == null)
-      content = new String("");
+      content = "";
     else content = this.getContent().toString();
     StringBuffer docContStrBuff =
       DocumentXmlUtils.filterNonXmlChars(new StringBuffer(content));
@@ -1469,24 +1468,24 @@
     // Then take all the annotations from aSourceAnnotationSet and verify if
     // they can be inserted safely into the dumpingSet. Where not possible,
     // report.
-    if(aSourceAnnotationSet != null) {
-      Iterator<Annotation> iter = aSourceAnnotationSet.iterator();
-      Annotation currentAnnot;
-      while(iter.hasNext()) {
-        currentAnnot = iter.next();
-        if(insertsSafety(originalMarkupsAnnotSet, currentAnnot)
-                && insertsSafety(dumpingSet, currentAnnot)) {
-          dumpingSet.add(currentAnnot);
-        } else {
-          Out.prln("Warning: Annotation with ID=" + currentAnnot.getId()
-                  + ", startOffset=" + currentAnnot.getStartNode().getOffset()
-                  + ", endOffset=" + currentAnnot.getEndNode().getOffset()
-                  + ", type=" + currentAnnot.getType()
-                  + " was found to violate the"
-                  + " crossed over condition. It will be discarded");
-        }// End if
-      }// End while
-    }// End if
+    
+    Iterator<Annotation> iter = aSourceAnnotationSet.iterator();
+    Annotation currentAnnot;
+    while(iter.hasNext()) {
+      currentAnnot = iter.next();
+      if(insertsSafety(originalMarkupsAnnotSet, currentAnnot)
+              && insertsSafety(dumpingSet, currentAnnot)) {
+        dumpingSet.add(currentAnnot);
+      } else {
+        Out.prln("Warning: Annotation with ID=" + currentAnnot.getId()
+                + ", startOffset=" + currentAnnot.getStartNode().getOffset()
+                + ", endOffset=" + currentAnnot.getEndNode().getOffset()
+                + ", type=" + currentAnnot.getType()
+                + " was found to violate the"
+                + " crossed over condition. It will be discarded");
+      }// End if
+    }// End while
+    
     // The dumpingSet is ready to be exported as XML
     // Here we go.
     if(sListener != null)
@@ -1497,7 +1496,7 @@
     // order. For each node write all the tags from left to right.
     // Construct the node set
     TreeSet<Long> offsets = new TreeSet<Long>();
-    Iterator<Annotation> iter = aSourceAnnotationSet.iterator();
+    iter = aSourceAnnotationSet.iterator();
     while(iter.hasNext()) {
       Annotation annot = iter.next();
       offsets.add(annot.getStartNode().getOffset());
@@ -1919,7 +1918,7 @@
       while(-1 != fromIndex) {
         fromIndex = aScanString.indexOf(c.charValue(), fromIndex);
         if(-1 != fromIndex) {
-          aMapToFill.put(new Long(fromIndex), c);
+          aMapToFill.put(Long.valueOf(fromIndex), c);
           fromIndex++;
         }// End if
       }// End while
@@ -2165,7 +2164,7 @@
 
   /** Generate and return the next annotation ID */
   public Integer getNextAnnotationId() {
-    return new Integer(nextAnnotationId++);
+    return nextAnnotationId++;
   } // getNextAnnotationId
   
   /** look at the next annotation ID without incrementing it */
@@ -2175,7 +2174,7 @@
 
   /** Generate and return the next node ID */
   public Integer getNextNodeId() {
-    return new Integer(nextNodeId++);
+    return nextNodeId++;
   }
 
   /** Ordering based on URL.toString() and the URL offsets (if any) */
@@ -2400,7 +2399,7 @@
           return result;
         } else {
           // DESC
-          if(result == 0) return -(a1.getId().compareTo(a2.getId()));
+          if(result == 0) return a2.getId().compareTo(a1.getId());
           return -result;
         }// End if (orderType == ASC)
       }// End if (orderOn == ORDER_ON_START_OFFSET)
@@ -2411,7 +2410,7 @@
         if(orderType == ASC) {
           // ASC
           // If they are equal then their ID will decide.
-          if(result == 0) return -(a1.getId().compareTo(a2.getId()));
+          if(result == 0) return a2.getId().compareTo(a1.getId());
           return result;
         } else {
           // DESC
@@ -2424,7 +2423,7 @@
       if(orderOn == ORDER_ON_ANNOT_ID) {
         if(orderType == ASC)
           return a1.getId().compareTo(a2.getId());
-        else return -(a1.getId().compareTo(a2.getId()));
+        else return a2.getId().compareTo(a1.getId());
       }// End if
       return 0;
     }// compare()

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