diff options
| author | krasimir <krasimir@chalmers.se> | 2015-11-13 14:34:24 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2015-11-13 14:34:24 +0000 |
| commit | f6bb796276c912cb2b0323d360d59bffc41b8e0a (patch) | |
| tree | b50c1cba65423a41301164b9e003c134e55303db /src/runtime/java/org/grammaticalframework | |
| parent | 6011fbc033b95ed3e703a61cf1162f4d032ad4ca (diff) | |
added Java API for insertion of triples in the semantic graph
Diffstat (limited to 'src/runtime/java/org/grammaticalframework')
| -rw-r--r-- | src/runtime/java/org/grammaticalframework/sg/SG.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/runtime/java/org/grammaticalframework/sg/SG.java b/src/runtime/java/org/grammaticalframework/sg/SG.java index 631b38ff7..278dd8117 100644 --- a/src/runtime/java/org/grammaticalframework/sg/SG.java +++ b/src/runtime/java/org/grammaticalframework/sg/SG.java @@ -1,12 +1,40 @@ package org.grammaticalframework.sg; import java.io.Closeable; -import org.grammaticalframework.pgf.Expr; +import org.grammaticalframework.pgf.*; public class SG implements Closeable { - public static native SG openSG(String path); - public native void close(); - public native TripleResult queryTriple(Expr subj, Expr pred, Expr obj); + /** Opens a new database file */ + public static native SG openSG(String path) throws SGError; + + /** Closes an already opened database */ + public native void close() throws SGError; + + /** Reads a triple in the format <expr,expr,expr> and returns it as an array */ + public static native Expr[] readTriple(String s) throws PGFError; + + /** Simple triple queries. Each of the arguments subj, pred and obj + * could be null. In that case the argument is interpreted as a wild card. + * If one of the arguments is not null then only triples with matching values + * will be retrieved. + * + * @return An iterator over the matching triples + */ + public native TripleResult queryTriple(Expr subj, Expr pred, Expr obj) throws SGError; + + /** Start a new transaction */ + public native void beginTrans() throws SGError; + + /** Commits the transaction */ + public native void commit() throws SGError; + + /** Rollbacks all changes made in the current transaction */ + public native void rollback() throws SGError; + + /** Inserts a new triple. + * @return an unique id that identifies this triple in the database + */ + public native long insertTriple(Expr subj, Expr pred, Expr obj) throws SGError; ////////////////////////////////////////////////////////////////// // private stuff |
