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 2022/02/10 14:37:19 UTC
[uima-uimaj] 12/15: [UIMA-6373] Format UIMA Core Java SDK codebase
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch refactoring/UIMA-6373-Format-UIMA-Core-Java-SDK-codebase
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 87ac952e4789b5bca2b91478e2b9d767bb9608b5
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Thu Feb 10 15:18:53 2022 +0100
[UIMA-6373] Format UIMA Core Java SDK codebase
- Auto-format
---
.../apache/uima/jcas/tcas/DocumentAnnotation.java | 26 +-
.../java/org/apache/uima/jcas/tcas/DocMeta.java | 406 ++++++++++++---------
.../uima/jcas/tcas/DocumentAnnotationTest.java | 88 ++---
3 files changed, 300 insertions(+), 220 deletions(-)
diff --git a/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java b/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java
index b85f1f6..72c2874 100644
--- a/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java
+++ b/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java
@@ -41,7 +41,7 @@ public class DocumentAnnotation extends Annotation {
/* public static string for use where constants are needed, e.g. in some Java Annotations */
public final static String _TypeName = CAS.TYPE_NAME_DOCUMENT_ANNOTATION;
public final static String _FeatName_language = "language";
-
+
public final static int typeIndexID = JCasRegistry.register(DocumentAnnotation.class);
public final static int type = typeIndexID;
@@ -51,9 +51,10 @@ public class DocumentAnnotation extends Annotation {
return typeIndexID;
}
- private final static CallSite _FC_language = TypeSystemImpl.createCallSite(DocumentAnnotation.class, "language");
+ private final static CallSite _FC_language = TypeSystemImpl
+ .createCallSite(DocumentAnnotation.class, "language");
private final static MethodHandle _FH_language = _FC_language.dynamicInvoker();
-
+
// Never called. Disable default constructor
protected DocumentAnnotation() {
}
@@ -63,10 +64,12 @@ public class DocumentAnnotation extends Annotation {
}
/**
- * used by generator
- * Make a new AnnotationBase
- * @param c -
- * @param t -
+ * used by generator Make a new AnnotationBase
+ *
+ * @param c
+ * -
+ * @param t
+ * -
*/
public DocumentAnnotation(TypeImpl t, CASImpl c) {
@@ -77,13 +80,18 @@ public class DocumentAnnotation extends Annotation {
// * Feature: language
/**
* getter for language
+ *
* @return the language
*/
- public String getLanguage() { return _getStringValueNc(wrapGetIntCatchException(_FH_language)); }
+ public String getLanguage() {
+ return _getStringValueNc(wrapGetIntCatchException(_FH_language));
+ }
/**
* setter for language
- * @param v the language
+ *
+ * @param v
+ * the language
*/
public void setLanguage(String v) {
_setStringValueNfc(wrapGetIntCatchException(_FH_language), v);
diff --git a/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java b/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
index b3699a6..56f1eca 100644
--- a/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
+++ b/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
/* Apache UIMA v3 - First created by JCasGen Mon Oct 02 16:32:10 EDT 2017 */
package org.apache.uima.jcas.tcas;
@@ -33,40 +33,47 @@ import org.apache.uima.jcas.cas.FSArray;
import org.apache.uima.jcas.cas.IntegerArray;
import org.apache.uima.jcas.cas.StringArray;
-
-/**
- * Updated by JCasGen Mon Oct 02 16:32:10 EDT 2017
- * XML source: C:/au/svnCheckouts/uv3/trunk/uimaj-v3/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
- * @generated */
+/**
+ * Updated by JCasGen Mon Oct 02 16:32:10 EDT 2017 XML source:
+ * C:/au/svnCheckouts/uv3/trunk/uimaj-v3/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
+ *
+ * @generated
+ */
public class DocMeta extends DocumentAnnotation {
-
- /** @generated
- * @ordered
+
+ /**
+ * @generated
+ * @ordered
*/
- @SuppressWarnings ("hiding")
+ @SuppressWarnings("hiding")
public final static String _TypeName = "org.apache.uima.jcas.tcas.DocMeta";
-
- /** @generated
- * @ordered
+
+ /**
+ * @generated
+ * @ordered
*/
- @SuppressWarnings ("hiding")
+ @SuppressWarnings("hiding")
public final static int typeIndexID = JCasRegistry.register(DocMeta.class);
- /** @generated
- * @ordered
+ /**
+ * @generated
+ * @ordered
*/
- @SuppressWarnings ("hiding")
+ @SuppressWarnings("hiding")
public final static int type = typeIndexID;
- /** @generated
- * @return index of the type
+
+ /**
+ * @generated
+ * @return index of the type
*/
@Override
- public int getTypeIndexID() {return typeIndexID;}
-
-
- /* *******************
- * Feature Offsets *
- * *******************/
-
+ public int getTypeIndexID() {
+ return typeIndexID;
+ }
+
+ /*
+ * ******************* Feature Offsets *
+ *******************/
+
public final static String _FeatName_feat = "feat";
public final static String _FeatName_feat2 = "feat2";
public final static String _FeatName_feat3 = "feat3";
@@ -74,7 +81,6 @@ public class DocMeta extends DocumentAnnotation {
public final static String _FeatName_arrayints = "arrayints";
public final static String _FeatName_arrayFs = "arrayFs";
-
/* Feature Adjusted Offsets */
private final static CallSite _FC_feat = TypeSystemImpl.createCallSite(DocMeta.class, "feat");
private final static MethodHandle _FH_feat = _FC_feat.dynamicInvoker();
@@ -82,223 +88,289 @@ public class DocMeta extends DocumentAnnotation {
private final static MethodHandle _FH_feat2 = _FC_feat2.dynamicInvoker();
private final static CallSite _FC_feat3 = TypeSystemImpl.createCallSite(DocMeta.class, "feat3");
private final static MethodHandle _FH_feat3 = _FC_feat3.dynamicInvoker();
- private final static CallSite _FC_arraystr = TypeSystemImpl.createCallSite(DocMeta.class, "arraystr");
+ private final static CallSite _FC_arraystr = TypeSystemImpl.createCallSite(DocMeta.class,
+ "arraystr");
private final static MethodHandle _FH_arraystr = _FC_arraystr.dynamicInvoker();
- private final static CallSite _FC_arrayints = TypeSystemImpl.createCallSite(DocMeta.class, "arrayints");
+ private final static CallSite _FC_arrayints = TypeSystemImpl.createCallSite(DocMeta.class,
+ "arrayints");
private final static MethodHandle _FH_arrayints = _FC_arrayints.dynamicInvoker();
- private final static CallSite _FC_arrayFs = TypeSystemImpl.createCallSite(DocMeta.class, "arrayFs");
+ private final static CallSite _FC_arrayFs = TypeSystemImpl.createCallSite(DocMeta.class,
+ "arrayFs");
private final static MethodHandle _FH_arrayFs = _FC_arrayFs.dynamicInvoker();
-
- /** Never called. Disable default constructor
- * @generated */
- protected DocMeta() {/* intentionally empty block */}
-
- /** Internal - constructor used by generator
+ /**
+ * Never called. Disable default constructor
+ *
* @generated
- * @param casImpl the CAS this Feature Structure belongs to
- * @param type the type of this Feature Structure
+ */
+ protected DocMeta() {
+ /* intentionally empty block */}
+
+ /**
+ * Internal - constructor used by generator
+ *
+ * @generated
+ * @param casImpl
+ * the CAS this Feature Structure belongs to
+ * @param type
+ * the type of this Feature Structure
*/
public DocMeta(TypeImpl type, CASImpl casImpl) {
super(type, casImpl);
readObject();
}
-
- /** @generated
- * @param jcas JCas to which this Feature Structure belongs
+
+ /**
+ * @generated
+ * @param jcas
+ * JCas to which this Feature Structure belongs
*/
public DocMeta(JCas jcas) {
super(jcas);
- readObject();
- }
-
+ readObject();
+ }
- /** @generated
- * @param jcas JCas to which this Feature Structure belongs
- * @param begin offset to the begin spot in the SofA
- * @param end offset to the end spot in the SofA
- */
+ /**
+ * @generated
+ * @param jcas
+ * JCas to which this Feature Structure belongs
+ * @param begin
+ * offset to the begin spot in the SofA
+ * @param end
+ * offset to the end spot in the SofA
+ */
public DocMeta(JCas jcas, int begin, int end) {
super(jcas);
setBegin(begin);
setEnd(end);
readObject();
- }
+ }
- /**
- * <!-- begin-user-doc -->
- * Write your own initialization here
- * <!-- end-user-doc -->
+ /**
+ * <!-- begin-user-doc --> Write your own initialization here <!-- end-user-doc -->
*
- * @generated modifiable
+ * @generated modifiable
*/
- private void readObject() {/*default - does nothing empty block */}
-
-
-
- //*--------------*
- //* Feature: feat
-
- /** getter for feat - gets
+ private void readObject() {
+ /* default - does nothing empty block */}
+
+ // *--------------*
+ // * Feature: feat
+
+ /**
+ * getter for feat - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public String getFeat() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat));}
-
- /** setter for feat - sets
+ public String getFeat() {
+ return _getStringValueNc(wrapGetIntCatchException(_FH_feat));
+ }
+
+ /**
+ * setter for feat - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setFeat(String v) {
_setStringValueNfc(wrapGetIntCatchException(_FH_feat), v);
- }
-
-
-
- //*--------------*
- //* Feature: feat2
-
- /** getter for feat2 - gets
+ }
+
+ // *--------------*
+ // * Feature: feat2
+
+ /**
+ * getter for feat2 - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public String getFeat2() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat2));}
-
- /** setter for feat2 - sets
+ public String getFeat2() {
+ return _getStringValueNc(wrapGetIntCatchException(_FH_feat2));
+ }
+
+ /**
+ * setter for feat2 - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setFeat2(String v) {
_setStringValueNfc(wrapGetIntCatchException(_FH_feat2), v);
- }
-
-
-
- //*--------------*
- //* Feature: feat3
-
- /** getter for feat3 - gets
+ }
+
+ // *--------------*
+ // * Feature: feat3
+
+ /**
+ * getter for feat3 - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public String getFeat3() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat3));}
-
- /** setter for feat3 - sets
+ public String getFeat3() {
+ return _getStringValueNc(wrapGetIntCatchException(_FH_feat3));
+ }
+
+ /**
+ * setter for feat3 - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setFeat3(String v) {
_setStringValueNfc(wrapGetIntCatchException(_FH_feat3), v);
- }
-
-
-
- //*--------------*
- //* Feature: arraystr
-
- /** getter for arraystr - gets
+ }
+
+ // *--------------*
+ // * Feature: arraystr
+
+ /**
+ * getter for arraystr - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public StringArray getArraystr() { return (StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)));}
-
- /** setter for arraystr - sets
+ public StringArray getArraystr() {
+ return (StringArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)));
+ }
+
+ /**
+ * setter for arraystr - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setArraystr(StringArray v) {
_setFeatureValueNcWj(wrapGetIntCatchException(_FH_arraystr), v);
- }
-
-
- /** indexed getter for arraystr - gets an indexed value -
+ }
+
+ /**
+ * indexed getter for arraystr - gets an indexed value -
+ *
* @generated
- * @param i index in the array to get
- * @return value of the element at index i
+ * @param i
+ * index in the array to get
+ * @return value of the element at index i
*/
public String getArraystr(int i) {
- return ((StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).get(i);}
+ return ((StringArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).get(i);
+ }
- /** indexed setter for arraystr - sets an indexed value -
+ /**
+ * indexed setter for arraystr - sets an indexed value -
+ *
* @generated
- * @param i index in the array to set
- * @param v value to set into the array
+ * @param i
+ * index in the array to set
+ * @param v
+ * value to set into the array
*/
public void setArraystr(int i, String v) {
- ((StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).set(i, v);
- }
-
-
- //*--------------*
- //* Feature: arrayints
-
- /** getter for arrayints - gets
+ ((StringArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).set(i, v);
+ }
+
+ // *--------------*
+ // * Feature: arrayints
+
+ /**
+ * getter for arrayints - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public IntegerArray getArrayints() { return (IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)));}
-
- /** setter for arrayints - sets
+ public IntegerArray getArrayints() {
+ return (IntegerArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)));
+ }
+
+ /**
+ * setter for arrayints - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setArrayints(IntegerArray v) {
_setFeatureValueNcWj(wrapGetIntCatchException(_FH_arrayints), v);
- }
-
-
- /** indexed getter for arrayints - gets an indexed value -
+ }
+
+ /**
+ * indexed getter for arrayints - gets an indexed value -
+ *
* @generated
- * @param i index in the array to get
- * @return value of the element at index i
+ * @param i
+ * index in the array to get
+ * @return value of the element at index i
*/
public int getArrayints(int i) {
- return ((IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).get(i);}
+ return ((IntegerArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).get(i);
+ }
- /** indexed setter for arrayints - sets an indexed value -
+ /**
+ * indexed setter for arrayints - sets an indexed value -
+ *
* @generated
- * @param i index in the array to set
- * @param v value to set into the array
+ * @param i
+ * index in the array to set
+ * @param v
+ * value to set into the array
*/
public void setArrayints(int i, int v) {
- ((IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).set(i, v);
- }
-
-
- //*--------------*
- //* Feature: arrayFs
-
- /** getter for arrayFs - gets
+ ((IntegerArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).set(i, v);
+ }
+
+ // *--------------*
+ // * Feature: arrayFs
+
+ /**
+ * getter for arrayFs - gets
+ *
* @generated
- * @return value of the feature
+ * @return value of the feature
*/
- public FSArray getArrayFs() { return (FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)));}
-
- /** setter for arrayFs - sets
+ public FSArray getArrayFs() {
+ return (FSArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)));
+ }
+
+ /**
+ * setter for arrayFs - sets
+ *
* @generated
- * @param v value to set into the feature
+ * @param v
+ * value to set into the feature
*/
public void setArrayFs(FSArray v) {
_setFeatureValueNcWj(wrapGetIntCatchException(_FH_arrayFs), v);
- }
-
-
- /** indexed getter for arrayFs - gets an indexed value -
+ }
+
+ /**
+ * indexed getter for arrayFs - gets an indexed value -
+ *
* @generated
- * @param i index in the array to get
- * @return value of the element at index i
+ * @param i
+ * index in the array to get
+ * @return value of the element at index i
*/
public Annotation getArrayFs(int i) {
- return (Annotation)(((FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)))).get(i));}
+ return (Annotation) (((FSArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs))))
+ .get(i));
+ }
- /** indexed setter for arrayFs - sets an indexed value -
+ /**
+ * indexed setter for arrayFs - sets an indexed value -
+ *
* @generated
- * @param i index in the array to set
- * @param v value to set into the array
+ * @param i
+ * index in the array to set
+ * @param v
+ * value to set into the array
*/
public void setArrayFs(int i, Annotation v) {
- ((FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)))).set(i, v);
- }
+ ((FSArray) (_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)))).set(i, v);
}
-
-
\ No newline at end of file
+}
diff --git a/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java b/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
index 3d43b73..3f7e30b 100644
--- a/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
+++ b/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
@@ -48,14 +48,13 @@ import org.apache.uima.util.XMLInputSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-
public class DocumentAnnotationTest {
JCas jcas;
private CAS source;
private CAS target;
-
- @BeforeEach
- public void setUp() throws Exception {
+
+ @BeforeEach
+ public void setUp() throws Exception {
try {
CAS cas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null);
this.jcas = cas.getJCas();
@@ -63,18 +62,18 @@ public class DocumentAnnotationTest {
JUnitExtension.handleException(e);
}
}
-
- @Test
- public void testGetDocumentAnnotation() throws Exception {
+
+ @Test
+ public void testGetDocumentAnnotation() throws Exception {
try {
assertTrue(jcas.getDocumentAnnotationFs() instanceof DocumentAnnotation);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
}
-
- @Test
- public void testCreateDocumentAnnot() throws Exception {
+
+ @Test
+ public void testCreateDocumentAnnot() throws Exception {
try {
DocumentAnnotation b = (DocumentAnnotation) jcas.getDocumentAnnotationFs();
jcas.reset();
@@ -83,75 +82,76 @@ public class DocumentAnnotationTest {
JUnitExtension.handleException(e);
}
}
-
- @Test
- public void testDocMeta() throws Exception {
+
+ @Test
+ public void testDocMeta() throws Exception {
File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem_docmetadata.xml");
- TypeSystemDescription typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
- new XMLInputSource(typeSystemFile));
-
+ TypeSystemDescription typeSystem = UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(new XMLInputSource(typeSystemFile));
+
source = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
target = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
-
+
jcas = source.getJCas();
-
+
tstSerdesB4Sofa(SerialFormat.XMI);
tstSerdesB4Sofa(SerialFormat.XCAS);
tstSerdesB4Sofa(SerialFormat.BINARY);
tstSerdesB4Sofa(SerialFormat.COMPRESSED);
- tstSerdesB4Sofa(SerialFormat.COMPRESSED_FILTERED);
+ tstSerdesB4Sofa(SerialFormat.COMPRESSED_FILTERED);
}
-
+
private void tstSerdesB4Sofa(SerialFormat format) throws IOException {
source.reset();
target.reset();
-
+
new DocMeta(jcas).addToIndexes();
-
+
jcas.setDocumentText("something");
-
+
new Annotation(jcas);
-
+
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CasIOUtils.save(source, bos, format);
bos.close();
-
+
CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
AnnotationFS c = target.getDocumentAnnotation();
System.out.println(c);
- System.out.println(target.<DocMeta>getDocumentAnnotation());
- assertTrue(CasCompare.compareCASes((CASImpl)source, (CASImpl)target));
+ System.out.println(target.<DocMeta> getDocumentAnnotation());
+ assertTrue(CasCompare.compareCASes((CASImpl) source, (CASImpl) target));
}
-
- @Test
- public void testToString() throws InvalidXMLException, IOException, ResourceInitializationException, CASException {
+
+ @Test
+ public void testToString()
+ throws InvalidXMLException, IOException, ResourceInitializationException, CASException {
File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem_docmetadata.xml");
- TypeSystemDescription typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
- new XMLInputSource(typeSystemFile));
-
+ TypeSystemDescription typeSystem = UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(new XMLInputSource(typeSystemFile));
+
source = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
jcas = source.getJCas();
-
+
DocMeta d = new DocMeta(jcas);
d.setFeat("a string");
d.setFeat2("b string");
d.setFeat3("c string");
-
+
FSArray fsa = new FSArray(jcas, 2);
- fsa.set(0, new Annotation(jcas, 1,2));
- fsa.set(1, new Annotation(jcas, 3,4));
+ fsa.set(0, new Annotation(jcas, 1, 2));
+ fsa.set(1, new Annotation(jcas, 3, 4));
d.setArrayFs(fsa);
-
+
IntegerArray intarr = new IntegerArray(jcas, 2);
- intarr.set(0, 10);
- intarr.set(1, -10);
+ intarr.set(0, 10);
+ intarr.set(1, -10);
d.setArrayints(intarr);
-
+
StringArray strarr = new StringArray(jcas, 2);
- strarr.set(0, "first");
- strarr.set(1, "second");
+ strarr.set(0, "first");
+ strarr.set(1, "second");
d.setArraystr(strarr);
-
+
System.out.println(d.toString());
}