You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/09/02 17:18:01 UTC

svn commit: r810550 - in /incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier: SimpleCasGenerator.java SimpleCasMerger.java

Author: cwiklik
Date: Wed Sep  2 15:18:01 2009
New Revision: 810550

URL: http://svn.apache.org/viewvc?rev=810550&view=rev
Log:
UIMA-1541 Reformatted to conform to UIMA formatting guidelines. No other changes included.

Modified:
    incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
    incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasMerger.java

Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java?rev=810550&r1=810549&r2=810550&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java Wed Sep  2 15:18:01 2009
@@ -55,115 +55,93 @@
 /**
  * An example CasMultiplier, which generates the specified number of output CASes.
  */
-public class SimpleCasGenerator extends CasMultiplier_ImplBase
-{
-	private int mCount;
-
-	private int nToGen;
-    
-	private String text;
-
-	long docCount=0;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent_ImplBase#initialize(org.apache.uima.UimaContext)
-	 */
-	public void initialize(UimaContext aContext) throws ResourceInitializationException {
+public class SimpleCasGenerator extends CasMultiplier_ImplBase {
+  private int mCount;
+
+  private int nToGen;
+
+  private String text;
+
+  long docCount = 0;
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.uima.analysis_component.AnalysisComponent_ImplBase#initialize(org.apache.uima.
+   * UimaContext)
+   */
+  public void initialize(UimaContext aContext) throws ResourceInitializationException {
     super.initialize(aContext);
     this.nToGen = ((Integer) aContext.getConfigParameterValue("NumberToGenerate")).intValue();
     FileInputStream fis = null;
-    try
-    {
-  	  String filename = ((String) aContext.getConfigParameterValue("InputFile")).trim();
-  	  File file = null;
-  	  	try
-  	  	{
-  	  	    URL url = this.getClass().getClassLoader().getResource(filename);
-  	  	  	System.out.println("************ File::::"+url.getPath());
-  	  	  	// open input stream to file
-  	        file = new File( url.getPath() );
-  	  	}
-  	  	catch( Exception e)
-  	  	{
-  	  		file = new File(filename);
-  	  	}
-  	  	fis = new FileInputStream(file);
-         byte[] contents = new byte[(int) file.length()];
-          fis.read(contents);
-          text = new String(contents);
-    }
-    catch( Exception e)
-    {
-    	throw new ResourceInitializationException(e);
-    }
-    finally 
-    {
-      if (fis != null)
-      {
-    	  try
-    	  {
-        	  fis.close();
-    	  }
-    	  catch( Exception e){}
+    try {
+      String filename = ((String) aContext.getConfigParameterValue("InputFile")).trim();
+      File file = null;
+      try {
+        URL url = this.getClass().getClassLoader().getResource(filename);
+        System.out.println("************ File::::" + url.getPath());
+        // open input stream to file
+        file = new File(url.getPath());
+      } catch (Exception e) {
+        file = new File(filename);
+      }
+      fis = new FileInputStream(file);
+      byte[] contents = new byte[(int) file.length()];
+      fis.read(contents);
+      text = new String(contents);
+    } catch (Exception e) {
+      throw new ResourceInitializationException(e);
+    } finally {
+      if (fis != null) {
+        try {
+          fis.close();
+        } catch (Exception e) {
+        }
       }
     }
-    
+
   }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see JCasMultiplier_ImplBase#process(JCas)
-	 */
-	public void process(CAS aCas) throws AnalysisEngineProcessException
-	{
-		this.mCount = 0;
-    this.docCount=0;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent#hasNext()
-	 */
-	public boolean hasNext() throws AnalysisEngineProcessException
-	{
-		return this.mCount < this.nToGen;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent#next()
-	 */
-	public AbstractCas next() throws AnalysisEngineProcessException
-	{
-
-		CAS cas = getEmptyCAS();
-/*
-		int junk = this.gen.nextInt();
-		if ((junk & 1) != 0)
-		{
-			cas.setDocumentText(this.mDoc1);
-		}
-		else
-		{
-			cas.setDocumentText(this.mDoc2);
-		}
-*/
-		if (docCount ==0 && UIMAFramework.getLogger().isLoggable(Level.FINE))
-		{
-			System.out.println("Initializing CAS with a Document of Size:"+text.length());
-		}
-		docCount++;
-		if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
-			System.out.println("CasMult creating document#"+docCount);
-		cas.setDocumentText(this.text);
-		this.mCount++;
-		return cas;
-	}
+  /*
+   * (non-Javadoc)
+   * 
+   * @see JCasMultiplier_ImplBase#process(JCas)
+   */
+  public void process(CAS aCas) throws AnalysisEngineProcessException {
+    this.mCount = 0;
+    this.docCount = 0;
+  }
 
-}
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.uima.analysis_component.AnalysisComponent#hasNext()
+   */
+  public boolean hasNext() throws AnalysisEngineProcessException {
+    return this.mCount < this.nToGen;
+  }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.uima.analysis_component.AnalysisComponent#next()
+   */
+  public AbstractCas next() throws AnalysisEngineProcessException {
+
+    CAS cas = getEmptyCAS();
+    /*
+     * int junk = this.gen.nextInt(); if ((junk & 1) != 0) { cas.setDocumentText(this.mDoc1); } else
+     * { cas.setDocumentText(this.mDoc2); }
+     */
+    if (docCount == 0 && UIMAFramework.getLogger().isLoggable(Level.FINE)) {
+      System.out.println("Initializing CAS with a Document of Size:" + text.length());
+    }
+    docCount++;
+    if (UIMAFramework.getLogger().isLoggable(Level.FINE))
+      System.out.println("CasMult creating document#" + docCount);
+    cas.setDocumentText(this.text);
+    this.mCount++;
+    return cas;
+  }
+
+}

Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasMerger.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasMerger.java?rev=810550&r1=810549&r2=810550&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasMerger.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasMerger.java Wed Sep  2 15:18:01 2009
@@ -52,25 +52,25 @@
 import org.apache.uima.util.Level;
 
 /**
- * An example CasMultiplier, which simulates merging of the input CASes.
- * Generates 1 output CAS for every N input CASes.
+ * An example CasMultiplier, which simulates merging of the input CASes. Generates 1 output CAS for
+ * every N input CASes.
  */
-public class SimpleCasMerger extends CasMultiplier_ImplBase
-{
-	private int docCount = 0;
+public class SimpleCasMerger extends CasMultiplier_ImplBase {
+  private int docCount = 0;
 
   private int genCount = 0;
 
   private int nToMerge;
-  
+
   private String casMultName;
-    
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent_ImplBase#initialize(org.apache.uima.UimaContext)
-	 */
-	public void initialize(UimaContext aContext) throws ResourceInitializationException {
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.uima.analysis_component.AnalysisComponent_ImplBase#initialize(org.apache.uima.
+   * UimaContext)
+   */
+  public void initialize(UimaContext aContext) throws ResourceInitializationException {
     super.initialize(aContext);
     this.nToMerge = ((Integer) aContext.getConfigParameterValue("NumberToMerge")).intValue();
     this.casMultName = (String) aContext.getConfigParameterValue("AnnotatorName");
@@ -79,46 +79,42 @@
     }
   }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see JCasMultiplier_ImplBase#process(JCas)
-	 */
-	public void process(CAS aCas) throws AnalysisEngineProcessException
-	{
-		this.docCount++;
-    if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
-      System.out.println(casMultName + ".process() received document " + this.docCount );
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent#hasNext()
-	 */
-	public boolean hasNext() throws AnalysisEngineProcessException
-	{
-	  // Generate N-th when receive M * N-th input
-		return (docCount >= (genCount+1) * nToMerge);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.uima.analysis_component.AnalysisComponent#next()
-	 */
-	public AbstractCas next() throws AnalysisEngineProcessException
-	{	
-	  CAS cas = getEmptyCAS();
-	   
+  /*
+   * (non-Javadoc)
+   * 
+   * @see JCasMultiplier_ImplBase#process(JCas)
+   */
+  public void process(CAS aCas) throws AnalysisEngineProcessException {
+    this.docCount++;
+    if (UIMAFramework.getLogger().isLoggable(Level.FINE))
+      System.out.println(casMultName + ".process() received document " + this.docCount);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.uima.analysis_component.AnalysisComponent#hasNext()
+   */
+  public boolean hasNext() throws AnalysisEngineProcessException {
+    // Generate N-th when receive M * N-th input
+    return (docCount >= (genCount + 1) * nToMerge);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.uima.analysis_component.AnalysisComponent#next()
+   */
+  public AbstractCas next() throws AnalysisEngineProcessException {
+    CAS cas = getEmptyCAS();
+
     this.genCount++;
     String text = casMultName + " created #" + this.genCount + " from #" + this.docCount;
-    if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
+    if (UIMAFramework.getLogger().isLoggable(Level.FINE))
       System.out.println(text);
     cas.setDocumentText(text);
-    
+
     return cas;
-	}
+  }
 
 }
-