// SofaFS longarraySofaFS = cas.createSofa(id, "text");
// longarraySofaFS.setLocalSofaData(longArrayFS);
CAS longArrayView =this.cas.createView("longArraySofaData");
longArrayView.setSofaDataArray(longArrayFS, "longs");
DoubleArrayFS doubleArrayFS =this.cas.createDoubleArrayFS(5);
doubleArrayFS.set(0, Double.MAX_VALUE);
doubleArrayFS.set(1, Double.MIN_VALUE);
doubleArrayFS.set(2, Double.parseDouble("1.5555"));
doubleArrayFS.set(3, Double.parseDouble("99.000000005"));
doubleArrayFS.set(4, Double.parseDouble("4.44444444444444444"));
// create a Sofa and set the SofaArray feature.
// id = new SofaID_impl();
// id.setSofaID("doubleArraySofaData");
// SofaFS doublearraySofaFS = cas.createSofa(id, "text");
// doublearraySofaFS.setLocalSofaData(doubleArrayFS);
CAS doubleArrayView =this.cas.createView("doubleArraySofaData");
doubleArrayView.setSofaDataArray(doubleArrayFS, "doubles");
// create remote sofa and set the SofaURI feature
// id = new SofaID_impl();
// id.setSofaID("remoteSofaData");
// SofaFS remoteSofa = cas.createSofa(id, "text");
// remoteSofa.setRemoteSofaURI("file:.\\Sofa.xcas");
CAS remoteView =this.cas.createView("remoteSofaData");
String sofaFileName = "./Sofa.xcas";
remoteView.setSofaDataURI("file:" + sofaFileName, "text");
// read sofa data
// InputStream is = strSofa.getSofaDataStream();
InputStream is = stringView.getSofaDataStream();
assertTrue(is != null);
byte[] dest = new byte[1];
StringBuffer buf = new StringBuffer();
while (is.read(dest) != -1) {
buf.append((char) dest[0]);
}
assertTrue(buf.toString().equals("this beer is good"));
dest = new byte[4];
// is = intarraySofaFS.getSofaDataStream();
is.close();
is = intArrayView.getSofaDataStream();
assertTrue(is != null);
int i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).getInt() == intArrayFS.get(i++));
}
is.close();
is = stringArrayView.getSofaDataStream();
assertTrue(is != null);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
i = 0;
while (br.ready()) {
assertTrue(stringArrayFS.get(i++).equals(br.readLine()));
}
// is = floatarraySofaFS.getSofaDataStream();
is.close();
is = floatArrayView.getSofaDataStream();
assertTrue(is != null);
i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).getFloat() == floatArrayFS.get(i++));
}
dest = new byte[2];
// is = shortarraySofaFS.getSofaDataStream();
is.close();
is = shortArrayView.getSofaDataStream();
assertTrue(is != null);
i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).getShort() == shortArrayFS.get(i++));
}
dest = new byte[1];
// is = bytearraySofaFS.getSofaDataStream();
is.close();
is = byteArrayView.getSofaDataStream();
assertTrue(is != null);
i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).get() == byteArrayFS.get(i++));
}
dest = new byte[8];
// is = longarraySofaFS.getSofaDataStream();
is.close();
is = longArrayView.getSofaDataStream();
assertTrue(is != null);
i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).getLong() == longArrayFS.get(i++));
}
// is = doublearraySofaFS.getSofaDataStream();
is.close();
is = doubleArrayView.getSofaDataStream();
assertTrue(is != null);
i = 0;
while (is.read(dest) != -1) {
assertTrue(ByteBuffer.wrap(dest).getDouble() == doubleArrayFS.get(i++));
}
dest = new byte[1];
// is = remoteSofa.getSofaDataStream();
is = remoteView.getSofaDataStream();