From 90d2deedb465c5a7ea7a96832acbe7a37fbbc62b Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Wed, 4 Sep 2024 11:39:29 +0200 Subject: [PATCH] Issue #379: Clean up code - Clean up --- .../vinci/transport/util/Base64Converter.java | 2 +- .../cas/impl/LLUnambiguousIteratorImpl.java | 4 +- .../uima/cas/impl/IndexComparitorTest.java | 12 +-- .../uima/cas/impl/XmiCasSerializerTest.java | 19 ++-- .../uima/cas/test/GetAllIndexedTest.java | 6 +- .../test/GrowingTheCasNoJcasCacheTest.java | 4 +- .../impl/FsIndexCollection_implTest.java | 50 ++++------- .../uima/util/CasIOUtilsAlwaysHoldOnTest.java | 2 +- .../impl/Log4JLogger_implCapturingTest.java | 11 +-- .../impl/cpm/engine/ArtifactProducer.java | 3 +- .../cpm/engine/NonThreadedProcessingUnit.java | 3 +- .../impl/cpm/engine/ProcessingUnit.java | 3 +- .../caseditor/ide/wizards/package-info.java | 4 +- .../caseditor/editor/AnnotationEditor.java | 3 +- .../uima/caseditor/editor/ArrayValue.java | 3 +- .../uima/caseditor/editor/FeatureValue.java | 3 +- .../editor/ModelFeatureStructure.java | 3 +- .../uima/caseditor/editor/SubPageSite.java | 9 +- .../caseditor/editor/fsview/package-info.java | 4 +- .../editor/outline/AnnotationTreeNode.java | 3 +- .../outline/AnnotationTypeTreeNode.java | 3 +- .../editor/outline/package-info.java | 4 +- .../uima/caseditor/editor/package-info.java | 4 +- .../editor/styleview/AnnotationTypeNode.java | 3 +- .../uima/caseditor/ui/package-info.java | 4 +- .../caseditor/ui/property/package-info.java | 4 +- .../editors/MultiPageEditor.java | 15 ++-- .../editors/ui/TypeSection.java | 2 +- .../Scenario1TestAnnotator.java | 2 +- .../Scenario3TestAnnotator.java | 6 +- .../spi/JCasClassProviderForTesting.java | 14 +-- .../uima/tools/jcasgen/package-info.java | 10 ++- .../uima/migratev3/jcas/MigrateJCas.java | 86 +++++++++---------- 33 files changed, 150 insertions(+), 158 deletions(-) diff --git a/jVinci/src/main/java/org/apache/vinci/transport/util/Base64Converter.java b/jVinci/src/main/java/org/apache/vinci/transport/util/Base64Converter.java index cbc18dcb03..19d24ebf9d 100644 --- a/jVinci/src/main/java/org/apache/vinci/transport/util/Base64Converter.java +++ b/jVinci/src/main/java/org/apache/vinci/transport/util/Base64Converter.java @@ -314,7 +314,7 @@ private static boolean b64validDigit(byte a) { } private static void b64encodeOctet(byte[] to, int to_offset, byte[] from, int from_offset, - int count) { + int count) { int A = 0; int B = 0; int C = 0; diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/LLUnambiguousIteratorImpl.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/LLUnambiguousIteratorImpl.java index 059fcb943c..1498393892 100644 --- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/LLUnambiguousIteratorImpl.java +++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/LLUnambiguousIteratorImpl.java @@ -37,8 +37,8 @@ public class LLUnambiguousIteratorImpl extends FsIterator_subtypes_snapshot { public LLUnambiguousIteratorImpl(LowLevelIterator it) { - super((T[]) createItemsArray((LowLevelIterator) it), it.ll_getIndex(), - IS_ORDERED, it.getComparator()); + super((T[]) createItemsArray((LowLevelIterator) it), + (LowLevelIndex) it.ll_getIndex(), IS_ORDERED, it.getComparator()); } // this is static because can't have instance method call before super call in constructor diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexComparitorTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexComparitorTest.java index 06c6f9a26d..a26835adfe 100644 --- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexComparitorTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexComparitorTest.java @@ -545,8 +545,8 @@ void testSetUsesType() throws Exception { // values FeatureStructure testprobe2 = createFs(type1, 1, 1); - assertThat(sortedType1.size()).isEqualTo(2); - assertThat(setType1.size()).isEqualTo(2); + assertThat(sortedType1).hasSize(2); + assertThat(setType1).hasSize(2); FSIterator it = setType1.iterator(); it.moveTo(testprobe); @@ -562,10 +562,9 @@ void testSetUsesType() throws Exception { // note: this test is here because the setup is done @Test void testProtectIndex() throws Exception { - var fs = sortedType1.iterator().get(); - - var oldIsReportFsUpdatesCorrputs = CASImpl.IS_REPORT_FS_UPDATE_CORRUPTS_INDEX; - var oldIsThrowExceptionCorruptIndes = CASImpl.IS_THROW_EXCEPTION_CORRUPT_INDEX; + FSIterator it = sortedType1.iterator(); + FeatureStructure fs = it.get(); + boolean ok = false; try { CASImpl.IS_THROW_EXCEPTION_CORRUPT_INDEX = true; CASImpl.IS_REPORT_FS_UPDATE_CORRUPTS_INDEX = true; @@ -575,5 +574,6 @@ void testProtectIndex() throws Exception { CASImpl.IS_THROW_EXCEPTION_CORRUPT_INDEX = oldIsThrowExceptionCorruptIndes; CASImpl.IS_REPORT_FS_UPDATE_CORRUPTS_INDEX = oldIsReportFsUpdatesCorrputs; } + assertThat(CASImpl.IS_THROW_EXCEPTION_CORRUPT_INDEX ? ok : !ok).isTrue(); } } diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasSerializerTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasSerializerTest.java index ecc6ff6d17..cca7743052 100644 --- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasSerializerTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasSerializerTest.java @@ -71,6 +71,13 @@ void setUp() throws Exception { .parseTypeSystemDescription(new XMLInputSource(typeSystemFile)); } + @AfterEach + void tearDown() throws Exception { + if ((outputFile != null) && outputFile.exists()) { + outputFile.delete(); + } + } + @Test void testInvalidCharsInDocumentText() throws Exception { CAS cas = CasCreationUtils.createCas(typeSystemDesc, null, null); @@ -138,16 +145,4 @@ void testInvalidCharsInFeatureValue() throws Exception { } } } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @AfterEach - public void tearDown() throws Exception { - if ((outputFile != null) && outputFile.exists()) { - outputFile.delete(); - } - } } diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java index c34dd54a49..5d3e07d783 100644 --- a/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java @@ -87,8 +87,8 @@ public class GetAllIndexedTest { public void setUp() throws Exception { File descriptorFile = JUnitExtension .getFile("CASTests/desc/typePriorityTestCaseDescriptor.xml"); - assertThat(descriptorFile.exists()) - .as("Descriptor must exist: " + descriptorFile.getAbsolutePath()).isTrue(); + assertThat(descriptorFile).as("Descriptor must exist: " + descriptorFile.getAbsolutePath()) + .exists(); XMLParser parser = UIMAFramework.getXMLParser(); ResourceSpecifier spec = (ResourceSpecifier) parser.parse(new XMLInputSource(descriptorFile)); @@ -109,7 +109,7 @@ public void setUp() throws Exception { } @AfterEach - public void tearDown() { + void tearDown() { cas = null; // this.tokenType = null; // this.sentenceType = null; diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasNoJcasCacheTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasNoJcasCacheTest.java index 982184f463..3b593b948f 100644 --- a/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasNoJcasCacheTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasNoJcasCacheTest.java @@ -56,8 +56,8 @@ class GrowingTheCasNoJcasCacheTest { @BeforeEach void setUp() throws Exception { File descriptorFile = JUnitExtension.getFile("CASTests/desc/TokensAndSentences.xml"); - assertThat(descriptorFile.exists()) - .as("Descriptor must exist: " + descriptorFile.getAbsolutePath()).isTrue(); + assertThat(descriptorFile).as("Descriptor must exist: " + descriptorFile.getAbsolutePath()) + .exists(); XMLParser parser = UIMAFramework.getXMLParser(); ResourceSpecifier spec = parser.parseResourceSpecifier(new XMLInputSource(descriptorFile)); diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/FsIndexCollection_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/FsIndexCollection_implTest.java index 537b26f16b..07e0e3bc93 100644 --- a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/FsIndexCollection_implTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/FsIndexCollection_implTest.java @@ -21,13 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.io.File; - import org.apache.uima.UIMAFramework; -import org.apache.uima.resource.ResourceManager; -import org.apache.uima.resource.metadata.FsIndexCollection; -import org.apache.uima.resource.metadata.FsIndexDescription; -import org.apache.uima.resource.metadata.Import; import org.apache.uima.test.junit_extension.JUnitExtension; import org.apache.uima.util.InvalidXMLException; import org.apache.uima.util.XMLInputSource; @@ -48,37 +42,31 @@ void tearDown() throws Exception { @Test void testBuildFromXmlElement() throws Exception { - try { - File descriptor = JUnitExtension - .getFile("FsIndexCollectionImplTest/TestFsIndexCollection.xml"); - FsIndexCollection indexColl = UIMAFramework.getXMLParser() - .parseFsIndexCollection(new XMLInputSource(descriptor)); + var descriptor = JUnitExtension.getFile("FsIndexCollectionImplTest/TestFsIndexCollection.xml"); + var indexColl = UIMAFramework.getXMLParser() + .parseFsIndexCollection(new XMLInputSource(descriptor)); - assertThat(indexColl.getName()).isEqualTo("TestFsIndexCollection"); - assertThat(indexColl.getDescription()).isEqualTo("This is a test."); - assertThat(indexColl.getVendor()).isEqualTo("The Apache Software Foundation"); - assertThat(indexColl.getVersion()).isEqualTo("0.1"); - Import[] imports = indexColl.getImports(); - assertThat(imports).hasSize(2); - assertThat(imports[0].getName()).isEqualTo("FsIndexCollectionImportedFromDataPath"); - assertThat(imports[0].getLocation()).isNull(); - assertThat(imports[1].getName()).isNull(); - assertThat(imports[1].getLocation()).isEqualTo("FsIndexCollectionImportedByLocation.xml"); + assertThat(indexColl.getName()).isEqualTo("TestFsIndexCollection"); + assertThat(indexColl.getDescription()).isEqualTo("This is a test."); + assertThat(indexColl.getVendor()).isEqualTo("The Apache Software Foundation"); + assertThat(indexColl.getVersion()).isEqualTo("0.1"); + var imports = indexColl.getImports(); + assertThat(imports).hasSize(2); + assertThat(imports[0].getName()).isEqualTo("FsIndexCollectionImportedFromDataPath"); + assertThat(imports[0].getLocation()).isNull(); + assertThat(imports[1].getName()).isNull(); + assertThat(imports[1].getLocation()).isEqualTo("FsIndexCollectionImportedByLocation.xml"); - FsIndexDescription[] indexes = indexColl.getFsIndexes(); - assertThat(indexes).hasSize(2); - } catch (Exception e) { - JUnitExtension.handleException(e); - } + var indexes = indexColl.getFsIndexes(); + assertThat(indexes).hasSize(2); } @Test void testResolveImports() throws Exception { - File descriptor = JUnitExtension.getFile("FsIndexCollectionImplTest/TestFsIndexCollection.xml"); - FsIndexCollection ic = UIMAFramework.getXMLParser() - .parseFsIndexCollection(new XMLInputSource(descriptor)); + var descriptor = JUnitExtension.getFile("FsIndexCollectionImplTest/TestFsIndexCollection.xml"); + var ic = UIMAFramework.getXMLParser().parseFsIndexCollection(new XMLInputSource(descriptor)); - FsIndexDescription[] indexes = ic.getFsIndexes(); + var indexes = ic.getFsIndexes(); assertThat(indexes).hasSize(2); // resolving imports without setting data path should fail @@ -93,7 +81,7 @@ void testResolveImports() throws Exception { // thrown // set data path correctly and it should work - ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); + var resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPathElements( JUnitExtension.getFile("FsIndexCollectionImplTest/dataPathDir").getAbsoluteFile()); ic.resolveImports(resMgr); diff --git a/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsAlwaysHoldOnTest.java b/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsAlwaysHoldOnTest.java index 7cbbc887f8..285f41a094 100644 --- a/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsAlwaysHoldOnTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsAlwaysHoldOnTest.java @@ -49,7 +49,7 @@ static void tearDown() throws Exception { if (oldHoldOntoFss != null) { System.setProperty(CASImpl.ALWAYS_HOLD_ONTO_FSS, oldHoldOntoFss); } else { - System.getProperties().remove(CASImpl.ALWAYS_HOLD_ONTO_FSS); + System.clearProperty(CASImpl.ALWAYS_HOLD_ONTO_FSS); } } diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/Log4JLogger_implCapturingTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/Log4JLogger_implCapturingTest.java index d736711a46..f2c2c819d0 100644 --- a/uimaj-core/src/test/java/org/apache/uima/util/impl/Log4JLogger_implCapturingTest.java +++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/Log4JLogger_implCapturingTest.java @@ -26,6 +26,7 @@ import java.util.List; import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.LogEvent; import org.apache.uima.util.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -123,9 +124,9 @@ void thatTwoParametersAndThrowableAreLogged() throws Exception { assertThat(capture.getAndClearLatestEvents()) // .extracting( // - logEvent1 -> logEvent1.getLevel(), // + LogEvent::getLevel, // e -> e.getMessage().getFormattedMessage(), // - logEvent -> logEvent.getThrown()) // + LogEvent::getThrown) // .containsExactly( // tuple(Level.TRACE, "1 2", ex), // tuple(Level.DEBUG, "1 2", ex), // @@ -146,9 +147,9 @@ void thatThreeParametersAndThrowableAreLogged() throws Exception { assertThat(capture.getAndClearLatestEvents()) // .extracting( // - logEvent1 -> logEvent1.getLevel(), // + LogEvent::getLevel, // e -> e.getMessage().getFormattedMessage(), // - logEvent -> logEvent.getThrown()) // + LogEvent::getThrown) // .containsExactly( // tuple(Level.TRACE, "1 2 3", ex), // tuple(Level.DEBUG, "1 2 3", ex), // @@ -177,7 +178,7 @@ void thatMultipleParametersAndThrowableAreLogged() throws Exception { assertThat(capture.getAndClearLatestEvents()) // .extracting( // e -> e.getMessage().getFormattedMessage(), // - logEvent -> logEvent.getThrown()) // + LogEvent::getThrown) // .containsExactly( // tuple(String.join(" ", values), ex)); } diff --git a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java index c85016acb7..eb946a2068 100644 --- a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java +++ b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java @@ -771,8 +771,7 @@ public void run() { // while the CPM is in normal shutdown state. // (Moved this code inside if (casObjectList != null) // block to avoid NullPointerException. -Adam - if (cpm.isRunning() - || (!cpm.isRunning() && !cpm.isHardKilled())) { + if (cpm.isRunning() || (!cpm.isRunning() && !cpm.isHardKilled())) { threadState = 1005; // Entering enqueue workQueue.enqueue(casObjectList); // synchronized (workQueue) { // redundant, enqueue does this diff --git a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/NonThreadedProcessingUnit.java b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/NonThreadedProcessingUnit.java index 2c9542eef8..74ebd0a647 100644 --- a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/NonThreadedProcessingUnit.java +++ b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/NonThreadedProcessingUnit.java @@ -655,8 +655,7 @@ private void postAnalysis(Object[] aCasObjectList, boolean isCasObject, Object[] } } // enqueue CASes. If the CPM is in shutdown mode due to hard kill dont allow enqueue of CASes - if (outputQueue != null && (cpm.isRunning() - || (!cpm.isRunning() && !cpm.isHardKilled()))) { + if (outputQueue != null && (cpm.isRunning() || (!cpm.isRunning() && !cpm.isHardKilled()))) { if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_add_cas_to_queue__FINEST", diff --git a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ProcessingUnit.java b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ProcessingUnit.java index 696bfdb603..6ebaa4038a 100644 --- a/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ProcessingUnit.java +++ b/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ProcessingUnit.java @@ -1306,8 +1306,7 @@ private void postAnalysis(Object[] aCasObjectList, boolean isCasObject, Object[] maybeLogFinest("UIMA_CPM_done_notify_listeners__FINEST"); } // enqueue CASes. If the CPM is in shutdown mode due to hard kill dont allow enqueue of CASes - if (outputQueue != null && (cpm.isRunning() - || (!cpm.isRunning() && !cpm.isHardKilled()))) { + if (outputQueue != null && (cpm.isRunning() || (!cpm.isRunning() && !cpm.isHardKilled()))) { maybeLogFinestWorkQueue("UIMA_CPM_add_cas_to_queue__FINEST", outputQueue); WorkUnit workUnit = new WorkUnit(aCasObjectList); if (casCache != null && casCache[0] != null) { diff --git a/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/package-info.java b/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/package-info.java index 6e7b2b121d..43e2a1b4db 100644 --- a/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/package-info.java +++ b/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/package-info.java @@ -17,6 +17,8 @@ * under the License. */ /** - *

