mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
Expr and ExprProb are now serializable objects
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
package org.grammaticalframework.pgf;
|
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 Pool pool;
|
||||||
private PGF gr;
|
private PGF gr;
|
||||||
private long ref;
|
private long ref;
|
||||||
@@ -18,4 +25,15 @@ public class Expr {
|
|||||||
public static native Expr readExpr(String s) throws PGFError;
|
public static native Expr readExpr(String s) throws PGFError;
|
||||||
|
|
||||||
private static native String showExpr(long ref);
|
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;
|
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 Expr expr;
|
||||||
private double prob;
|
private double prob;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user