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:33 UTC
svn commit: r810551 - in
/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop:
CheckTextAnnotator.java NoOpAnnotator.java NoOpCC.java SimpleAnnotator.java
Author: cwiklik
Date: Wed Sep 2 15:18:33 2009
New Revision: 810551
URL: http://svn.apache.org/viewvc?rev=810551&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/noop/CheckTextAnnotator.java
incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpAnnotator.java
incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpCC.java
incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/SimpleAnnotator.java
Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/CheckTextAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/CheckTextAnnotator.java?rev=810551&r1=810550&r2=810551&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/CheckTextAnnotator.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/CheckTextAnnotator.java Wed Sep 2 15:18:33 2009
@@ -54,55 +54,54 @@
import org.apache.uima.util.Logger;
/**
- * Checks that the sofa data of every N-th CAS starts with the correct value.
- * Validates output of a CasMultiplier that merges its input CASes
+ * Checks that the sofa data of every N-th CAS starts with the correct value. Validates output of a
+ * CasMultiplier that merges its input CASes
*/
-public class CheckTextAnnotator extends CasAnnotator_ImplBase
-{
+public class CheckTextAnnotator extends CasAnnotator_ImplBase {
String name = "CheckText";
+
int counter;
-
+
int checkInterval = 0;
- int finalCount = 0;
+
+ int finalCount = 0;
+
String textPrefix;
-
- public void initialize(UimaContext aContext) throws ResourceInitializationException
- {
- super.initialize(aContext);
- counter = 0;
-
- textPrefix = (String)getContext().getConfigParameterValue("TextPrefix");
- checkInterval = ((Integer)getContext().getConfigParameterValue("CheckInterval")).intValue();
+
+ public void initialize(UimaContext aContext) throws ResourceInitializationException {
+ super.initialize(aContext);
+ counter = 0;
+
+ textPrefix = (String) getContext().getConfigParameterValue("TextPrefix");
+ checkInterval = ((Integer) getContext().getConfigParameterValue("CheckInterval")).intValue();
if (getContext().getConfigParameterValue("FinalCount") != null) {
- finalCount = ((Integer) getContext().getConfigParameterValue(
- "FinalCount")).intValue();
+ finalCount = ((Integer) getContext().getConfigParameterValue("FinalCount")).intValue();
}
- // write log messages
- Logger logger = getContext().getLogger();
- logger.log(Level.CONFIG, name+" initialized");
- }
-
- public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException
- {
- }
-
- public void collectionProcessComplete() throws AnalysisEngineProcessException
- {
- System.out.println(name+".collectionProcessComplete() Called -------------------------------------");
+ // write log messages
+ Logger logger = getContext().getLogger();
+ logger.log(Level.CONFIG, name + " initialized");
+ }
+
+ public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException {
+ }
+
+ public void collectionProcessComplete() throws AnalysisEngineProcessException {
+ System.out.println(name
+ + ".collectionProcessComplete() Called -------------------------------------");
if (finalCount > 0 && finalCount != counter) {
- String msg = name+" expected " + finalCount + " CASes but was given " + counter;
+ String msg = name + " expected " + finalCount + " CASes but was given " + counter;
System.out.println(msg);
throw new AnalysisEngineProcessException(new Exception(msg));
}
- if ( UIMAFramework.getLogger().isLoggable(Level.INFO)) {
- System.out.println(name+" processed " + counter + " CASes");
+ if (UIMAFramework.getLogger().isLoggable(Level.INFO)) {
+ System.out.println(name + " processed " + counter + " CASes");
}
counter = 0;
- }
-
- public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ }
+
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
++counter;
String line = aCAS.getDocumentText();
if (UIMAFramework.getLogger().isLoggable(Level.FINE)) {
@@ -113,13 +112,14 @@
}
if (checkInterval > 0 && counter % checkInterval == 0) {
if (!line.startsWith(textPrefix)) {
- String msg = name+" expected "+counter+"-th CAS to start with: " + textPrefix;
+ String msg = name + " expected " + counter + "-th CAS to start with: " + textPrefix;
System.out.println(msg);
throw new AnalysisEngineProcessException(new Exception(msg));
}
}
- // If not checking the document text check if a SourceDocumentInformation annotation has been added
+ // If not checking the document text check if a SourceDocumentInformation annotation has been
+ // added
if (checkInterval == 0) {
JCas jcas;
try {
@@ -130,11 +130,11 @@
AnnotationIndex aIndx = jcas.getAnnotationIndex(SourceDocumentInformation.type);
FSIterator aIter = aIndx.iterator();
if (!aIter.isValid()) {
- String msg = name+" didn't find a SourceDocumentInformation annotation";
+ String msg = name + " didn't find a SourceDocumentInformation annotation";
System.out.println(msg);
throw new AnalysisEngineProcessException(new Exception(msg));
}
- System.out.println(name+" found a SourceDocumentInformation");
+ System.out.println(name + " found a SourceDocumentInformation");
}
}
Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpAnnotator.java?rev=810551&r1=810550&r2=810551&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpAnnotator.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpAnnotator.java Wed Sep 2 15:18:33 2009
@@ -31,117 +31,111 @@
import org.apache.uima.util.Level;
import org.apache.uima.util.Logger;
-public class NoOpAnnotator extends CasAnnotator_ImplBase
-{
- private long counter = 0;
+public class NoOpAnnotator extends CasAnnotator_ImplBase {
+ private long counter = 0;
+
private long countDown = 0;
- int errorFrequency = 0;
- int processDelay = 0;
+
+ int errorFrequency = 0;
+
+ int processDelay = 0;
+
int finalCount = 0;
+
int cpcDelay = 0;
-
- public void initialize(UimaContext aContext) throws ResourceInitializationException
- {
- super.initialize(aContext);
-
- if ( getContext().getConfigParameterValue("FailDuringInitialization") != null )
- {
- throw new ResourceInitializationException(new FileNotFoundException("Simulated Exception"));
- }
-
- if ( getContext().getConfigParameterValue("ErrorFrequency") != null )
- {
- errorFrequency = ((Integer)getContext().getConfigParameterValue("ErrorFrequency")).intValue();
+
+ public void initialize(UimaContext aContext) throws ResourceInitializationException {
+ super.initialize(aContext);
+
+ if (getContext().getConfigParameterValue("FailDuringInitialization") != null) {
+ throw new ResourceInitializationException(new FileNotFoundException("Simulated Exception"));
+ }
+
+ if (getContext().getConfigParameterValue("ErrorFrequency") != null) {
+ errorFrequency = ((Integer) getContext().getConfigParameterValue("ErrorFrequency"))
+ .intValue();
countDown = errorFrequency;
}
-
-
- if ( getContext().getConfigParameterValue("CpCDelay") != null )
- {
- cpcDelay = ((Integer)getContext().getConfigParameterValue("CpCDelay")).intValue();
- System.out.println("NoOpAnnotator.initialize() Initializing With CpC Delay of " +cpcDelay +" millis");
- }
- if ( getContext().getConfigParameterValue("ProcessDelay") != null )
- {
- processDelay = ((Integer)getContext().getConfigParameterValue("ProcessDelay")).intValue();
- System.out.println("NoOpAnnotator.initialize() Initializing With Process Delay of " +processDelay +" millis");
- }
+ if (getContext().getConfigParameterValue("CpCDelay") != null) {
+ cpcDelay = ((Integer) getContext().getConfigParameterValue("CpCDelay")).intValue();
+ System.out.println("NoOpAnnotator.initialize() Initializing With CpC Delay of " + cpcDelay
+ + " millis");
+ }
+ if (getContext().getConfigParameterValue("ProcessDelay") != null) {
+ processDelay = ((Integer) getContext().getConfigParameterValue("ProcessDelay")).intValue();
+ System.out.println("NoOpAnnotator.initialize() Initializing With Process Delay of "
+ + processDelay + " millis");
+
+ }
if (getContext().getConfigParameterValue("FinalCount") != null) {
finalCount = ((Integer) getContext().getConfigParameterValue("FinalCount")).intValue();
}
- // write log messages
- Logger logger = getContext().getLogger();
- logger.log(Level.CONFIG, "NAnnotator initialized");
- }
-
- public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException
- {
- }
-
- public void collectionProcessComplete() throws AnalysisEngineProcessException
- {
- System.out.println("NoOpAnnotator.collectionProcessComplete() Called -------------------------------------");
-
- if ( cpcDelay > 0 ) {
- try {
- System.out.println("NoOpAnnotator.collectionProcessComplete() Delaying CpC Reply For " +cpcDelay +" millis");
- synchronized(this) {
- this.wait(cpcDelay);
- }
- } catch ( InterruptedException e) {
-
- }
- }
- if (finalCount > 0 && finalCount != counter) {
+ // write log messages
+ Logger logger = getContext().getLogger();
+ logger.log(Level.CONFIG, "NAnnotator initialized");
+ }
+
+ public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException {
+ }
+
+ public void collectionProcessComplete() throws AnalysisEngineProcessException {
+ System.out
+ .println("NoOpAnnotator.collectionProcessComplete() Called -------------------------------------");
+
+ if (cpcDelay > 0) {
+ try {
+ System.out.println("NoOpAnnotator.collectionProcessComplete() Delaying CpC Reply For "
+ + cpcDelay + " millis");
+ synchronized (this) {
+ this.wait(cpcDelay);
+ }
+ } catch (InterruptedException e) {
+
+ }
+ }
+ if (finalCount > 0 && finalCount != counter) {
String msg = "NoOpAnnotator expected " + finalCount + " CASes but was given " + counter;
System.out.println(msg);
throw new AnalysisEngineProcessException(new Exception(msg));
}
counter = 0;
- }
-
- public void process(CAS aCAS) throws AnalysisEngineProcessException
- {
+ }
+
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
++counter;
- try
- {
- if ( processDelay == 0 ) {
- if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
- System.out.println("NoOpAnnotator.process() called for the " + counter + "th time. Hashcode:"+hashCode());
+ try {
+ if (processDelay == 0) {
+ if (UIMAFramework.getLogger().isLoggable(Level.FINE))
+ System.out.println("NoOpAnnotator.process() called for the " + counter
+ + "th time. Hashcode:" + hashCode());
+ } else {
+ // if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
+ System.out.println("NoOpAnnotator.process() called for the " + counter
+ + "th time, delaying Response For:" + processDelay + " millis");
+ synchronized (this) {
+ try {
+ wait(processDelay);
+ } catch (InterruptedException e) {
+ }
+ }
}
- else {
-// if ( UIMAFramework.getLogger().isLoggable(Level.FINE))
- System.out.println("NoOpAnnotator.process() called for the " + counter + "th time, delaying Response For:" +processDelay +" millis");
- synchronized( this )
- {
- try
- {
- wait(processDelay);
- }
- catch( InterruptedException e) {}
- }
- }
// If creating exceptions, reduce interval between them each time.
- if ( errorFrequency > 0 )
- {
- if ( --countDown == 0)
- {
- System.out.println("Generating OutOfBoundsException on " + counter + "th call.");
+ if (errorFrequency > 0) {
+ if (--countDown == 0) {
+ System.out.println("Generating OutOfBoundsException on " + counter + "th call.");
if (errorFrequency > 1) {
--errorFrequency;
}
countDown = errorFrequency;
- throw new IndexOutOfBoundsException();
- }
- }
- }
- catch ( Exception e)
- {
- throw new AnalysisEngineProcessException(e);
- }
- }
+ throw new IndexOutOfBoundsException();
+ }
+ }
+ } catch (Exception e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+ }
}
Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpCC.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpCC.java?rev=810551&r1=810550&r2=810551&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpCC.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/NoOpCC.java Wed Sep 2 15:18:33 2009
@@ -24,11 +24,12 @@
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceProcessException;
-public class NoOpCC extends CasConsumer_ImplBase{
+public class NoOpCC extends CasConsumer_ImplBase {
public void initialize() throws ResourceInitializationException {
-
+
}
+
public void processCas(CAS aCAS) throws ResourceProcessException {
System.out.println("NoOpCC process() called");
}
Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/SimpleAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/SimpleAnnotator.java?rev=810551&r1=810550&r2=810551&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/SimpleAnnotator.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/noop/SimpleAnnotator.java Wed Sep 2 15:18:33 2009
@@ -33,78 +33,73 @@
import org.apache.uima.util.Logger;
public class SimpleAnnotator extends CasAnnotator_ImplBase {
- private long counter = 0;
- int processDelay = 0;
- int finalCount = 0;
-
- public void initialize(UimaContext aContext)
- throws ResourceInitializationException {
- super.initialize(aContext);
-
- if (getContext().getConfigParameterValue("ProcessDelay") != null) {
- processDelay = ((Integer) getContext().getConfigParameterValue(
- "ProcessDelay")).intValue();
- System.out
- .println("SimpleAnnotator.initialize() Initializing With Process Delay of "
- + processDelay + " millis");
- }
-
- if (getContext().getConfigParameterValue("FinalCount") != null) {
- finalCount = ((Integer) getContext().getConfigParameterValue(
- "FinalCount")).intValue();
- }
-
- // write log messages
- Logger logger = getContext().getLogger();
- logger.log(Level.CONFIG, "SimpleAnnotator initialized");
- }
-
- public void typeSystemInit(TypeSystem aTypeSystem)
- throws AnalysisEngineProcessException {
- }
-
- public void collectionProcessComplete()
- throws AnalysisEngineProcessException {
- System.out
- .println("SimpleAnnotator.collectionProcessComplete() Called -------------------------------------");
- if (finalCount > 0 && finalCount != counter) {
- String msg = "SimpleAnnotator expected " + finalCount
- + " CASes but was given " + counter;
- System.out.println(msg);
- throw new AnalysisEngineProcessException(new Exception(msg));
- }
- counter = 0;
- }
-
- public void process(CAS aCAS) throws AnalysisEngineProcessException {
- ++counter;
- if (processDelay == 0) {
- if (UIMAFramework.getLogger().isLoggable(Level.FINE))
- System.out.println("SimpleAnnotator.process() called for the "
- + counter + "th time. Hashcode:" + hashCode());
- } else {
- if (UIMAFramework.getLogger().isLoggable(Level.FINE))
- System.out.println("SimpleAnnotator.process() called for the "
- + counter + "th time, delaying Response For:"
- + processDelay + " millis");
- synchronized (this) {
- try {
- wait(processDelay);
- } catch (InterruptedException e) {
- }
- }
- }
- JCas jcas;
- try {
- jcas = aCAS.getJCas();
- } catch (CASException e) {
- throw new AnalysisEngineProcessException(e);
- }
- SourceDocumentInformation sda = new SourceDocumentInformation(jcas, 0, jcas.getDocumentText().length());
- sda.setOffsetInSource(0);
- sda.addToIndexes();
+ private long counter = 0;
+
+ int processDelay = 0;
+
+ int finalCount = 0;
+
+ public void initialize(UimaContext aContext) throws ResourceInitializationException {
+ super.initialize(aContext);
+
+ if (getContext().getConfigParameterValue("ProcessDelay") != null) {
+ processDelay = ((Integer) getContext().getConfigParameterValue("ProcessDelay")).intValue();
+ System.out.println("SimpleAnnotator.initialize() Initializing With Process Delay of "
+ + processDelay + " millis");
+ }
+
+ if (getContext().getConfigParameterValue("FinalCount") != null) {
+ finalCount = ((Integer) getContext().getConfigParameterValue("FinalCount")).intValue();
+ }
+
+ // write log messages
+ Logger logger = getContext().getLogger();
+ logger.log(Level.CONFIG, "SimpleAnnotator initialized");
+ }
+
+ public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException {
+ }
+
+ public void collectionProcessComplete() throws AnalysisEngineProcessException {
+ System.out
+ .println("SimpleAnnotator.collectionProcessComplete() Called -------------------------------------");
+ if (finalCount > 0 && finalCount != counter) {
+ String msg = "SimpleAnnotator expected " + finalCount + " CASes but was given " + counter;
+ System.out.println(msg);
+ throw new AnalysisEngineProcessException(new Exception(msg));
+ }
+ counter = 0;
+ }
+
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ ++counter;
+ if (processDelay == 0) {
+ if (UIMAFramework.getLogger().isLoggable(Level.FINE))
+ System.out.println("SimpleAnnotator.process() called for the " + counter
+ + "th time. Hashcode:" + hashCode());
+ } else {
+ if (UIMAFramework.getLogger().isLoggable(Level.FINE))
+ System.out.println("SimpleAnnotator.process() called for the " + counter
+ + "th time, delaying Response For:" + processDelay + " millis");
+ synchronized (this) {
+ try {
+ wait(processDelay);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ JCas jcas;
+ try {
+ jcas = aCAS.getJCas();
+ } catch (CASException e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+ SourceDocumentInformation sda = new SourceDocumentInformation(jcas, 0, jcas.getDocumentText()
+ .length());
+ sda.setOffsetInSource(0);
+ sda.addToIndexes();
if (UIMAFramework.getLogger().isLoggable(Level.FINE))
System.out.println("SimpleAnnotator.process() added a SourceDocumentInformation annotation");
- }
+ }
}