This package contains the wizards classes.

+ *

+ * This package contains the wizards classes. + *

*/ package org.apache.uima.caseditor.ide.wizards; \ No newline at end of file diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java index 6f8e20a1c5..0d7da4c297 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java @@ -708,8 +708,7 @@ public String getTitleToolTip() { * @return an adapter or null */ @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (IContentOutlinePage.class.equals(adapter) && getDocument() != null) { return mOutlinePage; diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java index f612a3fac2..4a4faa9617 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java @@ -163,8 +163,7 @@ public Object get() { } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (FeatureStructure.class.equals(adapter)) { if (arrayFS instanceof ArrayFS) { diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java index 16ab07c681..39af8542ca 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java @@ -81,8 +81,7 @@ public Object getValue() { } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (AnnotationFS.class.equals(adapter)) { if (getValue() instanceof AnnotationFS) { return getValue(); diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java index dd5c0a0322..e1b43d1577 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java @@ -133,8 +133,7 @@ public static List create(ICasDocument document, } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (FeatureStructure.class.equals(adapter)) { return getStructre(); } else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) { diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java index ee6f108bbf..b7b47d3c1c 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java @@ -53,20 +53,17 @@ public SubPageSite(IPageSite site) { } @Override - public boolean hasService(@SuppressWarnings("rawtypes") - Class api) { + public boolean hasService(@SuppressWarnings("rawtypes") Class api) { return site.hasService(api); } @Override - public Object getService(@SuppressWarnings("rawtypes") - Class api) { + public Object getService(@SuppressWarnings("rawtypes") Class api) { return site.getService(api); } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { return site.getAdapter(adapter); } diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/package-info.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/package-info.java index 41cfa59eda..793c2d9d86 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/package-info.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/package-info.java @@ -17,6 +17,8 @@ * under the License. */ /** - *

This package contains the feature structure view classes.

+ *

+ * This package contains the feature structure view classes. + *

*/ package org.apache.uima.caseditor.editor.fsview; \ No newline at end of file diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java index 75634ae830..9796150f31 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java @@ -112,8 +112,7 @@ void addChild(AnnotationTreeNode node) { } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { // TODO: // use ModelFeatureStructure // create a AdapterFactory which just calls the diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java index 85c04bebe8..b0722870d4 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java @@ -77,8 +77,7 @@ public void remove(AnnotationTreeNode annotation) { } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (Type.class.equals(adapter)) { return type; diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/package-info.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/package-info.java index 5bb5153197..686ab22f89 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/package-info.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/package-info.java @@ -17,6 +17,8 @@ * under the License. */ /** - *

This package contains the outline classes.

+ *

+ * This package contains the outline classes. + *

*/ package org.apache.uima.caseditor.editor.outline; \ No newline at end of file diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/package-info.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/package-info.java index 215e83ee2a..e31291bb9c 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/package-info.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/package-info.java @@ -18,6 +18,8 @@ */ /** - *

This package contains the editor classes.

+ *

+ * This package contains the editor classes. + *

*/ package org.apache.uima.caseditor.editor; \ No newline at end of file diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java index e9951420c3..4903c3fbe7 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java @@ -84,8 +84,7 @@ public int hashCode() { } @Override - public Object getAdapter(@SuppressWarnings("rawtypes") - Class adapter) { + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (AnnotationTypeNode.class.equals(adapter)) { return this; diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/package-info.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/package-info.java index 1ba83e9c77..6e2902448e 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/package-info.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/package-info.java @@ -18,6 +18,8 @@ */ /** - *

This package contains the ui classes and packages.

+ *

+ * This package contains the ui classes and packages. + *

*/ package org.apache.uima.caseditor.ui; \ No newline at end of file diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/package-info.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/package-info.java index 730a7887c2..9103519c32 100644 --- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/package-info.java +++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/package-info.java @@ -18,6 +18,8 @@ */ /** - *

This package contains the property page classes.

+ *

+ * This package contains the property page classes. + *

*/ package org.apache.uima.caseditor.ui.property; \ No newline at end of file diff --git a/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/MultiPageEditor.java b/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/MultiPageEditor.java index 0f4306ba36..8aebbcf8a5 100644 --- a/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/MultiPageEditor.java +++ b/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/MultiPageEditor.java @@ -1132,7 +1132,8 @@ public boolean isValidAE(AnalysisEngineDescription aAe) { // class is compiled for Java 5.0, but the CDE is running Java 1.4.2 Utility.popMessage(Messages.getString("MultiPageEditor.failedCollRdrValidation"), //$NON-NLS-1$ Messages.getString("MultiPageEditor.failedCollRdrValidationMsg") + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + getMessagesToRootCause(e), MessageDialog.ERROR); + + getMessagesToRootCause(e), + MessageDialog.ERROR); return false; } } else if (isCasInitializerDescriptor()) { @@ -1143,7 +1144,8 @@ public boolean isValidAE(AnalysisEngineDescription aAe) { } catch (Throwable e) { Utility.popMessage(Messages.getString("MultiPageEditor.failedCasInitValidation"), //$NON-NLS-1$ Messages.getString("MultiPageEditor.failedCasInitValidationMsg") + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + getMessagesToRootCause(e), MessageDialog.ERROR); + + getMessagesToRootCause(e), + MessageDialog.ERROR); return false; } } else if (isCasConsumerDescriptor()) { @@ -1153,7 +1155,8 @@ public boolean isValidAE(AnalysisEngineDescription aAe) { } catch (Throwable e) { Utility.popMessage(Messages.getString("MultiPageEditor.failedCasConsValidation"), //$NON-NLS-1$ Messages.getString("MultiPageEditor.failedCasConsValidationMsg") + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + getMessagesToRootCause(e), MessageDialog.ERROR); + + getMessagesToRootCause(e), + MessageDialog.ERROR); return false; } @@ -1186,7 +1189,8 @@ public boolean isValidAE(AnalysisEngineDescription aAe) { } catch (Throwable e) { Utility.popMessage(Messages.getString("MultiPageEditor.failedAeValidation"), //$NON-NLS-1$ Messages.getString("MultiPageEditor.failedAeValidationMsg") + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + getMessagesToRootCause(e), MessageDialog.ERROR); + + getMessagesToRootCause(e), + MessageDialog.ERROR); return false; } } @@ -1477,7 +1481,8 @@ private void parseSourceInner(XMLInputSource input, String filePathName, boolean e.printStackTrace(); Utility.popMessage(Messages.getString("MultiPageEditor.XMLerrorInDescriptorTitle"), //$NON-NLS-1$ Messages.getString("MultiPageEditor.XMLerrorInDescriptor") + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + getMessagesToRootCause(e), MessageDialog.ERROR); + + getMessagesToRootCause(e), + MessageDialog.ERROR); } catch (ResourceInitializationException e) { // occurs if bad xml diff --git a/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java b/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java index de62d0ab14..70e0a9ba6a 100644 --- a/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java +++ b/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java @@ -1570,7 +1570,7 @@ public int compare(Object o1, Object o2) { TypeOrFeature tf = (TypeOrFeature) o2; return ((tf.isType() == true && tf.getName().equals(o1)) || // remove features belong to type if type is removed - tf.getName().startsWith(((String) o1) + ':')) ? 0 : 1; + tf.getName().startsWith(((String) o1) + ':')) ? 0 : 1; } }; diff --git a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario1TestAnnotator.java b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario1TestAnnotator.java index 8dd996e38e..a4461599a8 100644 --- a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario1TestAnnotator.java +++ b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario1TestAnnotator.java @@ -39,7 +39,7 @@ public void process(JCas aJCas) throws AnalysisEngineProcessException var simpleAnnotation = new SimpleAnnotation(aJCas); simpleAnnotation.addToIndexes(); - + var complexAnnotation = new ComplexAnnotation(aJCas); complexAnnotation.setDelegate(simpleAnnotation); complexAnnotation.addToIndexes(); diff --git a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario3TestAnnotator.java b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario3TestAnnotator.java index 9c4bc0fe09..14b71a846f 100644 --- a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario3TestAnnotator.java +++ b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario3TestAnnotator.java @@ -31,8 +31,8 @@ public class Scenario3TestAnnotator extends TestAnnotator_ImplBase { - private static final String TYPE_NAME_COMPLEX_ANNOTATION_SUBTYPE = "org.apache.uima.it.pear_with_typesystem.type.ComplexAnnotationSubtype"; - + private static final String TYPE_NAME_COMPLEX_ANNOTATION_SUBTYPE = "org.apache.uima.it.pear_with_typesystem.type.ComplexAnnotationSubtype"; + @SuppressWarnings("unused") @Override public void process(JCas aJCas) throws AnalysisEngineProcessException @@ -42,7 +42,7 @@ public void process(JCas aJCas) throws AnalysisEngineProcessException // The unit test should have prepared the CAS with one of these assertFalse(aJCas.select(TYPE_NAME_COMPLEX_ANNOTATION_SUBTYPE).isEmpty()); - + // Iterating over the ComplexAnnotation instances should also return a ComplexAnnotationSubtype // and that will trigger a ClassCastException - we have the assertion for this in the unit test var complexAnnotation = aJCas.select(ComplexAnnotation.class).get(); diff --git a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/spi/JCasClassProviderForTesting.java b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/spi/JCasClassProviderForTesting.java index 17af1777ef..ca3ef84f79 100644 --- a/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/spi/JCasClassProviderForTesting.java +++ b/uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/spi/JCasClassProviderForTesting.java @@ -28,10 +28,14 @@ import org.apache.uima.jcas.cas.TOP; import org.apache.uima.spi.JCasClassProvider; -public class JCasClassProviderForTesting implements JCasClassProvider { +public class JCasClassProviderForTesting + implements JCasClassProvider +{ - @Override - public List> listJCasClasses() { - return asList(ComplexAnnotation.class, SimpleAnnotation.class, ComplexAnnotationSubtype.class); - } + @Override + public List> listJCasClasses() + { + return asList(ComplexAnnotation.class, SimpleAnnotation.class, + ComplexAnnotationSubtype.class); + } } diff --git a/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/package-info.java b/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/package-info.java index f1d555c339..028e591def 100644 --- a/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/package-info.java +++ b/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/package-info.java @@ -18,12 +18,14 @@ */ /** * Describes the format of the generated JCas cover classes for UIMA Version 3. - *

In UIMA version 3

+ *

+ * In UIMA version 3 + *

*
    *
  • There are no xxx_Type classes.
  • - *
  • As in v2, multiple type systems may be sequentially loaded into a (reset) CAS, under one class loader.
  • - *
  • Change: one consistent JCas gen'd set of classes is loaded per class loader. - *
  • + *
  • As in v2, multiple type systems may be sequentially loaded into a (reset) CAS, under one + * class loader.
  • + *
  • Change: one consistent JCas gen'd set of classes is loaded per class loader.
  • *
*/ package org.apache.uima.tools.jcasgen; \ No newline at end of file diff --git a/uimaj-v3migration-jcas/src/main/java/org/apache/uima/migratev3/jcas/MigrateJCas.java b/uimaj-v3migration-jcas/src/main/java/org/apache/uima/migratev3/jcas/MigrateJCas.java index 0cdb75fad3..9245f47eac 100644 --- a/uimaj-v3migration-jcas/src/main/java/org/apache/uima/migratev3/jcas/MigrateJCas.java +++ b/uimaj-v3migration-jcas/src/main/java/org/apache/uima/migratev3/jcas/MigrateJCas.java @@ -391,8 +391,7 @@ private Path installJarOrPear() { false); String newClasspath = ip.buildComponentClassPath(); String parentClasspath = parent.pearClasspath; - pearClasspath = (null == parentClasspath || 0 == parentClasspath.length()) - ? newClasspath + pearClasspath = (null == parentClasspath || 0 == parentClasspath.length()) ? newClasspath : newClasspath + File.pathSeparator + parentClasspath; } @@ -458,18 +457,18 @@ public int hashCode() { @Override public boolean equals(Object obj) { if (this == obj) { - return true; - } + return true; + } if (obj == null) { - return false; - } + return false; + } if (getClass() != obj.getClass()) { - return false; - } + return false; + } Container other = (Container) obj; if (id != other.id) { - return false; - } + return false; + } return true; } @@ -918,8 +917,8 @@ private void postProcessPearOrJar(Container container) { // copy the pear or jar so we don't change the original Path lastPartOfPath = container.rootOrig.getFileName(); if (null == lastPartOfPath) { - throw new RuntimeException("Internal Error"); - } + throw new RuntimeException("Internal Error"); + } Path pearOrJarCopy = Paths.get(outputDirectory, container.isJar ? "jars" : "pears", Integer.toString(container.id), lastPartOfPath.toString()); @@ -1031,10 +1030,9 @@ private boolean compileV3SourcesCommon2(Container container) { indent[0] += 2; boolean isEmpty = true; for (CommonConverted cc : container.convertedItems) { - if (cc.v3SourcePath == null) - { - continue; // skip items that failed migration - } + if (cc.v3SourcePath == null) { + continue; // skip items that failed migration + } isEmpty = false; // relativePathInContainer = the whole path with the first part (up to the end of the // container root) stripped off @@ -1730,16 +1728,16 @@ public void visit(MethodDeclaration n, Object ignore) { List ps = n.getParameters(); if (isGetter) { if (ps.size() > 1) { - break; - } + break; + } } else { // is setter if (ps.size() > 2 || ps.size() == 0) { - break; - } + break; + } if (ps.size() == 2) { if (!getParmTypeName(ps, 0).equals("int")) { - break; - } + break; + } isArraySetter = true; } } @@ -1748,8 +1746,8 @@ public void visit(MethodDeclaration n, Object ignore) { String bodyString = n.getBody().get().toString(printWithoutComments); int i = bodyString.indexOf("jcasType.ll_cas.ll_"); if (i < 0) { - break; - } + break; + } String s = bodyString.substring(i + "jcasType.ll_cas.ll_get".length()); // also for // ...ll_set - same // length! @@ -1918,8 +1916,8 @@ public void visit(MethodCallExpr n, Object ignore) { do { if (get_set_method == null) { - break; - } + break; + } /** remove checkArraybounds statement **/ if (n.getNameAsString().equals("checkArrayBounds") @@ -1937,8 +1935,8 @@ public void visit(MethodCallExpr n, Object ignore) { .startsWith("ll_" + (useGetter ? "get" : "set") + rangeNameV2Part + "Value")) { args = n.getArguments(); if (args.size() != (useGetter ? 2 : 3)) { - break; - } + break; + } String suffix = useGetter ? "Nc" : rangeNamePart.equals("Feature") ? "NcWj" : "Nfc"; String methodName = "_" + (useGetter ? "get" : "set") + rangeNamePart + "Value" + suffix; args.remove(0); // remove the old addr arg @@ -1955,11 +1953,11 @@ public void visit(MethodCallExpr n, Object ignore) { String s = nname.substring(z.length()); s = s.substring(0, s.length() - "Value".length()); // s = "ShortArray", etc. if (s.equals("RefArray")) { - s = "FSArray"; - } + s = "FSArray"; + } if (s.equals("IntArray")) { - s = "IntegerArray"; - } + s = "IntegerArray"; + } EnclosedExpr ee = new EnclosedExpr( new CastExpr(new ClassOrInterfaceType(s), n.getArguments().get(0))); @@ -2215,8 +2213,8 @@ private Path makePath(String name) throws IOException { reportPathWorkaround(parent.toString(), p2.toString()); Path lastPartOfPath = p.getFileName(); if (null == lastPartOfPath) { - throw new RuntimeException(); - } + throw new RuntimeException(); + } return Paths.get(p2.toString(), lastPartOfPath.toString()); } return p; @@ -2256,8 +2254,8 @@ private boolean reportPaths(String title, String fileName, } System.out.println("\n" + title); for (int i = 0; i < title.length(); i++) { - System.out.print('='); - } + System.out.print('='); + } System.out.println(""); try (BufferedWriter bw = Files.newBufferedWriter(makePath(outDirLog + fileName), @@ -2775,8 +2773,8 @@ private Node replaceInParent(Node n, Expression v) { List args = ((ObjectCreationExpr) parent).getArguments(); int i = args.indexOf(n); if (i < 0) { - throw new RuntimeException(); - } + throw new RuntimeException(); + } args.set(i, v); } else { System.out.println(parent.getClass().getName()); @@ -2833,11 +2831,11 @@ private boolean hasTypeFields(NodeList> members) { if (vd.getType().equals(intType)) { String n = vd.getNameAsString(); if (n.equals("type")) { - hasType = true; - } + hasType = true; + } if (n.equals("typeIndexID")) { - hasTypeId = true; - } + hasTypeId = true; + } if (hasTypeId && hasType) { return true; } @@ -2874,8 +2872,8 @@ private void setHasJCasConstructors(NodeList> members) { if (bd instanceof ConstructorDeclaration) { List ps = ((ConstructorDeclaration) bd).getParameters(); if (ps.size() == 0) { - has0ArgConstructor = true; - } + has0ArgConstructor = true; + } if (ps.size() == 1 && getParmTypeName(ps, 0).equals("JCas")) { has1ArgJCasConstructor = true; }