Expr and ExprProb are now serializable objects

This commit is contained in:
kr.angelov
2014-04-07 12:52:51 +00:00
parent e4555d2dce
commit baef6eee90
2 changed files with 24 additions and 2 deletions

View File

@@ -1,6 +1,13 @@
package org.grammaticalframework.pgf;
public class Expr {
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class Expr implements Serializable {
private static final long serialVersionUID = 1148602474802492674L;
private Pool pool;
private PGF gr;
private long ref;
@@ -18,4 +25,15 @@ public class Expr {
public static native Expr readExpr(String s) throws PGFError;
private static native String showExpr(long ref);
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeObject(showExpr(ref));
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
Expr e = readExpr((String) in.readObject());
pool = e.pool;
gr = e.gr;
ref = e.ref;
}
}

View File

@@ -1,6 +1,10 @@
package org.grammaticalframework.pgf;
public class ExprProb {
import java.io.Serializable;
public class ExprProb implements Serializable {
private static final long serialVersionUID = -3112602244416576742L;
private Expr expr;
private double prob;