aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Pitschke2012-06-27 09:39:50 (EDT)
committerSteve Pitschke2012-06-27 09:39:50 (EDT)
commitcfbdb6e4abeee0b9ba52020da1d7c2638f399024 (patch)
treeca87165b6d4776a8ae90072bb0b8d56f651d390d
parent6435ecf36f5da7ddc1e7d250554d7fe54121c8bf (diff)
downloadorg.eclipse.lyo.core-cfbdb6e4abeee0b9ba52020da1d7c2638f399024.zip
org.eclipse.lyo.core-cfbdb6e4abeee0b9ba52020da1d7c2638f399024.tar.gz
org.eclipse.lyo.core-cfbdb6e4abeee0b9ba52020da1d7c2638f399024.tar.bz2
Bug 383469: Finish debugging of typed values and langed stringsrefs/changes/36/6536/1
Change-Id: Ic9a89196ec09be91ebabc378f09c9bb82ef01a8a Signed-off-by: Steve Pitschke <pitschke@us.ibm.com>
-rw-r--r--org.eclipse.lyo.core.query/src/main/antlr3/org/eclipse/lyo/core/query/OslcWhere.g8
-rw-r--r--org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/LangedStringValueInvocationHandler.java11
-rw-r--r--org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/TypedValueInvocationHandler.java18
-rw-r--r--org.eclipse.lyo.core.query/src/test/java/org/eclipse/lyo/core/query/test/BasicWhereTest.java5
4 files changed, 33 insertions, 9 deletions
diff --git a/org.eclipse.lyo.core.query/src/main/antlr3/org/eclipse/lyo/core/query/OslcWhere.g b/org.eclipse.lyo.core.query/src/main/antlr3/org/eclipse/lyo/core/query/OslcWhere.g
index e522e32..28a7793 100644
--- a/org.eclipse.lyo.core.query/src/main/antlr3/org/eclipse/lyo/core/query/OslcWhere.g
+++ b/org.eclipse.lyo.core.query/src/main/antlr3/org/eclipse/lyo/core/query/OslcWhere.g
@@ -148,7 +148,13 @@ IRI_REF
LANGTAG
- : '@' PN_CHARS_BASE+ (MINUS (PN_CHARS_BASE DIGIT)+)?
+ : '@' ALPHA_CHARS+ (MINUS (DIGIT | ALPHA_CHARS)+)*
+ ;
+
+fragment
+ALPHA_CHARS
+ : 'a'..'z'
+ | 'A'..'Z'
;
BOOLEAN
diff --git a/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/LangedStringValueInvocationHandler.java b/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/LangedStringValueInvocationHandler.java
index 7debee1..c1a57cb 100644
--- a/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/LangedStringValueInvocationHandler.java
+++ b/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/LangedStringValueInvocationHandler.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import org.antlr.runtime.tree.CommonTree;
import org.eclipse.lyo.core.query.LangedStringValue;
+import org.eclipse.lyo.core.query.TypedValue;
import org.eclipse.lyo.core.query.Value.Type;
/**
@@ -48,7 +49,8 @@ class LangedStringValueInvocationHandler extends ValueInvocationHandler
boolean isValue = methodName.equals("value");
if (! isValue &&
- ! methodName.equals("langTag")) {
+ ! methodName.equals("langTag")&&
+ ! methodName.equals("toString")) {
super.invoke(proxy, method, args);
}
@@ -69,7 +71,12 @@ class LangedStringValueInvocationHandler extends ValueInvocationHandler
langTag = ((CommonTree)tree.getChild(1)).getText().substring(1);
}
- return langTag;
+ if (methodName.equals("langTag")) {
+ return langTag;
+ }
+
+ return '"' + ((LangedStringValue)proxy).value() + "\"@" +
+ ((LangedStringValue)proxy).langTag();
}
private String value = null;
diff --git a/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/TypedValueInvocationHandler.java b/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/TypedValueInvocationHandler.java
index d004aef..c4aa1e8 100644
--- a/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/TypedValueInvocationHandler.java
+++ b/org.eclipse.lyo.core.query/src/main/java/org/eclipse/lyo/core/query/impl/TypedValueInvocationHandler.java
@@ -55,7 +55,8 @@ class TypedValueInvocationHandler extends ValueInvocationHandler
boolean isValue = methodName.equals("value");
if (! isValue &&
- ! methodName.equals("prefixedName")) {
+ ! methodName.equals("prefixedName") &&
+ ! methodName.equals("toString")) {
super.invoke(proxy, method, args);
}
@@ -63,7 +64,7 @@ class TypedValueInvocationHandler extends ValueInvocationHandler
if (value == null) {
- String rawValue = ((CommonTree)tree.getChild(0)).getToken().toString();
+ String rawValue = ((CommonTree)tree.getChild(0)).getText();
// XXX - determine if need to unescape
value = rawValue.substring(1, rawValue.length() - 1);
@@ -74,7 +75,9 @@ class TypedValueInvocationHandler extends ValueInvocationHandler
if (prefixedName == null) {
- String rawPName = tree.getChild(1).toString();
+ String rawPName = tree.getChild(1).getText();
+
+ rawPName = rawPName.substring(1, rawPName.length() - 1);
prefixedName = new PName();
@@ -90,8 +93,13 @@ class TypedValueInvocationHandler extends ValueInvocationHandler
prefixedName.local = rawPName.substring(colon + 1);
}
}
-
- return prefixedName;
+
+ if (methodName.equals("prefixedName")) {
+ return prefixedName;
+ }
+
+ return '"' + ((TypedValue)proxy).value() + "\"^^\"" +
+ ((TypedValue)proxy).prefixedName() + '"';
}
private final Map<String, String> prefixMap;
diff --git a/org.eclipse.lyo.core.query/src/test/java/org/eclipse/lyo/core/query/test/BasicWhereTest.java b/org.eclipse.lyo.core.query/src/test/java/org/eclipse/lyo/core/query/test/BasicWhereTest.java
index c270112..835aa54 100644
--- a/org.eclipse.lyo.core.query/src/test/java/org/eclipse/lyo/core/query/test/BasicWhereTest.java
+++ b/org.eclipse.lyo.core.query/src/test/java/org/eclipse/lyo/core/query/test/BasicWhereTest.java
@@ -47,13 +47,16 @@ public class BasicWhereTest
prefixMap.put("qm", "http://qm.example.com/ns");
prefixMap.put("olsc", "http://open-services.net/ns/core#");
+ prefixMap.put("xs", "http://www.w3.org/2001/XMLSchema");
String[] expressions = {
"qm:testcase=<http://example.com/tests/31459>",
"qm:duration>=10.4",
"oslc:create!=\"Bob\" and qm:verified!=true",
"qm:state in [\"Done\",\"Open\"]",
- "oslc:verified_by{oslc:owner=\"Steve\" and qm:duration=-47.0} and oslc:description=\"very hairy expression\""
+ "oslc:verified_by{oslc:owner=\"Steve\" and qm:duration=-47.0} and oslc:description=\"very hairy expression\"",
+ "qm:submitted<\"2011-10-10T07:00:00Z\"^^\"xs:dateTime\"",
+ "oslc:label>\"The End\"@en-US"
};
for (String expression : expressions) {