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/08 18:25:25 UTC

svn commit: r983443 - in /uima/uimaj/trunk: jVinci/src/main/java/org/apache/vinci/transport/vns/service/ uimaj-examples/src/main/java/org/apache/uima/examples/ uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/

Author: schor
Date: Sun Aug  8 16:25:24 2010
New Revision: 983443

URL: http://svn.apache.org/viewvc?rev=983443&view=rev
Log:
[UIMA-1853] vinci ServiceRegistry - add (probably unused) hashCode that matches equals for inner class.  

uimaj-examples: ExampleApplication: remove unused local variable, and the try/finally block that was there in case it was used.

uimaj-examples: SofaExampleAnnotator: removed unneeded new String("xxx"), replace with just "xxx".

uimaj-examples: TutorialDateTime: change DateFormat field from static to instance, because it's not thread-safe.

Modified:
    uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/vns/service/ServiceRegistry.java
    uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/ExampleApplication.java
    uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/SofaExampleAnnotator.java
    uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/TutorialDateTime.java

Modified: uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/vns/service/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/vns/service/ServiceRegistry.java?rev=983443&r1=983442&r2=983443&view=diff
==============================================================================
--- uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/vns/service/ServiceRegistry.java (original)
+++ uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/vns/service/ServiceRegistry.java Sun Aug  8 16:25:24 2010
@@ -524,6 +524,11 @@ public class ServiceRegistry {
 
       return (p.minPort == minPort) && (p.maxPort == maxPort);
     }
+
+    @Override
+    public int hashCode() {
+      return minPort * 31 + maxPort;
+    }
   }
 
   /* For testing */

Modified: uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/ExampleApplication.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/ExampleApplication.java?rev=983443&r1=983442&r2=983443&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/ExampleApplication.java (original)
+++ uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/ExampleApplication.java Sun Aug  8 16:25:24 2010
@@ -117,31 +117,21 @@ public class ExampleApplication {
   private static void processFile(File aFile, AnalysisEngine aAE, CAS aCAS) throws IOException,
           AnalysisEngineProcessException {
     System.out.println("Processing file " + aFile.getName());
-    BufferedInputStream fis = null;
 
-    try {
-      String document = FileUtils.file2String(aFile);
-      document = document.trim();
-
-      // put document text in CAS
-      aCAS.setDocumentText(document);
-
-      // process
-      aAE.process(aCAS);
-
-      // print annotations to System.out
-      PrintAnnotations.printAnnotations(aCAS, System.out);
-
-      // reset the CAS to prepare it for processing the next document
-      aCAS.reset();
-    } finally {
-      try {
-        if (fis != null)
-          fis.close();
-      } catch (Exception ex) {
-        ex.printStackTrace();
-      }
-    }
+    String document = FileUtils.file2String(aFile);
+    document = document.trim();
+
+    // put document text in CAS
+    aCAS.setDocumentText(document);
+
+    // process
+    aAE.process(aCAS);
+
+    // print annotations to System.out
+    PrintAnnotations.printAnnotations(aCAS, System.out);
+
+    // reset the CAS to prepare it for processing the next document
+    aCAS.reset();
   }
 
 }

Modified: uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/SofaExampleAnnotator.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/SofaExampleAnnotator.java?rev=983443&r1=983442&r2=983443&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/SofaExampleAnnotator.java (original)
+++ uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/SofaExampleAnnotator.java Sun Aug  8 16:25:24 2010
@@ -105,12 +105,12 @@ public class SofaExampleAnnotator extend
   private String translate(String word) {
     String lword = word.toLowerCase();
     if (Arrays.equals(wThis, lword.toCharArray()))
-      return new String("das");
+      return "das";
     if (Arrays.equals(wBeer, lword.toCharArray()))
-      return new String("bier");
+      return "bier";
     if (Arrays.equals(wIs, lword.toCharArray()))
-      return new String("ist");
-    return new String("gut");
+      return "ist";
+    return "gut";
   }
 
 }

Modified: uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/TutorialDateTime.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/TutorialDateTime.java?rev=983443&r1=983442&r2=983443&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/TutorialDateTime.java (original)
+++ uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/tutorial/ex3/TutorialDateTime.java Sun Aug  8 16:25:24 2010
@@ -78,7 +78,8 @@ public class TutorialDateTime extends JC
   static final Pattern numericDatePattern = Pattern
           .compile("(?s)\\b([0-1]?\\d/[0-3]?\\d((/[1-2]\\d\\d\\d)|(/\\d\\d))?)\\W");
 
-  static final DateFormat dfDateShort = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
+  // not static, because DateFormat is not threadsafe
+  final DateFormat dfDateShort = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
 
   // .*? (any number of artibrary chars, non greedy
   // \b word boundary
@@ -202,7 +203,7 @@ public class TutorialDateTime extends JC
     String av; // append value
     pp.setIndex(0);
     if (-1 < s.indexOf(":")) { // have time string
-      if (s.endsWith("AM") | s.endsWith("PM") | s.endsWith("am") | s.endsWith("pm"))
+      if (s.endsWith("AM") || s.endsWith("PM") || s.endsWith("am") || s.endsWith("pm"))
         return s;
       else {
         int hour = numberFormat.parse(s, pp).intValue();