added org.grammaticalframework.pgf.Expr.unStr

This commit is contained in:
Krasimir Angelov
2017-08-07 11:48:40 +02:00
parent 47a4218d21
commit ec4a11ce25
2 changed files with 18 additions and 0 deletions

View File

@@ -1412,6 +1412,19 @@ Java_org_grammaticalframework_pgf_Expr_unMeta(JNIEnv* env, jobject self)
return -1;
}
JNIEXPORT jstring JNICALL
Java_org_grammaticalframework_pgf_Expr_unStr(JNIEnv* env, jobject self)
{
PgfExpr expr = gu_variant_from_ptr(get_ref(env, self));
PgfLiteralStr* pstr = pgf_expr_unlit(expr, PGF_LITERAL_STR);
if (pstr != NULL) {
return gu2j_string(env, pstr->val);
}
return NULL;
}
JNIEXPORT jboolean JNICALL
Java_org_grammaticalframework_pgf_Expr_equals(JNIEnv* env, jobject self, jobject other)
{

View File

@@ -93,6 +93,11 @@ public class Expr implements Serializable {
* a meta variable, then it will return the variable's id.
* If this is not a meta variable then the result is -1. */
public native int unMeta();
/** If the method is called on an expression which is
* a string literal, then it will return the string value.
* If this is not a string literal then the result is null. */
public native String unStr();
/** Returns the expression as a string in the GF syntax */
public String toString() {