forked from GitHub/gf-core
Expr and ExprProb are now serializable objects
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user