stringArrayFS.set(1, "Test1");
stringArrayFS.set(2, "Test2");
cas.getDocumentAnnotation().setFeatureValue(stringArrayFeat,
stringArrayFS);
String path = "/stringArray";
FeaturePath featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(stringArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("Test0,Test1,Test2,null", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_STRINGARRAY, featurePath
.getTypClass(cas.getDocumentAnnotation()));
assertEquals(stringArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test shortArray feature
Feature shortArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("shortArray");
ShortArrayFS shortArrayFS = cas.createShortArrayFS(3);
shortArrayFS.set(0, (short) 0);
shortArrayFS.set(1, (short) 2);
shortArrayFS.set(2, (short) 54);
cas.getDocumentAnnotation().setFeatureValue(shortArrayFeat, shortArrayFS);
path = "/shortArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(shortArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("0,2,54", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_SHORTARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(shortArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test floatArray feature
Feature floatArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("floatArray");
FloatArrayFS floatArrayFS = cas.createFloatArrayFS(3);
floatArrayFS.set(0, 1.4f);
floatArrayFS.set(1, 0f);
floatArrayFS.set(2, 3434.34f);
cas.getDocumentAnnotation().setFeatureValue(floatArrayFeat, floatArrayFS);
path = "/floatArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(floatArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("1.4,0.0,3434.34", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_FLOATARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(floatArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test doubleArray feature
Feature doubleArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("doubleArray");
DoubleArrayFS doubleArrayFS = cas.createDoubleArrayFS(3);
doubleArrayFS.set(0, 1.4);
doubleArrayFS.set(1, 0);
doubleArrayFS.set(2, 3434.34);
cas.getDocumentAnnotation().setFeatureValue(doubleArrayFeat,
doubleArrayFS);
path = "/doubleArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(doubleArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("1.4,0.0,3434.34", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_DOUBLEARRAY, featurePath
.getTypClass(cas.getDocumentAnnotation()));
assertEquals(doubleArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test longArray feature
Feature longArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("longArray");
LongArrayFS longArrayFS = cas.createLongArrayFS(3);
longArrayFS.set(0, 14);
longArrayFS.set(1, 0);
longArrayFS.set(2, 343434);
cas.getDocumentAnnotation().setFeatureValue(longArrayFeat, longArrayFS);
path = "/longArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(longArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("14,0,343434", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_LONGARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(longArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test intArray feature
Feature intArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("intArray");
IntArrayFS intArrayFS = cas.createIntArrayFS(3);
intArrayFS.set(0, 14);
intArrayFS.set(1, 0);
intArrayFS.set(2, 343);
cas.getDocumentAnnotation().setFeatureValue(intArrayFeat, intArrayFS);
path = "/intArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(intArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("14,0,343", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_INTARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(intArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test booleanArray feature
Feature booleanArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("booleanArray");
BooleanArrayFS booleanArrayFS = cas.createBooleanArrayFS(3);
booleanArrayFS.set(0, true);
booleanArrayFS.set(1, false);
booleanArrayFS.set(2, true);
cas.getDocumentAnnotation().setFeatureValue(booleanArrayFeat,
booleanArrayFS);
path = "/booleanArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(booleanArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("true,false,true", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_BOOLEANARRAY, featurePath
.getTypClass(cas.getDocumentAnnotation()));
assertEquals(booleanArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test byteArray feature
Feature byteArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("byteArray");
ByteArrayFS byteArrayFS = cas.createByteArrayFS(3);
byteArrayFS.set(0, (byte) 23);
byteArrayFS.set(1, (byte) 47);
byteArrayFS.set(2, (byte) 11);
cas.getDocumentAnnotation().setFeatureValue(byteArrayFeat, byteArrayFS);
path = "/byteArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(byteArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertEquals("23,47,11", featurePath.getValueAsString(cas
.getDocumentAnnotation()));
assertEquals(TypeClass.TYPE_CLASS_BYTEARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(byteArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
// test fsArray feature
Feature fsArrayFeat = cas.getDocumentAnnotation().getType()
.getFeatureByBaseName("fsArray");
ArrayFS fsArrayFS = cas.createArrayFS(2);
fsArrayFS.set(0, cas.getDocumentAnnotation());
fsArrayFS.set(1, cas.getDocumentAnnotation());
fsArrayFS.toStringArray();
cas.getDocumentAnnotation().setFeatureValue(fsArrayFeat, fsArrayFS);
path = "/fsArray";
featurePath = new FeaturePathImpl();
featurePath.initialize(path);
featurePath.typeInit(cas.getDocumentAnnotation().getType());
assertEquals(fsArrayFS, featurePath.getFSValue(cas
.getDocumentAnnotation()));
assertTrue(featurePath.getValueAsString(cas.getDocumentAnnotation())
.indexOf("11") > 0);
assertEquals(TypeClass.TYPE_CLASS_FSARRAY, featurePath.getTypClass(cas
.getDocumentAnnotation()));
assertEquals(fsArrayFeat.getRange(), featurePath.getType(cas
.getDocumentAnnotation()));
}