You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2013/01/11 00:12:37 UTC
svn commit: r1431721 [10/19] - in /uima/sandbox/uimafit/trunk:
uimafit-examples/src/main/java/org/apache/uima/fit/examples/experiment/pos/
uimafit-examples/src/main/java/org/apache/uima/fit/examples/getstarted/
uimafit-examples/src/main/java/org/apache...
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java Thu Jan 10 23:12:33 2013
@@ -43,85 +43,80 @@ import org.apache.uima.util.CasCreationU
*/
public class JCasIterable implements Iterator<JCas>, Iterable<JCas> {
- private CollectionReader collectionReader;
+ private CollectionReader collectionReader;
- private AnalysisEngine[] analysisEngines;
+ private AnalysisEngine[] analysisEngines;
- private JCas jCas;
+ private JCas jCas;
- /**
- * Iterate over the documents loaded by the CollectionReader. (Uses an JCasAnnotatorAdapter to
- * create the document JCas.)
- *
- * @param aReader
- * The CollectionReader for loading documents.
- * @param aTypeSystemDescription
- * a type system description
- */
- public JCasIterable(final CollectionReader aReader,
- final TypeSystemDescription aTypeSystemDescription) throws UIMAException, IOException {
- this(aReader, AnalysisEngineFactory.createPrimitive(NoOpAnnotator.class,
- aTypeSystemDescription));
- }
-
- /**
- * Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each
- * one before yielding them.
- *
- * @param aReader
- * The CollectionReader for loading documents.
- * @param aEngines
- * The AnalysisEngines for processing documents.
- */
- public JCasIterable(final CollectionReader aReader, final AnalysisEngine... aEngines)
- throws UIMAException, IOException {
- this.collectionReader = aReader;
- this.analysisEngines = aEngines;
- final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
- metaData.add(aReader.getMetaData());
- for (AnalysisEngine engine : aEngines) {
- metaData.add(engine.getMetaData());
- }
- this.jCas = CasCreationUtils.createCas(metaData).getJCas();
- }
-
- public Iterator<JCas> iterator() {
- return this;
- }
-
- public boolean hasNext() {
- try {
- return this.collectionReader.hasNext();
- }
- catch (CollectionException e) {
- throw new IllegalStateException(e);
- }
- catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- public JCas next() {
- this.jCas.reset();
- try {
- this.collectionReader.getNext(this.jCas.getCas());
- for (AnalysisEngine engine : this.analysisEngines) {
- engine.process(this.jCas);
- }
- }
- catch (CollectionException e) {
- throw new IllegalStateException(e);
- }
- catch (IOException e) {
- throw new IllegalStateException(e);
- }
- catch (AnalysisEngineProcessException e) {
- throw new IllegalStateException(e);
- }
- return this.jCas;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
+ /**
+ * Iterate over the documents loaded by the CollectionReader. (Uses an JCasAnnotatorAdapter to
+ * create the document JCas.)
+ *
+ * @param aReader
+ * The CollectionReader for loading documents.
+ * @param aTypeSystemDescription
+ * a type system description
+ */
+ public JCasIterable(final CollectionReader aReader,
+ final TypeSystemDescription aTypeSystemDescription) throws UIMAException, IOException {
+ this(aReader, AnalysisEngineFactory
+ .createPrimitive(NoOpAnnotator.class, aTypeSystemDescription));
+ }
+
+ /**
+ * Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each
+ * one before yielding them.
+ *
+ * @param aReader
+ * The CollectionReader for loading documents.
+ * @param aEngines
+ * The AnalysisEngines for processing documents.
+ */
+ public JCasIterable(final CollectionReader aReader, final AnalysisEngine... aEngines)
+ throws UIMAException, IOException {
+ this.collectionReader = aReader;
+ this.analysisEngines = aEngines;
+ final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
+ metaData.add(aReader.getMetaData());
+ for (AnalysisEngine engine : aEngines) {
+ metaData.add(engine.getMetaData());
+ }
+ this.jCas = CasCreationUtils.createCas(metaData).getJCas();
+ }
+
+ public Iterator<JCas> iterator() {
+ return this;
+ }
+
+ public boolean hasNext() {
+ try {
+ return this.collectionReader.hasNext();
+ } catch (CollectionException e) {
+ throw new IllegalStateException(e);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public JCas next() {
+ this.jCas.reset();
+ try {
+ this.collectionReader.getNext(this.jCas.getCas());
+ for (AnalysisEngine engine : this.analysisEngines) {
+ engine.process(this.jCas);
+ }
+ } catch (CollectionException e) {
+ throw new IllegalStateException(e);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ } catch (AnalysisEngineProcessException e) {
+ throw new IllegalStateException(e);
+ }
+ return this.jCas;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java Thu Jan 10 23:12:33 2013
@@ -44,218 +44,212 @@ import org.apache.uima.util.CasCreationU
*
*/
public final class SimplePipeline {
- private SimplePipeline() {
- // This class is not meant to be instantiated
- }
-
- /**
- * Run the CollectionReader and AnalysisEngines as a pipeline. After processing all CASes
- * provided by the reader, the method calls {@link AnalysisEngine#collectionProcessComplete()
- * collectionProcessComplete()} on the engines and {@link Resource#destroy() destroy()} on all
- * engines.
- *
- * @param reader
- * The CollectionReader that loads the documents into the CAS.
- * @param descs
- * Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a
- * mix of primitive and aggregate engines, then please create the AnalysisEngines
- * yourself and call the other runPipeline method.
- */
- public static void runPipeline(final CollectionReader reader,
- final AnalysisEngineDescription... descs) throws UIMAException, IOException {
- // Create AAE
- final AnalysisEngineDescription aaeDesc = createAggregateDescription(descs);
-
- // Instantiate AAE
- final AnalysisEngine aae = createAggregate(aaeDesc);
-
- // Create CAS from merged metadata
- final CAS cas = CasCreationUtils.createCas(asList(reader.getMetaData(), aae.getMetaData()));
-
- try {
- // Process
- while (reader.hasNext()) {
- reader.getNext(cas);
- aae.process(cas);
- cas.reset();
- }
-
- // Signal end of processing
- aae.collectionProcessComplete();
- }
- finally {
- // Destroy
- aae.destroy();
- }
- }
-
- /**
- * Run the CollectionReader and AnalysisEngines as a pipeline. After processing all CASes
- * provided by the reader, the method calls {@link AnalysisEngine#collectionProcessComplete()
- * collectionProcessComplete()} on the engines, {@link CollectionReader#close() close()} on the
- * reader and {@link Resource#destroy() destroy()} on the reader and all engines.
- *
- * @param readerDesc
- * The CollectionReader that loads the documents into the CAS.
- * @param descs
- * Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a
- * mix of primitive and aggregate engines, then please create the AnalysisEngines
- * yourself and call the other runPipeline method.
- */
- public static void runPipeline(final CollectionReaderDescription readerDesc,
- final AnalysisEngineDescription... descs) throws UIMAException, IOException {
- // Create the components
- final CollectionReader reader = createCollectionReader(readerDesc);
-
- try {
- // Run the pipeline
- runPipeline(reader, descs);
- }
- finally {
- close(reader);
- destroy(reader);
- }
- }
-
- /**
- * Provides a simple way to run a pipeline for a given collection reader and sequence of
- * analysis engines. After processing all CASes provided by the reader, the method calls
- * {@link AnalysisEngine#collectionProcessComplete() collectionProcessComplete()} on the
- * engines.
- *
- * @param reader
- * a collection reader
- * @param engines
- * a sequence of analysis engines
- */
- public static void runPipeline(final CollectionReader reader, final AnalysisEngine... engines)
- throws UIMAException, IOException {
- final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
- metaData.add(reader.getMetaData());
- for (AnalysisEngine engine : engines) {
- metaData.add(engine.getMetaData());
- }
-
- final CAS cas = CasCreationUtils.createCas(metaData);
- while (reader.hasNext()) {
- reader.getNext(cas);
- runPipeline(cas, engines);
- cas.reset();
- }
-
- collectionProcessComplete(engines);
- }
-
- /**
- * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. The result of
- * the analysis can be read from the JCas.
- *
- * @param aCas
- * the CAS to process
- * @param aDescs
- * a sequence of analysis engines to run on the jCas
- */
- public static void runPipeline(final CAS aCas, final AnalysisEngineDescription... aDescs)
- throws UIMAException, IOException {
- // Create aggregate AE
- final AnalysisEngineDescription aaeDesc = createAggregateDescription(aDescs);
-
- // Instantiate
- final AnalysisEngine aae = createAggregate(aaeDesc);
- try {
- // Process
- aae.process(aCas);
-
- // Signal end of processing
- aae.collectionProcessComplete();
- }
- finally {
- // Destroy
- aae.destroy();
- }
- }
-
- /**
- * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. The result of
- * the analysis can be read from the JCas.
- *
- * @param jCas
- * the jCas to process
- * @param descs
- * a sequence of analysis engines to run on the jCas
- */
- public static void runPipeline(final JCas jCas, final AnalysisEngineDescription... descs)
- throws UIMAException, IOException {
- runPipeline(jCas.getCas(), descs);
- }
-
- /**
- * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. This method
- * does not {@link AnalysisEngine#destroy() destroy} the engines or send them other events like
- * {@link AnalysisEngine#collectionProcessComplete()}. This is left to the caller.
- *
- * @param jCas
- * the jCas to process
- * @param engines
- * a sequence of analysis engines to run on the jCas
- */
- public static void runPipeline(final JCas jCas, final AnalysisEngine... engines)
- throws UIMAException, IOException {
- for (AnalysisEngine engine : engines) {
- engine.process(jCas);
- }
- }
-
- /**
- * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link CAS}. This method
- * does not {@link AnalysisEngine#destroy() destroy} the engines or send them other events like
- * {@link AnalysisEngine#collectionProcessComplete()}. This is left to the caller.
- *
- * @param cas
- * the CAS to process
- * @param engines
- * a sequence of analysis engines to run on the jCas
- */
- public static void runPipeline(final CAS cas, final AnalysisEngine... engines)
- throws UIMAException, IOException {
- for (AnalysisEngine engine : engines) {
- engine.process(cas);
- }
- }
-
- /**
- * Notify a set of {@link AnalysisEngine analysis engines} that the collection process is complete.
- */
- private static void collectionProcessComplete(final AnalysisEngine... engines)
- throws AnalysisEngineProcessException {
- for (AnalysisEngine e : engines) {
- e.collectionProcessComplete();
- }
- }
-
- /**
- * Destroy a set of {@link Resource resources}.
- */
- private static void destroy(final Resource... resources)
- {
- for (Resource r : resources) {
- if (r != null) {
- r.destroy();
- }
- }
- }
-
- private static void close(final BaseCollectionReader aReader)
- {
- if (aReader == null) {
- return;
- }
-
- try {
- aReader.close();
- }
- catch (IOException e) {
- // Ignore.
- }
- }
+ private SimplePipeline() {
+ // This class is not meant to be instantiated
+ }
+
+ /**
+ * Run the CollectionReader and AnalysisEngines as a pipeline. After processing all CASes provided
+ * by the reader, the method calls {@link AnalysisEngine#collectionProcessComplete()
+ * collectionProcessComplete()} on the engines and {@link Resource#destroy() destroy()} on all
+ * engines.
+ *
+ * @param reader
+ * The CollectionReader that loads the documents into the CAS.
+ * @param descs
+ * Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a mix
+ * of primitive and aggregate engines, then please create the AnalysisEngines yourself
+ * and call the other runPipeline method.
+ */
+ public static void runPipeline(final CollectionReader reader,
+ final AnalysisEngineDescription... descs) throws UIMAException, IOException {
+ // Create AAE
+ final AnalysisEngineDescription aaeDesc = createAggregateDescription(descs);
+
+ // Instantiate AAE
+ final AnalysisEngine aae = createAggregate(aaeDesc);
+
+ // Create CAS from merged metadata
+ final CAS cas = CasCreationUtils.createCas(asList(reader.getMetaData(), aae.getMetaData()));
+
+ try {
+ // Process
+ while (reader.hasNext()) {
+ reader.getNext(cas);
+ aae.process(cas);
+ cas.reset();
+ }
+
+ // Signal end of processing
+ aae.collectionProcessComplete();
+ } finally {
+ // Destroy
+ aae.destroy();
+ }
+ }
+
+ /**
+ * Run the CollectionReader and AnalysisEngines as a pipeline. After processing all CASes provided
+ * by the reader, the method calls {@link AnalysisEngine#collectionProcessComplete()
+ * collectionProcessComplete()} on the engines, {@link CollectionReader#close() close()} on the
+ * reader and {@link Resource#destroy() destroy()} on the reader and all engines.
+ *
+ * @param readerDesc
+ * The CollectionReader that loads the documents into the CAS.
+ * @param descs
+ * Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a mix
+ * of primitive and aggregate engines, then please create the AnalysisEngines yourself
+ * and call the other runPipeline method.
+ */
+ public static void runPipeline(final CollectionReaderDescription readerDesc,
+ final AnalysisEngineDescription... descs) throws UIMAException, IOException {
+ // Create the components
+ final CollectionReader reader = createCollectionReader(readerDesc);
+
+ try {
+ // Run the pipeline
+ runPipeline(reader, descs);
+ } finally {
+ close(reader);
+ destroy(reader);
+ }
+ }
+
+ /**
+ * Provides a simple way to run a pipeline for a given collection reader and sequence of analysis
+ * engines. After processing all CASes provided by the reader, the method calls
+ * {@link AnalysisEngine#collectionProcessComplete() collectionProcessComplete()} on the engines.
+ *
+ * @param reader
+ * a collection reader
+ * @param engines
+ * a sequence of analysis engines
+ */
+ public static void runPipeline(final CollectionReader reader, final AnalysisEngine... engines)
+ throws UIMAException, IOException {
+ final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
+ metaData.add(reader.getMetaData());
+ for (AnalysisEngine engine : engines) {
+ metaData.add(engine.getMetaData());
+ }
+
+ final CAS cas = CasCreationUtils.createCas(metaData);
+ while (reader.hasNext()) {
+ reader.getNext(cas);
+ runPipeline(cas, engines);
+ cas.reset();
+ }
+
+ collectionProcessComplete(engines);
+ }
+
+ /**
+ * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. The result of
+ * the analysis can be read from the JCas.
+ *
+ * @param aCas
+ * the CAS to process
+ * @param aDescs
+ * a sequence of analysis engines to run on the jCas
+ */
+ public static void runPipeline(final CAS aCas, final AnalysisEngineDescription... aDescs)
+ throws UIMAException, IOException {
+ // Create aggregate AE
+ final AnalysisEngineDescription aaeDesc = createAggregateDescription(aDescs);
+
+ // Instantiate
+ final AnalysisEngine aae = createAggregate(aaeDesc);
+ try {
+ // Process
+ aae.process(aCas);
+
+ // Signal end of processing
+ aae.collectionProcessComplete();
+ } finally {
+ // Destroy
+ aae.destroy();
+ }
+ }
+
+ /**
+ * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. The result of
+ * the analysis can be read from the JCas.
+ *
+ * @param jCas
+ * the jCas to process
+ * @param descs
+ * a sequence of analysis engines to run on the jCas
+ */
+ public static void runPipeline(final JCas jCas, final AnalysisEngineDescription... descs)
+ throws UIMAException, IOException {
+ runPipeline(jCas.getCas(), descs);
+ }
+
+ /**
+ * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link JCas}. This method does
+ * not {@link AnalysisEngine#destroy() destroy} the engines or send them other events like
+ * {@link AnalysisEngine#collectionProcessComplete()}. This is left to the caller.
+ *
+ * @param jCas
+ * the jCas to process
+ * @param engines
+ * a sequence of analysis engines to run on the jCas
+ */
+ public static void runPipeline(final JCas jCas, final AnalysisEngine... engines)
+ throws UIMAException, IOException {
+ for (AnalysisEngine engine : engines) {
+ engine.process(jCas);
+ }
+ }
+
+ /**
+ * Run a sequence of {@link AnalysisEngine analysis engines} over a {@link CAS}. This method does
+ * not {@link AnalysisEngine#destroy() destroy} the engines or send them other events like
+ * {@link AnalysisEngine#collectionProcessComplete()}. This is left to the caller.
+ *
+ * @param cas
+ * the CAS to process
+ * @param engines
+ * a sequence of analysis engines to run on the jCas
+ */
+ public static void runPipeline(final CAS cas, final AnalysisEngine... engines)
+ throws UIMAException, IOException {
+ for (AnalysisEngine engine : engines) {
+ engine.process(cas);
+ }
+ }
+
+ /**
+ * Notify a set of {@link AnalysisEngine analysis engines} that the collection process is
+ * complete.
+ */
+ private static void collectionProcessComplete(final AnalysisEngine... engines)
+ throws AnalysisEngineProcessException {
+ for (AnalysisEngine e : engines) {
+ e.collectionProcessComplete();
+ }
+ }
+
+ /**
+ * Destroy a set of {@link Resource resources}.
+ */
+ private static void destroy(final Resource... resources) {
+ for (Resource r : resources) {
+ if (r != null) {
+ r.destroy();
+ }
+ }
+ }
+
+ private static void close(final BaseCollectionReader aReader) {
+ if (aReader == null) {
+ return;
+ }
+
+ try {
+ aReader.close();
+ } catch (IOException e) {
+ // Ignore.
+ }
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/package-info.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/package-info.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/package-info.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/pipeline/package-info.java Thu Jan 10 23:12:33 2013
@@ -20,3 +20,4 @@
* Executing UIMA pipelines.
*/
package org.apache.uima.fit.pipeline;
+
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/GetAsTextStringEditor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/GetAsTextStringEditor.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/GetAsTextStringEditor.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/GetAsTextStringEditor.java Thu Jan 10 23:12:33 2013
@@ -25,55 +25,52 @@ import org.springframework.beans.Propert
import org.springframework.beans.PropertyEditorRegistrySupport;
/**
- * Custom property editor that tries to look convert and value to a string by checking if there is
- * a registered property editor for the source value.
+ * Custom property editor that tries to look convert and value to a string by checking if there is a
+ * registered property editor for the source value.
*
*/
public class GetAsTextStringEditor extends PropertyEditorSupport {
- private final PropertyEditorRegistry editorRegistry;
- private final PropertyEditorRegistrySupport editorRegistrySupport;
-
- public GetAsTextStringEditor(final PropertyEditorRegistry aEditorRegistry) {
- editorRegistry = aEditorRegistry;
- if (aEditorRegistry instanceof PropertyEditorRegistrySupport) {
- editorRegistrySupport = (PropertyEditorRegistrySupport) aEditorRegistry;
- }
- else {
- editorRegistrySupport = new PropertyEditorRegistrySupport();
- }
- }
-
- @Override
- public void setValue(Object value) {
- if (value == null || value instanceof String) {
- super.setValue(value);
- }
- else {
- PropertyEditor editor = editorRegistry.findCustomEditor(value.getClass(), null);
- if (editor == null) {
- editor = editorRegistrySupport.getDefaultEditor(value.getClass());
- }
- if (editor != null) {
- editor.setValue(value);
- super.setValue(editor.getAsText());
- }
- else if (Enum.class.isAssignableFrom(value.getClass())) {
- super.setValue(String.valueOf(value));
- }
- else {
- throw new IllegalArgumentException("Unable to convert " + value.getClass()
- + " to String. No PropertyEditor found.");
- }
- }
- }
-
- @Override
- public void setAsText(String text) {
- setValue(text);
- }
-
- @Override
- public String getAsText() {
- return (String) getValue();
- }
+ private final PropertyEditorRegistry editorRegistry;
+
+ private final PropertyEditorRegistrySupport editorRegistrySupport;
+
+ public GetAsTextStringEditor(final PropertyEditorRegistry aEditorRegistry) {
+ editorRegistry = aEditorRegistry;
+ if (aEditorRegistry instanceof PropertyEditorRegistrySupport) {
+ editorRegistrySupport = (PropertyEditorRegistrySupport) aEditorRegistry;
+ } else {
+ editorRegistrySupport = new PropertyEditorRegistrySupport();
+ }
+ }
+
+ @Override
+ public void setValue(Object value) {
+ if (value == null || value instanceof String) {
+ super.setValue(value);
+ } else {
+ PropertyEditor editor = editorRegistry.findCustomEditor(value.getClass(), null);
+ if (editor == null) {
+ editor = editorRegistrySupport.getDefaultEditor(value.getClass());
+ }
+ if (editor != null) {
+ editor.setValue(value);
+ super.setValue(editor.getAsText());
+ } else if (Enum.class.isAssignableFrom(value.getClass())) {
+ super.setValue(String.valueOf(value));
+ } else {
+ throw new IllegalArgumentException("Unable to convert " + value.getClass()
+ + " to String. No PropertyEditor found.");
+ }
+ }
+ }
+
+ @Override
+ public void setAsText(String text) {
+ setValue(text);
+ }
+
+ @Override
+ public String getAsText() {
+ return (String) getValue();
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/LocaleEditor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/LocaleEditor.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/LocaleEditor.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/LocaleEditor.java Thu Jan 10 23:12:33 2013
@@ -25,28 +25,26 @@ import org.apache.uima.fit.util.LocaleUt
/**
* Custom property editor for {@link Locale} that supports "-" as separator and sets the default
- * locale when {@code null} or {@code ""} is passed. This is used to be backwards-compatible with
+ * locale when {@code null} or {@code ""} is passed. This is used to be backwards-compatible with
* previous uimaFIT behavior.
*
*/
public class LocaleEditor extends PropertyEditorSupport {
- @Override
- public void setAsText(String text) {
- if (text == null) {
- setValue(Locale.getDefault());
- }
- else if (text.length() == 0) {
- setValue(Locale.getDefault());
- }
- else {
- setValue(LocaleUtil.getLocale(text));
- }
- }
+ @Override
+ public void setAsText(String text) {
+ if (text == null) {
+ setValue(Locale.getDefault());
+ } else if (text.length() == 0) {
+ setValue(Locale.getDefault());
+ } else {
+ setValue(LocaleUtil.getLocale(text));
+ }
+ }
- @Override
- public String getAsText() {
- Object value = getValue();
- return (value != null ? value.toString() : "");
- }
+ @Override
+ public String getAsText() {
+ Object value = getValue();
+ return (value != null ? value.toString() : "");
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/PropertyEditorUtil.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/PropertyEditorUtil.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/PropertyEditorUtil.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/propertyeditors/PropertyEditorUtil.java Thu Jan 10 23:12:33 2013
@@ -28,14 +28,13 @@ import org.springframework.beans.propert
*/
public final class PropertyEditorUtil {
- private PropertyEditorUtil() {
- // Utility class
- }
-
- public static void registerUimaFITEditors(PropertyEditorRegistry aRegistry)
- {
- aRegistry.registerCustomEditor(Locale.class, new LocaleEditor());
- aRegistry.registerCustomEditor(String.class, new GetAsTextStringEditor(aRegistry));
- aRegistry.registerCustomEditor(LinkedList.class, new CustomCollectionEditor(LinkedList.class));
- }
+ private PropertyEditorUtil() {
+ // Utility class
+ }
+
+ public static void registerUimaFITEditors(PropertyEditorRegistry aRegistry) {
+ aRegistry.registerCustomEditor(Locale.class, new LocaleEditor());
+ aRegistry.registerCustomEditor(String.class, new GetAsTextStringEditor(aRegistry));
+ aRegistry.registerCustomEditor(LinkedList.class, new CustomCollectionEditor(LinkedList.class));
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java Thu Jan 10 23:12:33 2013
@@ -34,222 +34,222 @@ import org.apache.uima.jcas.tcas.Annotat
*
*
* @param <TOKEN_TYPE>
- * the type system token type (e.g. org.uimafit.examples.type.Token)
+ * the type system token type (e.g. org.uimafit.examples.type.Token)
* @param <SENTENCE_TYPE>
- * the type system sentence type (e.g. org.uimafit.examples.type.Sentence)
+ * the type system sentence type (e.g. org.uimafit.examples.type.Sentence)
*/
public class TokenBuilder<TOKEN_TYPE extends Annotation, SENTENCE_TYPE extends Annotation> {
- private Class<TOKEN_TYPE> tokenClass;
- private Class<SENTENCE_TYPE> sentenceClass;
- private String posFeatureName;
- private String stemFeatureName;
-
- /**
- * Calls {@link TokenBuilder#TokenBuilder(Class, Class, String, String)} with the last two
- * arguments as null.
- */
- public TokenBuilder(Class<TOKEN_TYPE> tokenClass, Class<SENTENCE_TYPE> sentenceClass) {
- this(tokenClass, sentenceClass, null, null);
- }
-
- /**
- * Instantiates a TokenBuilder with the type system information that the builder needs to build
- * tokens.
- *
- * @param tokenClass
- * the class of your token type from your type system (e.g.
- * org.apache.uima.fit.type.Token.class)
- * @param sentenceClass
- * the class of your sentence type from your type system (e.g.
- * org.apache.uima.fit.type.Sentence.class)
- * @param posFeatureName
- * the feature name for the part-of-speech tag for your token type. This assumes that
- * there is a single string feature for which to put your pos tag. null is an ok
- * value.
- * @param stemFeatureName
- * the feature name for the stem for your token type. This assumes that there is a
- * single string feature for which to put your stem. null is an ok value.
- */
- public TokenBuilder(final Class<TOKEN_TYPE> tokenClass, final Class<SENTENCE_TYPE> sentenceClass,
- String posFeatureName, String stemFeatureName) {
- this.tokenClass = tokenClass;
- this.sentenceClass = sentenceClass;
- setPosFeatureName(posFeatureName);
- setStemFeatureName(stemFeatureName);
- }
-
- /**
- * Instantiates a TokenBuilder with the type system information that the builder needs to build
- * tokens.
- *
- * @param <T>
- * the type system token type (e.g. org.uimafit.examples.type.Token)
- * @param <S>
- * the type system sentence type (e.g. org.uimafit.examples.type.Sentence)
- * @param tokenClass
- * the class of your token type from your type system (e.g.
- * org.apache.uima.fit.type.Token.class)
- * @param sentenceClass
- * the class of your sentence type from your type system (e.g.
- * org.apache.uima.fit.type.Sentence.class)
- * @return the builder.
- */
- public static <T extends Annotation, S extends Annotation> TokenBuilder<T, S> create(
- Class<T> tokenClass, Class<S> sentenceClass) {
- return new TokenBuilder<T, S>(tokenClass, sentenceClass);
- }
-
- /**
- * Set the feature name for the part-of-speech tag for your token type. This assumes that there
- * is a single string feature for which to put your pos tag. null is an ok value.
- *
- * @param posFeatureName
- * the part-of-speech feature name.
- */
- public void setPosFeatureName(String posFeatureName) {
- this.posFeatureName = posFeatureName;
- }
-
- /**
- * Set the feature name for the stem for your token type. This assumes that there is a single
- * string feature for which to put your stem. null is an ok value.
- *
- * @param stemFeatureName
- * the stem feature name.
- */
- public void setStemFeatureName(String stemFeatureName) {
- this.stemFeatureName = stemFeatureName;
- }
-
- /**
- * Builds white-space delimited tokens from the input text.
- *
- * @param jCas
- * the JCas to add the tokens to
- * @param text
- * the JCas will have its document text set to this.
- */
- public void buildTokens(JCas jCas, String text) throws UIMAException {
- if (text == null) {
- throw new IllegalArgumentException("text may not be null.");
- }
- buildTokens(jCas, text, text, null, null);
- }
-
- /**
- * see {@link #buildTokens(JCas, String, String, String, String)}
- */
- public void buildTokens(JCas jCas, String text, String tokensString) throws UIMAException {
- if (tokensString == null) {
- throw new IllegalArgumentException("tokensText may not be null.");
- }
- buildTokens(jCas, text, tokensString, null, null);
- }
-
- /**
- * see {@link #buildTokens(JCas, String, String, String, String)}
- */
- public void buildTokens(JCas jCas, String text, String tokensString, String posTagsString)
- throws UIMAException {
- buildTokens(jCas, text, tokensString, posTagsString, null);
- }
-
- /**
- * Build tokens for the given text, tokens, part-of-speech tags, and word stems.
- *
- * @param aJCas
- * the JCas to add the Token annotations to
- * @param aText
- * this method sets the text of the JCas to this method. Therefore, it is generally a
- * good idea to call JCas.reset() before calling this method when passing in the
- * default view.
- * @param aTokensString
- * the tokensString must have the same non-white space characters as the text. The
- * tokensString is used to identify token boundaries using white space - i.e. the
- * only difference between the 'text' parameter and the 'tokensString' parameter is
- * that the latter may have more whitespace characters. For example, if the text is
- * "She ran." then the tokensString might be "She ran ."
- * @param aPosTagsString
- * the posTagsString should be a space delimited string of part-of-speech tags - one
- * for each token
- * @param aStemsString
- * the stemsString should be a space delimitied string of stems - one for each token
- */
- public void buildTokens(JCas aJCas, String aText, String aTokensString, String aPosTagsString,
- String aStemsString) throws UIMAException {
- aJCas.setDocumentText(aText);
-
- if (aPosTagsString != null && posFeatureName == null) {
- throw new IllegalArgumentException("posTagsString must be null if TokenBuilder is "
- + "not initialized with a feature name corresponding to the part-of-speech "
- + "feature of the token type (assuming your token type has such a feature).");
- }
-
- if (aStemsString != null && stemFeatureName == null) {
- throw new IllegalArgumentException(
- "stemsString must be null if TokenBuilder is not "
- + "initialized with a feature name corresponding to the part-of-speech feature "
- + "of the token type (assuming your token type has such a feature).");
- }
-
- Feature posFeature = null;
- if (posFeatureName != null) {
- // String fullPosFeatureName = tokenClass.getClass().getName()+":"+posFeatureName;
- // posFeature = jCas.getTypeSystem().getFeatureByFullName(fullPosFeatureName);
- posFeature = aJCas.getTypeSystem().getType(tokenClass.getName())
- .getFeatureByBaseName(posFeatureName);
- }
- Feature stemFeature = null;
- if (stemFeatureName != null) {
- stemFeature = aJCas.getTypeSystem().getType(tokenClass.getName())
- .getFeatureByBaseName(stemFeatureName);
- }
-
- String tokensString = aTokensString.replaceAll("\\s*\n\\s*", "\n");
- String[] sentenceStrings = tokensString.split("\n");
- String[] posTags = aPosTagsString != null ? aPosTagsString.split("\\s+") : null;
- String[] stems = aStemsString != null ? aStemsString.split("\\s+") : null;
-
- int offset = 0;
- int tokenIndex = 0;
-
- for (String sentenceString : sentenceStrings) {
- String[] tokenStrings = sentenceString.trim().split("\\s+");
- List<Annotation> tokenAnnotations = new ArrayList<Annotation>();
- for (String tokenString : tokenStrings) {
- // move the offset up to the beginning of the token
- while (!aText.startsWith(tokenString, offset)) {
- offset++;
- if (offset > aText.length()) {
- throw new IllegalArgumentException(String.format(
- "unable to find string %s", tokenString));
- }
- }
-
- // add the Token
- int start = offset;
- offset = offset + tokenString.length();
- Annotation token = AnnotationFactory.createAnnotation(aJCas, start, offset,
- tokenClass);
- tokenAnnotations.add(token);
-
- // set the stem and part of speech if present
- if (posTags != null) {
- token.setStringValue(posFeature, posTags[tokenIndex]);
- }
- if (stems != null) {
- token.setStringValue(stemFeature, stems[tokenIndex]);
- }
- tokenIndex++;
- }
- if (tokenAnnotations.size() > 0) {
- int begin = tokenAnnotations.get(0).getBegin();
- int end = tokenAnnotations.get(tokenAnnotations.size() - 1).getEnd();
- AnnotationFactory.createAnnotation(aJCas, begin, end, sentenceClass);
- }
- }
+ private Class<TOKEN_TYPE> tokenClass;
- }
+ private Class<SENTENCE_TYPE> sentenceClass;
+
+ private String posFeatureName;
+
+ private String stemFeatureName;
+
+ /**
+ * Calls {@link TokenBuilder#TokenBuilder(Class, Class, String, String)} with the last two
+ * arguments as null.
+ */
+ public TokenBuilder(Class<TOKEN_TYPE> tokenClass, Class<SENTENCE_TYPE> sentenceClass) {
+ this(tokenClass, sentenceClass, null, null);
+ }
+
+ /**
+ * Instantiates a TokenBuilder with the type system information that the builder needs to build
+ * tokens.
+ *
+ * @param tokenClass
+ * the class of your token type from your type system (e.g.
+ * org.apache.uima.fit.type.Token.class)
+ * @param sentenceClass
+ * the class of your sentence type from your type system (e.g.
+ * org.apache.uima.fit.type.Sentence.class)
+ * @param posFeatureName
+ * the feature name for the part-of-speech tag for your token type. This assumes that
+ * there is a single string feature for which to put your pos tag. null is an ok value.
+ * @param stemFeatureName
+ * the feature name for the stem for your token type. This assumes that there is a single
+ * string feature for which to put your stem. null is an ok value.
+ */
+ public TokenBuilder(final Class<TOKEN_TYPE> tokenClass, final Class<SENTENCE_TYPE> sentenceClass,
+ String posFeatureName, String stemFeatureName) {
+ this.tokenClass = tokenClass;
+ this.sentenceClass = sentenceClass;
+ setPosFeatureName(posFeatureName);
+ setStemFeatureName(stemFeatureName);
+ }
+
+ /**
+ * Instantiates a TokenBuilder with the type system information that the builder needs to build
+ * tokens.
+ *
+ * @param <T>
+ * the type system token type (e.g. org.uimafit.examples.type.Token)
+ * @param <S>
+ * the type system sentence type (e.g. org.uimafit.examples.type.Sentence)
+ * @param tokenClass
+ * the class of your token type from your type system (e.g.
+ * org.apache.uima.fit.type.Token.class)
+ * @param sentenceClass
+ * the class of your sentence type from your type system (e.g.
+ * org.apache.uima.fit.type.Sentence.class)
+ * @return the builder.
+ */
+ public static <T extends Annotation, S extends Annotation> TokenBuilder<T, S> create(
+ Class<T> tokenClass, Class<S> sentenceClass) {
+ return new TokenBuilder<T, S>(tokenClass, sentenceClass);
+ }
+
+ /**
+ * Set the feature name for the part-of-speech tag for your token type. This assumes that there is
+ * a single string feature for which to put your pos tag. null is an ok value.
+ *
+ * @param posFeatureName
+ * the part-of-speech feature name.
+ */
+ public void setPosFeatureName(String posFeatureName) {
+ this.posFeatureName = posFeatureName;
+ }
+
+ /**
+ * Set the feature name for the stem for your token type. This assumes that there is a single
+ * string feature for which to put your stem. null is an ok value.
+ *
+ * @param stemFeatureName
+ * the stem feature name.
+ */
+ public void setStemFeatureName(String stemFeatureName) {
+ this.stemFeatureName = stemFeatureName;
+ }
+
+ /**
+ * Builds white-space delimited tokens from the input text.
+ *
+ * @param jCas
+ * the JCas to add the tokens to
+ * @param text
+ * the JCas will have its document text set to this.
+ */
+ public void buildTokens(JCas jCas, String text) throws UIMAException {
+ if (text == null) {
+ throw new IllegalArgumentException("text may not be null.");
+ }
+ buildTokens(jCas, text, text, null, null);
+ }
+
+ /**
+ * see {@link #buildTokens(JCas, String, String, String, String)}
+ */
+ public void buildTokens(JCas jCas, String text, String tokensString) throws UIMAException {
+ if (tokensString == null) {
+ throw new IllegalArgumentException("tokensText may not be null.");
+ }
+ buildTokens(jCas, text, tokensString, null, null);
+ }
+
+ /**
+ * see {@link #buildTokens(JCas, String, String, String, String)}
+ */
+ public void buildTokens(JCas jCas, String text, String tokensString, String posTagsString)
+ throws UIMAException {
+ buildTokens(jCas, text, tokensString, posTagsString, null);
+ }
+
+ /**
+ * Build tokens for the given text, tokens, part-of-speech tags, and word stems.
+ *
+ * @param aJCas
+ * the JCas to add the Token annotations to
+ * @param aText
+ * this method sets the text of the JCas to this method. Therefore, it is generally a
+ * good idea to call JCas.reset() before calling this method when passing in the default
+ * view.
+ * @param aTokensString
+ * the tokensString must have the same non-white space characters as the text. The
+ * tokensString is used to identify token boundaries using white space - i.e. the only
+ * difference between the 'text' parameter and the 'tokensString' parameter is that the
+ * latter may have more whitespace characters. For example, if the text is "She ran."
+ * then the tokensString might be "She ran ."
+ * @param aPosTagsString
+ * the posTagsString should be a space delimited string of part-of-speech tags - one for
+ * each token
+ * @param aStemsString
+ * the stemsString should be a space delimitied string of stems - one for each token
+ */
+ public void buildTokens(JCas aJCas, String aText, String aTokensString, String aPosTagsString,
+ String aStemsString) throws UIMAException {
+ aJCas.setDocumentText(aText);
+
+ if (aPosTagsString != null && posFeatureName == null) {
+ throw new IllegalArgumentException("posTagsString must be null if TokenBuilder is "
+ + "not initialized with a feature name corresponding to the part-of-speech "
+ + "feature of the token type (assuming your token type has such a feature).");
+ }
+
+ if (aStemsString != null && stemFeatureName == null) {
+ throw new IllegalArgumentException("stemsString must be null if TokenBuilder is not "
+ + "initialized with a feature name corresponding to the part-of-speech feature "
+ + "of the token type (assuming your token type has such a feature).");
+ }
+
+ Feature posFeature = null;
+ if (posFeatureName != null) {
+ // String fullPosFeatureName = tokenClass.getClass().getName()+":"+posFeatureName;
+ // posFeature = jCas.getTypeSystem().getFeatureByFullName(fullPosFeatureName);
+ posFeature = aJCas.getTypeSystem().getType(tokenClass.getName())
+ .getFeatureByBaseName(posFeatureName);
+ }
+ Feature stemFeature = null;
+ if (stemFeatureName != null) {
+ stemFeature = aJCas.getTypeSystem().getType(tokenClass.getName())
+ .getFeatureByBaseName(stemFeatureName);
+ }
+
+ String tokensString = aTokensString.replaceAll("\\s*\n\\s*", "\n");
+ String[] sentenceStrings = tokensString.split("\n");
+ String[] posTags = aPosTagsString != null ? aPosTagsString.split("\\s+") : null;
+ String[] stems = aStemsString != null ? aStemsString.split("\\s+") : null;
+
+ int offset = 0;
+ int tokenIndex = 0;
+
+ for (String sentenceString : sentenceStrings) {
+ String[] tokenStrings = sentenceString.trim().split("\\s+");
+ List<Annotation> tokenAnnotations = new ArrayList<Annotation>();
+ for (String tokenString : tokenStrings) {
+ // move the offset up to the beginning of the token
+ while (!aText.startsWith(tokenString, offset)) {
+ offset++;
+ if (offset > aText.length()) {
+ throw new IllegalArgumentException(String.format("unable to find string %s",
+ tokenString));
+ }
+ }
+
+ // add the Token
+ int start = offset;
+ offset = offset + tokenString.length();
+ Annotation token = AnnotationFactory.createAnnotation(aJCas, start, offset, tokenClass);
+ tokenAnnotations.add(token);
+
+ // set the stem and part of speech if present
+ if (posTags != null) {
+ token.setStringValue(posFeature, posTags[tokenIndex]);
+ }
+ if (stems != null) {
+ token.setStringValue(stemFeature, stems[tokenIndex]);
+ }
+ tokenIndex++;
+ }
+ if (tokenAnnotations.size() > 0) {
+ int begin = tokenAnnotations.get(0).getBegin();
+ int end = tokenAnnotations.get(tokenAnnotations.size() - 1).getEnd();
+ AnnotationFactory.createAnnotation(aJCas, begin, end, sentenceClass);
+ }
+ }
+
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/DisableLogging.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/DisableLogging.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/DisableLogging.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/DisableLogging.java Thu Jan 10 23:12:33 2013
@@ -28,32 +28,32 @@ import java.util.logging.Logger;
*
*/
public final class DisableLogging {
- private DisableLogging() {
- // This class is not meant to be instantiated
- }
+ private DisableLogging() {
+ // This class is not meant to be instantiated
+ }
- /**
- * Disable all logging.
- *
- * @return The original logging level.
- */
- public static Level disableLogging() {
- Logger logger = Logger.getLogger("");
- Level level = logger.getLevel();
- logger.setLevel(Level.OFF);
- return level;
- }
+ /**
+ * Disable all logging.
+ *
+ * @return The original logging level.
+ */
+ public static Level disableLogging() {
+ Logger logger = Logger.getLogger("");
+ Level level = logger.getLevel();
+ logger.setLevel(Level.OFF);
+ return level;
+ }
- /**
- * Enable all logging.
- *
- * @param level
- * The logging level to be restored. Usually this is the result returned by
- * disableLogging().
- */
- public static void enableLogging(Level level) {
- Logger logger = Logger.getLogger("");
- logger.setLevel(level);
- }
+ /**
+ * Enable all logging.
+ *
+ * @param level
+ * The logging level to be restored. Usually this is the result returned by
+ * disableLogging().
+ */
+ public static void enableLogging(Level level) {
+ Logger logger = Logger.getLogger("");
+ logger.setLevel(level);
+ }
}
Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/HideOutput.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/HideOutput.java?rev=1431721&r1=1431720&r2=1431721&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/HideOutput.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/testing/util/HideOutput.java Thu Jan 10 23:12:33 2013
@@ -40,26 +40,26 @@ import org.apache.commons.io.output.Null
*
*/
public class HideOutput {
- protected PrintStream out;
+ protected PrintStream out;
- protected PrintStream err;
+ protected PrintStream err;
- /**
- * calling this constructor will silence System.out and System.err until
- * {@link #restoreOutput()} is called by setting them to this OutputStream
- */
- public HideOutput() {
- this.out = System.out;
- this.err = System.err;
- System.setOut(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM));
- System.setErr(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM));
- }
+ /**
+ * calling this constructor will silence System.out and System.err until {@link #restoreOutput()}
+ * is called by setting them to this OutputStream
+ */
+ public HideOutput() {
+ this.out = System.out;
+ this.err = System.err;
+ System.setOut(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM));
+ System.setErr(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM));
+ }
- /**
- * this method restores System.out and System.err
- */
- public void restoreOutput() {
- System.setOut(this.out);
- System.setErr(this.err);
- }
+ /**
+ * this method restores System.out and System.err
+ */
+ public void restoreOutput() {
+ System.setOut(this.out);
+ System.setErr(this.err);
+ }
}