You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/11/05 11:52:16 UTC
[11/52] [partial] Reverting the erroneous merge by Sebastian
according to the instructions in INFRA-6876
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/ShortTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/ShortTransformer.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/ShortTransformer.java
index 66fcfa1..352f6a1 100644
--- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/ShortTransformer.java
+++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/ShortTransformer.java
@@ -17,7 +17,7 @@
*/
package org.apache.marmotta.ldpath.model.transformers;
-import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
import java.util.Map;
@@ -25,7 +25,7 @@ import java.util.Map;
public class ShortTransformer<Node> implements NodeTransformer<Short,Node> {
@Override
- public Short transform(NodeBackend<Node> backend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
+ public Short transform(RDFBackend<Node> backend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
if(backend.isLiteral(node)) {
return backend.decimalValue(node).shortValueExact();
} else {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/StringTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/StringTransformer.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/StringTransformer.java
index addb444..7f6e365 100644
--- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/StringTransformer.java
+++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/StringTransformer.java
@@ -17,7 +17,7 @@
*/
package org.apache.marmotta.ldpath.model.transformers;
-import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
import java.util.Map;
@@ -35,11 +35,13 @@ public class StringTransformer<Node> implements NodeTransformer<String,Node> {
* the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
* carrying out the transformation.
*
+ *
+ * @param backend
* @param node
* @return
*/
@Override
- public String transform(NodeBackend<Node> backend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
+ public String transform(RDFBackend<Node> backend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
return backend.stringValue(node);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/TimeTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/TimeTransformer.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/TimeTransformer.java
index 887c0eb..c6aeb48 100644
--- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/TimeTransformer.java
+++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/transformers/TimeTransformer.java
@@ -21,7 +21,7 @@ package org.apache.marmotta.ldpath.model.transformers;
import java.util.Date;
import java.util.Map;
-import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
/**
@@ -36,11 +36,13 @@ public class TimeTransformer<Node> implements NodeTransformer<Date,Node> {
* the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
* carrying out the transformation.
*
+ *
+ * @param rdfBackend
* @param node
* @return
*/
@Override
- public Date transform(NodeBackend<Node> rdfBackend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
+ public Date transform(RDFBackend<Node> rdfBackend, Node node, Map<String, String> configuration) throws IllegalArgumentException {
if(rdfBackend.isLiteral(node)) {
return rdfBackend.timeValue(node);
} else {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/util/Collections.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/util/Collections.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/util/Collections.java
index 8f2abea..651c771 100644
--- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/util/Collections.java
+++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/util/Collections.java
@@ -34,6 +34,7 @@ public class Collections {
* @param lists
* @return
*/
+ @SafeVarargs
public static <T> List<T> concat(final Collection<T>... lists) {
List<T> result = new ArrayList<T>();
for(Collection<T> list : lists) {
@@ -46,6 +47,7 @@ public class Collections {
* @param lists the array with the lists
* @return the plain iterator over all elements of the lists
*/
+ @SafeVarargs
public static <T> Iterator<T> iterator(final Collection<T>...lists){
return iterator(0,lists);
}
@@ -57,6 +59,7 @@ public class Collections {
* @return the plain iterator over all elements of the lists starting from
* index offset
*/
+ @SafeVarargs
public static <T> Iterator<T> iterator(final int offset,final Collection<T>...lists){
if(offset < 0){
throw new IllegalArgumentException("The parsed Offest MUST NOT be < 0!");
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
index c91a6a9..bd71bb5 100644
--- a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
+++ b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
@@ -26,7 +26,7 @@ options
// DEBUG_LOOKAHEAD=true;
}
-PARSER_BEGIN(RdfPathParser)
+PARSER_BEGIN(LdPathParser)
package org.apache.marmotta.ldpath.parser;
import org.apache.marmotta.ldpath.model.Constants;
@@ -47,6 +47,7 @@ import org.apache.marmotta.ldpath.model.transformers.*;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -64,12 +65,12 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("all")
-public class RdfPathParser<Node> {
+public class LdPathParser<Node> {
private enum Mode { RULE, SELECTOR, TEST, PROGRAM, PREFIX };
- private static final Logger log = LoggerFactory.getLogger(RdfPathParser.class);
+ private static final Logger log = LoggerFactory.getLogger(LdPathParser.class);
/**
* A map mapping from namespace prefix to namespace URI
@@ -82,11 +83,11 @@ public class RdfPathParser<Node> {
private Mode mode = Mode.PROGRAM;
- public RdfPathParser(NodeBackend<Node> backend, Reader in) {
+ public LdPathParser(NodeBackend<Node> backend, Reader in) {
this(backend,null,in);
}
- public RdfPathParser(NodeBackend<Node> backend, Configuration config, Reader in) {
+ public LdPathParser(NodeBackend<Node> backend, Configuration config, Reader in) {
this(in);
this.backend = backend;
if(config == null) {
@@ -98,11 +99,11 @@ public class RdfPathParser<Node> {
initialise();
}
- public RdfPathParser(NodeBackend<Node> backend, InputStream in) {
+ public LdPathParser(NodeBackend<Node> backend, InputStream in) {
this(backend,null,in);
}
- public RdfPathParser(NodeBackend<Node> backend, Configuration config, InputStream in) {
+ public LdPathParser(NodeBackend<Node> backend, Configuration config, InputStream in) {
this(in);
this.backend = backend;
if(config == null) {
@@ -114,11 +115,11 @@ public class RdfPathParser<Node> {
initialise();
}
- public RdfPathParser(NodeBackend<Node> backend, InputStream in, String encoding) {
+ public LdPathParser(NodeBackend<Node> backend, InputStream in, String encoding) {
this(backend,null,in,encoding);
}
- public RdfPathParser(NodeBackend<Node> backend, Configuration config, InputStream in, String encoding) {
+ public LdPathParser(NodeBackend<Node> backend, Configuration config, InputStream in, String encoding) {
this(in,encoding);
this.backend = backend;
if(config == null) {
@@ -211,11 +212,16 @@ public class RdfPathParser<Node> {
}
}
+ public Node resolveURI(URI uri) {
return backend.createURI(uri.toString());
+ }
- public Node resolveResource(String uri) {
+ public Node resolveResource(String uri) throws ParseException {
return backend.createURI(uri);
}
+ public Node resolveResource(String prefix, String local) throws ParseException {
+ return resolveResource(resolveNamespace(prefix)+local);
}
+
public String resolveNamespace(String prefix) throws ParseException {
String uri = namespaces.get(prefix);
@@ -242,6 +248,14 @@ public class RdfPathParser<Node> {
}
}
+ public NodeTransformer<?,Node> getTransformer(URI type) throws ParseException {
+ return getTransformer(type.toString());
+ }
+
+ public NodeTransformer<?,Node> getTransformer(Node node) throws ParseException {
+ return getTransformer(backend.stringValue(node));
+ }
+
public NodeTransformer<?,Node> getTransformer(String uri) throws ParseException {
if(xsdNodeTransformerMap.get(uri) != null) {
return xsdNodeTransformerMap.get(uri);
@@ -289,7 +303,7 @@ public class RdfPathParser<Node> {
private Map<String, SelectorFunction<Node>> xsdNodeFunctionMap;
- private Map<String, TestFunction<Node>> xsdNodeTestMap;
+ private Map<String, TestFunction<Node>> xsdNodeTestMap;
private void initFunctionMappings() {
Map<String, SelectorFunction<Node>> functionMap = new HashMap<String, SelectorFunction<Node>>();
@@ -333,7 +347,7 @@ public class RdfPathParser<Node> {
}
}
-PARSER_END(RdfPathParser)
+PARSER_END(LdPathParser)
SKIP :
{
@@ -374,20 +388,49 @@ MORE:
}
+TOKEN : /* LDPATH */
+{
+ < COMMA: "," > |
+ < SCOLON: ";" > |
+ < COLON: ":" > |
+ < DCOLON: "::" > |
+ < ASSIGN: "=" > |
+ < K_PREFIX: "@prefix" > |
+ < K_FILTER: "@filter" > |
+ < K_BOOST: "@boost" > |
+ < K_GRAPH: "@graph" >
+}
TOKEN : /* OPERATORS */
{
+ < SELF: "." > |
< AND: "&" > |
< OR: "|" > |
+ < P_SEP:"/" > |
+ < PLUS: "+" > |
+ < STAR: "*" > |
< NOT: "!" > |
+ < INVERSE: "^" > |
< IS: "is" > |
< IS_A: "is-a" > |
+ < FUNC: "fn:" > |
< TYPE: "^^" > |
< LANG: "@" >
}
+TOKEN : /* BRACKETS */
+{
+ < B_RO: "(" > |
+ < B_RC: ")" > |
+ < B_SO: "[" > |
+ < B_SC: "]" > |
+ < B_CO: "{" > |
+ < B_CC: "}" > |
+ < B_XO: "<" > |
+ < B_XC: ">" >
+}
TOKEN :
{
- < URI: ["a"-"z","A"-"Z"](["a"-"z","A"-"Z","0"-"9","+","-","."])* "://" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])+ ("#" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])*)? | "#" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])+> |
+ < URI: "<" (~[ ">","<", "\"", "{", "}", "^", "\\", "|", "`", "\u0000"-"\u0020"])+ ">" > |
< IDENTIFIER: ["a"-"z","A"-"Z","0"-"9","_"](["a"-"z","A"-"Z","0"-"9","_","'","-", "."])* > |
< #URICHAR: ["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"] >
}
@@ -415,9 +458,9 @@ Entry<String, String> Namespace() :
}
{
(
- "@prefix" id = <IDENTIFIER> ":" "<" uri = <URI> ">" (";")? {
+ <K_PREFIX> id = <IDENTIFIER> <COLON> uri = <URI> (<SCOLON> )? {
}
- ) { return new Namespace(id.image, uri.image); }
+ ) { return new Namespace(id.image, uri.image.substring(1,uri.image.length()-1)); }
}
Program Program() :
@@ -427,6 +470,7 @@ Program Program() :
Map<String, String> nss = null;
FieldMapping<?,Node> rule;
NodeSelector<Node> boostSelector;
+ LinkedList<Node> graphs;
}
{
(
@@ -439,15 +483,21 @@ Program Program() :
)?
(
- "@filter" filter = NodeTest() ";" {
+ <K_GRAPH> graphs = UriList() <SCOLON> {
+ program.setGraphs(graphs);
+ }
+ )?
+
+ (
+ <K_FILTER> filter = NodeTest() <SCOLON> {
program.setFilter(filter);
}
)?
(
- "@boost" boostSelector = Selector() ";" {
+ <K_BOOST> boostSelector = Selector() <SCOLON> {
NodeTransformer transformer = getTransformer(Program.DOCUMENT_BOOST_TYPE);
- FieldMapping booster = new FieldMapping("@boost", Program.DOCUMENT_BOOST_TYPE, boostSelector, transformer, null);
+ FieldMapping booster = new FieldMapping("@boost", java.net.URI.create(Program.DOCUMENT_BOOST_TYPE), boostSelector, transformer, null);
program.setBooster(booster);
}
)?
@@ -464,18 +514,32 @@ Program Program() :
}
}
+LinkedList<Node> UriList() :
+{
+ LinkedList<Node> rest = null;
+ URI uri;
+}
+{
+ uri = Uri() ( <COMMA> rest = UriList() )?
+ {
+ if (rest == null) rest = new LinkedList<Node>();
+ rest.addFirst(resolveURI(uri));
+ return rest;
+ }
+}
+
FieldMapping Rule() :
{
FieldMapping<?,Node> rule;
Token name;
- String uri;
- String type = null;
+ URI uri;
+ URI type = null;
NodeSelector<Node> selector;
NodeTransformer<?,Node> transformer;
Map<String, String> conf = null;
}
{
- name = <IDENTIFIER> "=" selector = Selector() ("::" type = Uri())? ("(" conf = FieldConfig() ")")? ";" {
+ name = <IDENTIFIER> <ASSIGN> selector = Selector() (<DCOLON> type = Uri())? (<B_RO> conf = FieldConfig() <B_RC>)? <SCOLON> {
if(type != null) {
transformer = getTransformer(type);
} else {
@@ -487,7 +551,7 @@ FieldMapping Rule() :
rule = new FieldMapping(name.image,type,selector,transformer, conf);
return rule;
}
-| uri = Uri() "=" selector = Selector() ("::" type = Uri())? ("(" conf = FieldConfig() ")")? ";" {
+| uri = Uri() <ASSIGN> selector = Selector() (<DCOLON> type = Uri())? (<B_RO> conf = FieldConfig() <B_RC>)? <SCOLON> {
if(type != null) {
transformer = getTransformer(type);
} else {
@@ -499,7 +563,7 @@ FieldMapping Rule() :
rule = new FieldMapping(uri,type,selector,transformer, conf);
return rule;
}
-| selector = Selector() ("::" type = Uri())? ("(" conf = FieldConfig() ")")? (";")? {
+| selector = Selector() (<DCOLON> type = Uri())? (<B_RO> conf = FieldConfig() <B_RC>)? (<SCOLON>)? {
if(type != null) {
transformer = getTransformer(type);
} else {
@@ -531,7 +595,7 @@ Map<String,String> FieldConfig() : {
Map<String,String> more = null;
}
{
- ( key = <IDENTIFIER> "=" val = ConfVal() ("," more = FieldConfig() )? )? {
+ ( key = <IDENTIFIER> <ASSIGN> val = ConfVal() ( <COMMA> more = FieldConfig() )? )? {
if (key == null || val == null) return null;
conf.put(key.image, val);
if (more != null) {
@@ -549,16 +613,16 @@ String ConfVal() : {
| id = <IDENTIFIER> { return id.image; }
}
-String Uri() : {
+URI Uri() : {
Token uri, prefix, localName;
}
{
- "<" uri = <URI> ">" {
- return uri.image;
+ uri = <URI> {
+ return java.net.URI.create(uri.image.substring(1,uri.image.length()-1));
}
| prefix = <IDENTIFIER> ":" localName = <IDENTIFIER> {
- return resolveNamespace(prefix.image)+localName.image;
+ return java.net.URI.create(resolveNamespace(prefix.image)+localName.image);
}
}
@@ -678,7 +742,7 @@ NodeSelector SelfSelector() :
{
}
{
- "." { return new SelfSelector(); }
+ <SELF> { return new SelfSelector(); }
}
NodeSelector GroupedSelector() :
@@ -687,9 +751,9 @@ NodeSelector GroupedSelector() :
}
{
/* Other selector enclosed in braces */
- "(" result = Selector() ")"
+ <B_RO> result = Selector() <B_RC>
{
- return result;
+ return new GroupedSelector(result);
}
}
@@ -700,12 +764,12 @@ RecursivePathSelector RecursivePathSelector() :
NodeSelector delegate = null;
}
{
- "(" delegate = Selector() ")" "+"
+ <B_RO> delegate = Selector() <B_RC> <PLUS>
{
result = RecursivePathSelector.getPathSelectorPlused(delegate);
return result;
} |
- "(" delegate = Selector() ")" "*"
+ <B_RO> delegate = Selector() <B_RC> <STAR>
{
result = RecursivePathSelector.getPathSelectorStared(delegate);
return result;
@@ -719,7 +783,7 @@ PathSelector PathSelector() :
NodeSelector right = null;
}
{
- left = AtomicOrTestingSelector() "/" right = AtomicOrTestingOrPathSelector()
+ left = AtomicOrTestingSelector() <P_SEP> right = AtomicOrTestingOrPathSelector()
{
result = new PathSelector(left,right);
return result;
@@ -733,7 +797,7 @@ IntersectionSelector IntersectionSelector() :
NodeSelector right = null;
}
{
- left = AtomicOrTestingOrPathSelector() "&" right = Selector()
+ left = AtomicOrTestingOrPathSelector() <AND> right = Selector()
{
result = new IntersectionSelector(left,right);
return result;
@@ -747,7 +811,7 @@ UnionSelector UnionSelector() :
NodeSelector right = null;
}
{
- left = AtomicOrTestingOrPathSelector() "|" right = Selector()
+ left = AtomicOrTestingOrPathSelector() <OR> right = Selector()
{
result = new UnionSelector(left,right);
return result;
@@ -761,7 +825,7 @@ TestingSelector TestingSelector() :
NodeTest test = null;
}
{
- delegate = AtomicSelector() "[" test = NodeTest() "]" {
+ delegate = AtomicSelector() <B_SO> test = NodeTest() <B_SC> {
result = new TestingSelector(delegate,test);
return result;
}
@@ -770,13 +834,11 @@ TestingSelector TestingSelector() :
ReversePropertySelector ReversePropertySelector() :
{
ReversePropertySelector result = null;
- Node property;
- String uri;
+ URI uri;
}
{
- "^" uri = Uri() {
- property = resolveResource(uri);
- result = new ReversePropertySelector(property);
+ <INVERSE> uri = Uri() {
+ result = new ReversePropertySelector(resolveURI(uri));
return result;
}
}
@@ -784,13 +846,11 @@ ReversePropertySelector ReversePropertySelector() :
PropertySelector PropertySelector() :
{
PropertySelector result = null;
- Node property;
- String uri;
+ URI uri;
}
{
uri = Uri() {
- property = resolveResource(uri);
- result = new PropertySelector(property);
+ result = new PropertySelector(resolveURI(uri));
return result;
}
}
@@ -800,7 +860,7 @@ WildcardSelector WildcardSelector() :
WildcardSelector result = null;
}
{
- "*" {
+ <STAR> {
result = new WildcardSelector();
return result;
}
@@ -817,22 +877,22 @@ FunctionSelector FunctionSelector() :
{
/* Function-Calls without arguments can skip parenthesis */
/* Does not work... why?
- "fn:" fName = <IDENTIFIER> {
+ <FUNC> fName = <IDENTIFIER> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionSelector(getFunction(uri),Collections.emptyList());
return result;
} | */
/* Functions do not need to have arguments */
- "fn:" fName = <IDENTIFIER> "(" ")" {
+ <FUNC> fName = <IDENTIFIER> <B_RO> <B_RC> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionSelector(getFunction(uri),Collections.emptyList());
return result;
} |
/* Sometimes arguments are required */
- "fn:" fName = <IDENTIFIER> "("
+ <FUNC> fName = <IDENTIFIER> <B_RO>
argument = Selector() { arguments.add(argument); }
- ( "," argument = Selector() { arguments.add(argument); } )*
- ")" {
+ ( <COMMA> argument = Selector() { arguments.add(argument); } )*
+ <B_RC> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionSelector(getFunction(uri),arguments);
return result;
@@ -876,7 +936,7 @@ NodeTest GroupedTest() :
NodeTest delegate;
}
{
- "(" delegate = NodeTest() ")" {
+ <B_RO> delegate = NodeTest() <B_RC> {
return delegate;
}
}
@@ -889,7 +949,7 @@ NodeTest AtomicNodeTest() :
(
result = LiteralLanguageTest()
| result = LiteralTypeTest()
- | result = TypeTest()
+ | result = IsATest()
| result = PathEqualityTest()
| result = FunctionTest()
| result = PathTest()
@@ -911,20 +971,20 @@ FunctionTest FunctionTest() :
(
/* Function-Calls without arguments can skip parenthesis */
/* Does not work... why?
- "fn:" fName = <IDENTIFIER> {
+ <FUNC> fName = <IDENTIFIER> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionSelector(getTestFunction(uri),Collections.emptyList());
} | */
/* Functions do not need to have arguments */
- "fn:" fName = <IDENTIFIER> "(" ")" {
+ <FUNC> fName = <IDENTIFIER> <B_RO> <B_RC> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionTest(getTestFunction(uri),Collections.emptyList());
} |
/* Sometimes arguments are required */
- "fn:" fName = <IDENTIFIER> "("
+ <FUNC> fName = <IDENTIFIER> <B_RO>
argument = Selector() { arguments.add(argument); }
- ( "," argument = Selector() { arguments.add(argument); } )*
- ")" {
+ ( <COMMA> argument = Selector() { arguments.add(argument); } )*
+ <B_RC> {
uri = namespaces.get("fn") + fName.image;
result = new FunctionTest(getTestFunction(uri),arguments);
}
@@ -939,17 +999,17 @@ LiteralLanguageTest LiteralLanguageTest():
Token lang;
}
{
- "@" lang = <IDENTIFIER> {
+ <LANG> lang = <IDENTIFIER> {
return new LiteralLanguageTest(lang.image);
}
}
LiteralTypeTest LiteralTypeTest():
{
- String type;
+ URI type;
}
{
- "^^" type = Uri() {
+ <TYPE> type = Uri() {
return new LiteralTypeTest(type);
}
}
@@ -959,18 +1019,18 @@ NotTest NotTest() :
NodeTest delegate;
}
{
- "!" delegate = NodeTest() {
+ <NOT> delegate = NodeTest() {
return new NotTest(delegate);
}
}
-PathEqualityTest TypeTest() :
+IsATest IsATest() :
{
Node node;
}
{
<IS_A> node = Node() {
- return new PathEqualityTest(new PropertySelector(resolveResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")), node);
+ return new IsATest(resolveResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), node);
}
}
@@ -980,7 +1040,7 @@ AndTest AndTest():
NodeTest left, right;
}
{
- left = AtomicNodeTest() "&" right = NodeTest() {
+ left = AtomicNodeTest() <AND> right = NodeTest() {
return new AndTest(left,right);
}
}
@@ -990,7 +1050,7 @@ OrTest OrTest():
NodeTest left, right;
}
{
- left = AtomicNodeTest() "|" right = NodeTest() {
+ left = AtomicNodeTest() <OR> right = NodeTest() {
return new OrTest(left,right);
}
}
@@ -1001,7 +1061,7 @@ PathEqualityTest PathEqualityTest():
Node node;
}
{
- path = Selector() "is" node = Node() {
+ path = Selector() <IS> node = Node() {
return new PathEqualityTest(path,node);
}
}
@@ -1009,21 +1069,17 @@ PathEqualityTest PathEqualityTest():
Node Node():
{
- String uri, type = null;
+ URI uri, type = null;
Token literal, language;
}
{
uri = Uri() {
- return resolveResource(uri);
+ return resolveURI(uri);
}
-| literal = <STRLIT> ("^^" type = Uri() )? {
- try {
- return backend.createLiteral(literal.image.substring(1, literal.image.length()-1),null,type == null ? null : new URI(type));
- } catch(java.net.URISyntaxException ex) {
- throw new ParseException("could not parse type URI "+type+": "+ex.getMessage());
- }
+| literal = <STRLIT> (<TYPE> type = Uri() )? {
+ return backend.createLiteral(literal.image.substring(1, literal.image.length()-1),null,type);
}
-| literal = <STRLIT> "@" language = <IDENTIFIER> {
+| literal = <STRLIT> <LANG> language = <IDENTIFIER> {
return backend.createLiteral(literal.image.substring(1, literal.image.length()-1),new Locale(language.image),null);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/BinaryNumericTestFunctionsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/BinaryNumericTestFunctionsTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/BinaryNumericTestFunctionsTest.java
index 5047873..948d5c4 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/BinaryNumericTestFunctionsTest.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/BinaryNumericTestFunctionsTest.java
@@ -29,7 +29,7 @@ import java.util.List;
import org.apache.marmotta.ldpath.api.selectors.NodeSelector;
import org.apache.marmotta.ldpath.parser.ParseException;
-import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.apache.marmotta.ldpath.parser.LdPathParser;
import org.apache.marmotta.ldpath.test.AbstractTestBase;
import org.junit.Before;
import org.junit.Test;
@@ -70,7 +70,7 @@ public class BinaryNumericTestFunctionsTest extends AbstractTestBase {
@Before
public void loadData() throws RepositoryException, RDFParseException, IOException {
- super.loadData("test-data.n3", RDFFormat.N3);
+ super.loadData("/ldpath/test-data.n3", RDFFormat.N3);
}
@Test
@@ -96,7 +96,7 @@ public class BinaryNumericTestFunctionsTest extends AbstractTestBase {
}
- final RdfPathParser<Value> parser = createParserFromString("ex:hasItem[" + fkt + "(foo:left, foo:right)]");
+ final LdPathParser<Value> parser = createParserFromString("ex:hasItem[" + fkt + "(foo:left, foo:right)]");
final NodeSelector<Value> sel = parser.parseSelector(NSS);
final Collection<Value> result = sel.select(backend, start, null, null);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/FunctionsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/FunctionsTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/FunctionsTest.java
index 5ee947e..7df1621 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/FunctionsTest.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/model/functions/FunctionsTest.java
@@ -29,7 +29,7 @@ import java.util.Collection;
import org.apache.marmotta.ldpath.api.selectors.NodeSelector;
import org.apache.marmotta.ldpath.model.fields.FieldMapping;
import org.apache.marmotta.ldpath.parser.ParseException;
-import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.apache.marmotta.ldpath.parser.LdPathParser;
import org.apache.marmotta.ldpath.test.AbstractTestBase;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@@ -47,13 +47,13 @@ public class FunctionsTest extends AbstractTestBase {
@Before
public void loadData() throws RepositoryException, RDFParseException, IOException {
- loadData("test-data.n3", RDFFormat.N3);
+ loadData("/ldpath/test-data.n3", RDFFormat.N3);
}
@Test
public void testConcat() throws ParseException {
- RdfPathParser<Value> parser = createParserFromString("fn:concat(foo:title, \" \", foo:subtitle) :: xsd:string; ");
+ LdPathParser<Value> parser = createParserFromString("fn:concat(foo:title, \" \", foo:subtitle) :: xsd:string; ");
final URI context = repository.getValueFactory().createURI("http://www.example.com/1");
final FieldMapping<Object, Value> field = parser.parseRule(NSS);
@@ -67,7 +67,7 @@ public class FunctionsTest extends AbstractTestBase {
final URI ctx1 = repository.getValueFactory().createURI("http://www.example.com/1");
final URI ctx2 = repository.getValueFactory().createURI("http://www.example.com/2");
- RdfPathParser<Value> parser = createParserFromString("fn:first(foo:not_valid, foo:title, foo:subtitle, foo:not_valid2) :: xsd:string; ");
+ LdPathParser<Value> parser = createParserFromString("fn:first(foo:not_valid, foo:title, foo:subtitle, foo:not_valid2) :: xsd:string; ");
final FieldMapping<Object, Value> field = parser.parseRule(NSS);
final Collection<Object> result = field.getValues(backend, ctx1);
@@ -84,7 +84,7 @@ public class FunctionsTest extends AbstractTestBase {
final URI ctx1 = repository.getValueFactory().createURI("http://www.example.com/1");
final URI ctx2 = repository.getValueFactory().createURI("http://www.example.com/2");
- RdfPathParser<Value> parser = createParserFromString("fn:first(foo:i) :: xsd:int; ");
+ LdPathParser<Value> parser = createParserFromString("fn:first(foo:i) :: xsd:int; ");
final FieldMapping<Object, Value> field = parser.parseRule(NSS);
final Collection<Object> result = field.getValues(backend, ctx1);
@@ -101,7 +101,7 @@ public class FunctionsTest extends AbstractTestBase {
final URI ctx1 = repository.getValueFactory().createURI("http://www.example.com/1");
final URI ctx2 = repository.getValueFactory().createURI("http://www.example.com/2");
- RdfPathParser<Value> parser = createParserFromString("fn:last(foo:not_valid, foo:title, foo:subtitle, foo:not_valid2) :: xsd:string; ");
+ LdPathParser<Value> parser = createParserFromString("fn:last(foo:not_valid, foo:title, foo:subtitle, foo:not_valid2) :: xsd:string; ");
final FieldMapping<Object, Value> field = parser.parseRule(NSS);
final Collection<Object> result = field.getValues(backend, ctx1);
@@ -118,7 +118,7 @@ public class FunctionsTest extends AbstractTestBase {
final URI ctx1 = repository.getValueFactory().createURI("http://www.example.com/1");
final URI ctx2 = repository.getValueFactory().createURI("http://www.example.com/2");
- RdfPathParser<Value> parser = createParserFromString("fn:last(foo:i, ex:not_here) :: xsd:int; ");
+ LdPathParser<Value> parser = createParserFromString("fn:last(foo:i, ex:not_here) :: xsd:int; ");
final FieldMapping<Object, Value> field = parser.parseRule(NSS);
final Collection<Object> result = field.getValues(backend, ctx1);
@@ -136,14 +136,14 @@ public class FunctionsTest extends AbstractTestBase {
final URI ex1 = repository.getValueFactory().createURI("http://www.example.com/1");
final URI ex2 = repository.getValueFactory().createURI("http://www.example.com/2");
- final RdfPathParser<Value> parser = createParserFromString("ex:hasItem[fn:eq(foo:i, foo:j)]");
+ final LdPathParser<Value> parser = createParserFromString("ex:hasItem[fn:eq(foo:i, foo:j)]");
final NodeSelector<Value> sel = parser.parseSelector(NSS);
final Collection<Value> result = sel.select(backend, start, null, null);
assertEquals(1, result.size());
assertThat(result, allOf(hasItem(ex2), not(hasItem(ex1))));
- final RdfPathParser<Value> parseri = createParserFromString("ex:hasItem[! fn:eq(foo:i, foo:j)]");
+ final LdPathParser<Value> parseri = createParserFromString("ex:hasItem[! fn:eq(foo:i, foo:j)]");
final NodeSelector<Value> seli = parseri.parseSelector(NSS);
final Collection<Value> resulti = seli.select(backend, start, null, null);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/EmptyTestingBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/EmptyTestingBackend.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/EmptyTestingBackend.java
index 65329f0..cf02c4c 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/EmptyTestingBackend.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/EmptyTestingBackend.java
@@ -1,13 +1,12 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
index f7bcbe8..6a7734d 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
@@ -1,13 +1,12 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,6 +19,7 @@ package org.apache.marmotta.ldpath.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -32,11 +32,11 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.marmotta.ldpath.api.tests.NodeTest;
import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
import org.apache.marmotta.ldpath.model.programs.Program;
import org.hamcrest.CoreMatchers;
-import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -46,12 +46,14 @@ public class ParserTest {
private static NodeBackend<String> backend;
private static final String NS_TEST = "http://example.com/";
private static final String NS_FOO = "http://foo.com/some/path#";
+ private static final String NS_FOOBAR = "urn:uuid:1234";
private static final Map<String, String> NAMESPACES;
static {
Map<String, String> ns = new HashMap<String, String>();
ns.put("test", NS_TEST);
ns.put("foo", NS_FOO);
+ ns.put("foobar", NS_FOOBAR);
NAMESPACES = Collections.unmodifiableMap(ns);
}
@@ -63,7 +65,7 @@ public class ParserTest {
@Test
public void testParseProgram() throws IOException {
- RdfPathParser<String> parser = createParser("program.ldpath");
+ LdPathParser<String> parser = createParser("program.ldpath");
try {
Program<String> program = parser.parseProgram();
assertNotNull(program.getField("path"));
@@ -83,7 +85,7 @@ public class ParserTest {
@Test
public void testParseTest() throws IOException {
- RdfPathParser<String> parser = createParser("test.ldpath");
+ LdPathParser<String> parser = createParser("test.ldpath");
try {
NodeTest<String> test = parser.parseTest(NAMESPACES);
assertNotNull(test);
@@ -95,27 +97,29 @@ public class ParserTest {
@Test
public void testParsePrefixes() throws IOException {
- RdfPathParser<String> parser = createParser("namespaces.ldpath");
+ LdPathParser<String> parser = createParser("namespaces.ldpath");
try {
Map<String, String> prefixes = parser.parsePrefixes();
assertTrue(prefixes.containsKey("test"));
assertTrue(prefixes.containsKey("foo"));
+ assertTrue(prefixes.containsKey("foobar"));
assertEquals(NS_TEST, prefixes.get("test"));
assertEquals(NS_FOO, prefixes.get("foo"));
+ assertEquals(NS_FOOBAR, prefixes.get("foobar"));
} catch (ParseException e) {
assertFalse(e.getMessage(), true);
}
}
- private RdfPathParser<String> createParser(String input) throws IOException {
- final URL resource = ParserTest.class.getResource(input);
- Assume.assumeThat("Could not load test input data '" + input + "'", resource, CoreMatchers.notNullValue());
+ private LdPathParser<String> createParser(String input) throws IOException {
+ final URL resource = ParserTest.class.getResource("/parse/"+input);
+ assertThat("Could not load test input data '" + input + "'", resource, CoreMatchers.notNullValue());
- RdfPathParser<String> rdfPathParser = new RdfPathParser<String>(backend,new StringReader(IOUtils.toString(resource)));
+ LdPathParser<String> rdfPathParser = new LdPathParser<String>(backend,new StringReader(IOUtils.toString(resource)));
rdfPathParser.registerTransformer(NS_TEST + "type", new NodeTransformer<String, String>() {
@Override
- public String transform(NodeBackend<String> backend, String node, Map<String,String> configuration)
+ public String transform(RDFBackend<String> backend, String node, Map<String,String> configuration)
throws IllegalArgumentException {
return node;
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ProgramTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ProgramTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ProgramTest.java
new file mode 100644
index 0000000..0f74279
--- /dev/null
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ProgramTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldpath.parser;
+
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
+import org.apache.marmotta.ldpath.model.programs.Program;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.text.IsEqualIgnoringWhiteSpace;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ProgramTest {
+
+ private static StringTestingBackend backend;
+
+ private String expr;
+
+ private Program<String> program;
+
+ @BeforeClass
+ public static void beforeClass() {
+ backend = new StringTestingBackend();
+ }
+
+
+ @Before
+ public void before() throws ParseException, IOException {
+ final URL resource = ParserTest.class.getResource("/parse/program.ldpath");
+ assertThat("Could not load test input data '/parse/program.ldpath'", resource, CoreMatchers.notNullValue());
+
+ expr = IOUtils.toString(resource);
+
+ LdPathParser<String> rdfPathParser = new LdPathParser<String>(backend,new StringReader(expr));
+ rdfPathParser.registerTransformer("http://example.com/type", new NodeTransformer<String, String>() {
+ @Override
+ public String transform(RDFBackend<String> backend, String node, Map<String,String> configuration)
+ throws IllegalArgumentException {
+ return node;
+ }
+ });
+
+ program = rdfPathParser.parseProgram();
+
+ expr = expr.replaceAll("/\\*(?:.|[\\n\\r])*?\\*/", "");
+ }
+
+ @Test
+ public void testGetPathExpression() {
+ final String result = program.getPathExpression(backend);
+ Assert.assertThat(result, IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace(expr));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/SelectorsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/SelectorsTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/SelectorsTest.java
new file mode 100644
index 0000000..f2a0327
--- /dev/null
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/SelectorsTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldpath.parser;
+
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.selectors.NodeSelector;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.text.IsEqualIgnoringWhiteSpace;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class SelectorsTest {
+
+ @Parameters(name = "{index}: {1}Selector")
+ public static List<String[]> testCases() {
+ return Arrays.asList(new String[][] {
+ {"*", "Wildcard"},
+ {"<http://www.example.com/>", "Property"},
+ {"<http://foo.bar> / <http://bar.foo>", "Path"},
+ {"<http://foo.bar> & <http://bar.foo>", "Intersection"},
+ {"<http://foo.bar> | <http://bar.foo>", "Union"},
+ {"<http://foo.bar>[<http://bar.foo>]", "Testing"},
+ {"(<http://www.example.com/>[@en])", "Grouped"},
+ {"(<http://www.example.com/>)*", "RecursivePath"},
+ {"(<http://www.example.com/>)+", "RecursivePath"},
+ {"^<http://www.example.com/>", "ReverseProperty"},
+ {"fn:count(\"foo\")", "Function"},
+ // Not implemented yet: {"^*", "ReverseProperty"},
+ {".", "Self"},
+ {"\"Hello World\"", "StringConstant"},
+ });
+ }
+
+ @Parameter
+ public String expr;
+
+ @Parameter(1)
+ public String name;
+
+ private NodeSelector<String> selector;
+
+ private static NodeBackend<String> backend;
+
+ @BeforeClass
+ public static void beforeClass() {
+ backend = new StringTestingBackend();
+ }
+
+ @Before
+ public void before() throws ParseException {
+ LdPathParser<String> rdfPathParser = new LdPathParser<String>(backend,new StringReader(expr));
+ selector = rdfPathParser.parseSelector(Collections.<String,String>emptyMap());
+ }
+
+ @Test
+ public void testGetPathExpression() {
+ Assert.assertThat(selector.getPathExpression(backend), IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace(expr));
+ }
+
+ @Test
+ public void testParseSelector() {
+ final String className = "org.apache.marmotta.ldpath.model.selectors." + name + "Selector";
+ try {
+ final Class<?> cls = Class.forName(className);
+ Assert.assertThat(selector, CoreMatchers.instanceOf(cls));
+ } catch (ClassNotFoundException e) {
+ Assert.fail("Could not load class: " + className);
+ }
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/StringTestingBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/StringTestingBackend.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/StringTestingBackend.java
new file mode 100644
index 0000000..2af51ad
--- /dev/null
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/StringTestingBackend.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldpath.parser;
+
+import java.net.URI;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.marmotta.ldpath.model.backend.AbstractBackend;
+
+public class StringTestingBackend extends AbstractBackend<String> {
+
+ private static final Pattern LANG_PATTERN = Pattern.compile("@(\\w+)"),
+ TYPE_PATTERN = Pattern.compile("\\^\\^([\\w:/.#%-]+)");
+
+ @Override
+ public boolean isLiteral(String n) {
+ return n.startsWith("\"");
+ }
+
+ @Override
+ public boolean isURI(String n) {
+ return n.startsWith("<");
+ }
+
+ @Override
+ public boolean isBlank(String n) {
+ return n.startsWith("_");
+ }
+
+ @Override
+ public Locale getLiteralLanguage(String n) {
+ final Matcher m = LANG_PATTERN.matcher(n);
+ if (m.find()) {
+ return new Locale(m.group(1));
+ }
+ return null;
+ }
+
+ @Override
+ public URI getLiteralType(String n) {
+ final Matcher m = TYPE_PATTERN.matcher(n);
+ if (m.find()) {
+ return URI.create(m.group(1));
+ }
+ return null;
+ }
+
+ @Override
+ public String createLiteral(String content) {
+ return "\""+content+"\"";
+ }
+
+ @Override
+ public String createLiteral(String content, Locale language, URI type) {
+ StringBuilder sb = new StringBuilder('"');
+ sb.append(content).append('"');
+ if (language != null) {
+ sb.append("@").append(language.getLanguage());
+ }
+ if (type != null) {
+ sb.append("^^").append(type.toString());
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String createURI(String uri) {
+ return "<" + uri + ">";
+ }
+
+ @Override
+ public String stringValue(String node) {
+ if (node.startsWith("<")) {
+ return node.substring(1, node.length()-1);
+ } else if (node.startsWith("\"")) {
+ return node.substring(1, node.indexOf('"', 1));
+ } else
+ return node;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/TestsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/TestsTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/TestsTest.java
new file mode 100644
index 0000000..92f820e
--- /dev/null
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/TestsTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.ldpath.parser;
+
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.marmotta.ldpath.api.backend.NodeBackend;
+import org.apache.marmotta.ldpath.api.tests.NodeTest;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.text.IsEqualIgnoringWhiteSpace;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestsTest {
+
+ @Parameters(name = "{index}: {1}Test")
+ public static List<String[]> testCases() {
+ return Arrays.asList(new String[][] {
+ {"<http://foo.bar> & <http://bar.foo>", "And"},
+ {"fn:eq(\"1\", \"2\")", "Function"},
+ {"@en", "LiteralLanguage"},
+ {"^^<http://foo.bar>", "LiteralType"},
+ {"!@en", "Not"},
+ {"<http://foo.bar> | <http://bar.foo>", "Or"},
+ {"<http://www.example.com/> is <http://foo.bar>", "PathEquality"},
+ {"is-a <http://foo.bar>", "IsA"},
+ {"<http://www.example.com/>", "Path"},
+ });
+ }
+
+ @Parameter
+ public String expr;
+
+ @Parameter(1)
+ public String name;
+
+ private NodeTest<String> test;
+
+ private static NodeBackend<String> backend;
+
+ @BeforeClass
+ public static void beforeClass() {
+ backend = new StringTestingBackend();
+ }
+
+ @Before
+ public void before() throws ParseException {
+ LdPathParser<String> rdfPathParser = new LdPathParser<String>(backend,new StringReader(expr));
+ test = rdfPathParser.parseTest(Collections.<String,String>emptyMap());
+ }
+
+ @Test
+ public void testGetPathExpression() {
+ Assert.assertThat(test.getPathExpression(backend), IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace(expr));
+ }
+
+ @Test
+ public void testParseSelector() {
+ final String className = "org.apache.marmotta.ldpath.model.tests." + name + "Test";
+ try {
+ final Class<?> cls = Class.forName(className);
+ Assert.assertThat(test, CoreMatchers.instanceOf(cls));
+ } catch (ClassNotFoundException e) {
+ Assert.fail("Could not load class: " + className);
+ }
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/test/AbstractTestBase.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/test/AbstractTestBase.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/test/AbstractTestBase.java
index 9152031..e1acd89 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/test/AbstractTestBase.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/test/AbstractTestBase.java
@@ -18,13 +18,27 @@
package org.apache.marmotta.ldpath.test;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
import org.apache.marmotta.ldpath.api.selectors.NodeSelector;
import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
import org.apache.marmotta.ldpath.model.fields.FieldMapping;
-import org.apache.marmotta.ldpath.parser.*;
+import org.apache.marmotta.ldpath.parser.ParseException;
+import org.apache.marmotta.ldpath.parser.LdPathParser;
import org.hamcrest.CoreMatchers;
import org.junit.After;
-import org.junit.Assume;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestWatcher;
@@ -40,20 +54,6 @@ import org.openrdf.sail.memory.MemoryStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assume.assumeThat;
-
public abstract class AbstractTestBase {
protected final static Map<String, String> NSS;
static {
@@ -108,18 +108,18 @@ public abstract class AbstractTestBase {
};
- protected RdfPathParser<Value> createParserFromResource(String input) throws IOException {
+ protected LdPathParser<Value> createParserFromResource(String input) throws IOException {
final URL resource = this.getClass().getResource(input);
- assumeThat("Could not load test input data '" + input + "'", resource, CoreMatchers.notNullValue());
+ assertThat("Could not load test input data '" + input + "'", resource, CoreMatchers.notNullValue());
- RdfPathParser<Value> parser = new RdfPathParser<Value>(backend, resource.openStream());
+ LdPathParser<Value> parser = new LdPathParser<Value>(backend, resource.openStream());
assertThat("Could not parse ldPath", parser, CoreMatchers.notNullValue());
return parser;
}
- protected RdfPathParser<Value> createParserFromString(String program) {
- final RdfPathParser<Value> parser = new RdfPathParser<Value>(backend, new StringReader(program));
+ protected LdPathParser<Value> createParserFromString(String program) {
+ final LdPathParser<Value> parser = new LdPathParser<Value>(backend, new StringReader(program));
assertThat("Could not parse ldPath", parser, CoreMatchers.notNullValue());
return parser;
@@ -132,7 +132,7 @@ public abstract class AbstractTestBase {
protected final void loadData(String datafile, RDFFormat format, String baseURI) throws RepositoryException, RDFParseException, IOException {
// load demo data
InputStream data = this.getClass().getResourceAsStream(datafile);
- Assume.assumeThat("Could not load test-data: " + datafile, data, notNullValue(InputStream.class));
+ Assert.assertThat("Could not load test-data: " + datafile, data, notNullValue(InputStream.class));
final SailRepositoryConnection con = repository.getConnection();
try {
@@ -146,7 +146,7 @@ public abstract class AbstractTestBase {
}
protected Collection<Object> evaluateRule(final String ldPath, URI context) throws ParseException {
- final RdfPathParser<Value> parser = createParserFromString(ldPath);
+ final LdPathParser<Value> parser = createParserFromString(ldPath);
final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
final Collection<Object> values = rule.getValues(backend, context);
return values;
@@ -166,7 +166,7 @@ public abstract class AbstractTestBase {
}
protected Collection<Value> evaluateSelector(final String ldPath, URI context) throws ParseException {
- final RdfPathParser<Value> parser = createParserFromString(ldPath);
+ final LdPathParser<Value> parser = createParserFromString(ldPath);
final NodeSelector<Value> sel = parser.parseSelector(NSS);
final Collection<Value> nodes = sel.select(backend, context, null, null);
return nodes;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/resources/logback.xml b/libraries/ldpath/ldpath-core/src/test/resources/logback.xml
index 1bfecff..16c98cd 100644
--- a/libraries/ldpath/ldpath-core/src/test/resources/logback.xml
+++ b/libraries/ldpath/ldpath-core/src/test/resources/logback.xml
@@ -21,6 +21,8 @@
<pattern>%d{HH:mm:ss.SSS} %highlight(%level) %cyan(%logger{15}) - %m%n</pattern>
</encoder>
</appender>
+
+ <logger name="org.apache.marmotta.ldpath.parser.DefaultConfiguration" level="WARN" />
<root level="${root-level:-INFO}">
<appender-ref ref="CONSOLE"/>
</root>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath b/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
index 0f7c569..81a7def 100644
--- a/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
+++ b/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
@@ -17,4 +17,5 @@
@prefix foo: <http://foo.com/some/path#> ;
@prefix foaf: <http://xmlns.com/foaf/0.1/> ;
@prefix test: <http://example.com/>
-@prefix dcterms: <http://purl.org/dc/terms/> ;
\ No newline at end of file
+@prefix dcterms: <http://purl.org/dc/terms/> ;
+@prefix foobar: <urn:uuid:1234> ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath b/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
index 5af4a0e..fc4fdc5 100644
--- a/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
+++ b/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
@@ -13,19 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@prefix test: <http://example.com/>;
+@prefix test: <http://example.com/> ;
@prefix foo: <http://foo.com/some/path#> ;
+@graph test:context, foo:ctx, test:bar ;
+
@filter test:type is foo:bar | test:p1 & is-a test:Case ;
@boost foo:boost / ^test:boost ;
-path = test:p1 / test:p2 :: test:type;
-lang_test = test:p1[@en] :: test:type;
-type_test = foo:p2[^^test:int] :: test:type;
-int_s = (foo:go)* :: test:type;
-int_p = (foo:go)+ :: test:type;
+path = test:p1 / test:p2 :: test:type ;
+lang_test = test:p1[@en] :: test:type ;
+type_test = foo:p2[^^test:int] :: test:type ;
+int_s = (foo:go)* :: test:type ;
+int_p = (foo:go)+ :: test:type ;
+group = (test:p1 / test:p2) :: test:type ;
+
+inverse = ^test:incoming :: test:type ;
-inverse = ^test:incoming :: test:type;
+config = test:foo :: test:type(c1="true", c2="false", c3="1.234") ;
-config = test:foo :: test:type(c1=true, c2="false", c3="1.234");
\ No newline at end of file
+foo:bar = test:foo :: test:type ;
+<http://test/> = test:test :: test:type ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-collections/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-collections/pom.xml b/libraries/ldpath/ldpath-functions-collections/pom.xml
index e6ed175..ac7553a 100644
--- a/libraries/ldpath/ldpath-functions-collections/pom.xml
+++ b/libraries/ldpath/ldpath-functions-collections/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.1.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -73,6 +73,27 @@
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin> <!-- generate JRebel Configuration -->
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>jrebel-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-rebel-xml</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <relativePath>../../../</relativePath>
+ <rootPath>$${rebel.root}</rootPath>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-date/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-date/pom.xml b/libraries/ldpath/ldpath-functions-date/pom.xml
index e990287..62e6fe7 100644
--- a/libraries/ldpath/ldpath-functions-date/pom.xml
+++ b/libraries/ldpath/ldpath-functions-date/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.1.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -69,6 +69,27 @@
</dependency>
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin> <!-- generate JRebel Configuration -->
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>jrebel-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-rebel-xml</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <relativePath>../../../</relativePath>
+ <rootPath>$${rebel.root}</rootPath>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java b/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
index 8470462..ea8c9e8 100644
--- a/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
+++ b/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
@@ -24,7 +24,7 @@ import java.util.Random;
import org.apache.marmotta.ldpath.model.fields.FieldMapping;
import org.apache.marmotta.ldpath.parser.ParseException;
-import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.apache.marmotta.ldpath.parser.LdPathParser;
import org.apache.marmotta.ldpath.test.AbstractTestBase;
import org.junit.Assert;
import org.junit.Before;
@@ -48,7 +48,7 @@ public class DateFunctionsTest extends AbstractTestBase {
@Before
public void loadData() throws RepositoryException, RDFParseException, IOException {
final int delta = 60 * 60 * 24 * 365;
- now = new Date();
+ now = new Date(1000*(System.currentTimeMillis() / 1000));
first = new Date(now.getTime() - 1000l * delta);
uri = repository.getValueFactory().createURI(NSS.get("ex") + now.getTime());
@@ -76,7 +76,7 @@ public class DateFunctionsTest extends AbstractTestBase {
@Test
public void testEarliest() throws ParseException {
- final RdfPathParser<Value> parser = createParserFromString("fn:earliest(<" + prop.stringValue() + ">) :: xsd:dateTime");
+ final LdPathParser<Value> parser = createParserFromString("fn:earliest(<" + prop.stringValue() + ">) :: xsd:dateTime");
final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
final Collection<Object> result = rule.getValues(backend, uri);
@@ -88,7 +88,7 @@ public class DateFunctionsTest extends AbstractTestBase {
@Test
public void testLatest() throws ParseException {
- final RdfPathParser<Value> parser = createParserFromString("fn:latest(<" + prop.stringValue() + ">) :: xsd:dateTime");
+ final LdPathParser<Value> parser = createParserFromString("fn:latest(<" + prop.stringValue() + ">) :: xsd:dateTime");
final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
final Collection<Object> result = rule.getValues(backend, uri);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-html/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-html/pom.xml b/libraries/ldpath/ldpath-functions-html/pom.xml
index fd9fe94..dc031ad 100644
--- a/libraries/ldpath/ldpath-functions-html/pom.xml
+++ b/libraries/ldpath/ldpath-functions-html/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.1.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating</version>
<relativePath>../../../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -83,6 +83,27 @@
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin> <!-- generate JRebel Configuration -->
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>jrebel-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-rebel-xml</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <relativePath>../../../</relativePath>
+ <rootPath>$${rebel.root}</rootPath>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-html/src/test/java/org/apache/marmotta/ldpath/model/functions/html/HtmlFunctionsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-html/src/test/java/org/apache/marmotta/ldpath/model/functions/html/HtmlFunctionsTest.java b/libraries/ldpath/ldpath-functions-html/src/test/java/org/apache/marmotta/ldpath/model/functions/html/HtmlFunctionsTest.java
index d663924..29f5426 100644
--- a/libraries/ldpath/ldpath-functions-html/src/test/java/org/apache/marmotta/ldpath/model/functions/html/HtmlFunctionsTest.java
+++ b/libraries/ldpath/ldpath-functions-html/src/test/java/org/apache/marmotta/ldpath/model/functions/html/HtmlFunctionsTest.java
@@ -27,7 +27,7 @@ import java.util.Collection;
import org.apache.marmotta.ldpath.model.fields.FieldMapping;
import org.apache.marmotta.ldpath.parser.ParseException;
-import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.apache.marmotta.ldpath.parser.LdPathParser;
import org.apache.marmotta.ldpath.test.AbstractTestBase;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
@@ -50,7 +50,7 @@ public class HtmlFunctionsTest extends AbstractTestBase {
public void testCleanHtmlFunction() throws ParseException {
URI uri = repository.getValueFactory().createURI(NSS.get("ex") + "Simple");
- final RdfPathParser<Value> parser = createParserFromString("fn:cleanHtml(foo:html) :: xsd:string");
+ final LdPathParser<Value> parser = createParserFromString("fn:cleanHtml(foo:html) :: xsd:string");
final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
final Collection<Object> result = rule.getValues(backend, uri);
@@ -67,7 +67,7 @@ public class HtmlFunctionsTest extends AbstractTestBase {
public void testCssSelectFunction() throws ParseException {
URI uri = repository.getValueFactory().createURI(NSS.get("ex") + "Simple");
- final RdfPathParser<Value> parser = createParserFromString("fn:css(\"p\", foo:html) :: xsd:string");
+ final LdPathParser<Value> parser = createParserFromString("fn:css(\"p\", foo:html) :: xsd:string");
final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
final Collection<Object> result = rule.getValues(backend, uri);
@@ -79,7 +79,7 @@ public class HtmlFunctionsTest extends AbstractTestBase {
assertThat("String end", s, CoreMatchers.endsWith("</p>"));
}
- final RdfPathParser<Value> parser2 = createParserFromString("fn:css(\"p#p2\", foo:html) :: xsd:string");
+ final LdPathParser<Value> parser2 = createParserFromString("fn:css(\"p#p2\", foo:html) :: xsd:string");
final FieldMapping<Object, Value> rule2 = parser2.parseRule(NSS);
final Collection<Object> result2 = rule2.getValues(backend, uri);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-math/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-math/pom.xml b/libraries/ldpath/ldpath-functions-math/pom.xml
index 3a8ede8..333fbcc 100644
--- a/libraries/ldpath/ldpath-functions-math/pom.xml
+++ b/libraries/ldpath/ldpath-functions-math/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.1.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -68,6 +68,27 @@
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin> <!-- generate JRebel Configuration -->
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>jrebel-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-rebel-xml</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <relativePath>../../../</relativePath>
+ <rootPath>$${rebel.root}</rootPath>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MaxFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MaxFunction.java b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MaxFunction.java
index a403303..252c268 100644
--- a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MaxFunction.java
+++ b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MaxFunction.java
@@ -46,7 +46,7 @@ public class MaxFunction<Node> extends MathFunction<Node> {
return result;
}
- protected Node calc(NodeBackend<Node> backend, Collection<Node> arg) {
+ protected Node calc(RDFBackend<Node> backend, Collection<Node> arg) {
/* MAX */
double d = Double.MIN_VALUE;
Node max = null;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MinFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MinFunction.java b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MinFunction.java
index ada8303..c4fd8b0 100644
--- a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MinFunction.java
+++ b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/MinFunction.java
@@ -47,7 +47,7 @@ public class MinFunction<Node> extends MathFunction<Node> {
return result;
}
- protected Node calc(NodeBackend<Node> backend, Collection<Node> arg) {
+ protected Node calc(RDFBackend<Node> backend, Collection<Node> arg) {
/* MIN */
double d = Double.MAX_VALUE;
Node min = null;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/RoundFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/RoundFunction.java b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/RoundFunction.java
index 9a18a8e..0675249 100644
--- a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/RoundFunction.java
+++ b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/RoundFunction.java
@@ -49,7 +49,7 @@ public class RoundFunction<Node> extends MathFunction<Node> {
return result;
}
- protected Node calc(NodeBackend<Node> backend, Node node) {
+ protected Node calc(RDFBackend<Node> backend, Node node) {
/* SUM */
try {
Double val = doubleTransformer.transform(backend, node, null);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/582abb5b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/SumFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/SumFunction.java b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/SumFunction.java
index a78d68b..99d271f 100644
--- a/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/SumFunction.java
+++ b/libraries/ldpath/ldpath-functions-math/src/main/java/org/apache/marmotta/ldpath/model/functions/math/SumFunction.java
@@ -46,7 +46,7 @@ public class SumFunction<Node> extends MathFunction<Node> {
return result;
}
- protected Node calc(NodeBackend<Node> backend, Collection<Node> arg) {
+ protected Node calc(RDFBackend<Node> backend, Collection<Node> arg) {
/* SUM */
Double d = 0d;
for (Node n : arg) {