use of org.apache.rya.reasoning.OwlClass in project incubator-rya by apache.
the class SchemaWritable method readFields.
@Override
public void readFields(DataInput in) throws IOException {
int size = in.readInt();
if (size < 1)
throw new Error("De-serializtion failed, count is less than one.");
byte[] bytes = new byte[size];
in.readFully(bytes);
// ObjectInputStream stream = new ObjectInputStream(new ByteArrayInputStream(bytes));
try (//
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final ValidatingObjectInputStream vois = new ValidatingObjectInputStream(bais)) // this is how you find classes that you missed in the vois.accept() list, below.
// { @Override protected void invalidClassNameFound(String className) throws java.io.InvalidClassException {
// System.out.println("vois.accept(" + className + ".class, ");};};
{
// this is a (hopefully) complete list of classes involved in a Schema to be serialized.
// if a useful class is missing, throws an InvalidClassException.
//
vois.accept(//
java.util.ArrayList.class, //
org.apache.rya.reasoning.OwlProperty.class, //
java.util.HashSet.class, //
org.apache.rya.reasoning.OwlClass.class, //
org.openrdf.model.impl.URIImpl.class, org.openrdf.model.impl.BNodeImpl.class);
try {
Iterable<?> propList = (Iterable<?>) vois.readObject();
Iterable<?> classList = (Iterable<?>) vois.readObject();
for (Object p : propList) {
OwlProperty prop = (OwlProperty) p;
properties.put(prop.getURI(), prop);
}
for (Object c : classList) {
OwlClass owlClass = (OwlClass) c;
classes.put(owlClass.getURI(), owlClass);
}
} catch (ClassNotFoundException e) {
throw new Error("While reading a schema object.");
}
}
}
use of org.apache.rya.reasoning.OwlClass in project incubator-rya by apache.
the class SchemaWritable method write.
@Override
public void write(DataOutput out) throws IOException {
ArrayList<OwlProperty> propList = new ArrayList<>(properties.values());
ArrayList<OwlClass> classList = new ArrayList<>(classes.values());
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ObjectOutputStream stream = new ObjectOutputStream(bytes);
stream.writeObject(propList);
stream.writeObject(classList);
byte[] arr = bytes.toByteArray();
stream.close();
out.writeInt(arr.length);
out.write(arr);
}
Aggregations