MARMOTTA-611: added getters also for NodeTests
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/5c5a4d1b Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/5c5a4d1b Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/5c5a4d1b Branch: refs/heads/develop Commit: 5c5a4d1b49bd1f3a09b882c70a3f8a24362b1e03 Parents: 9458ea2 Author: Jakob Frank <[email protected]> Authored: Fri May 8 10:48:12 2015 +0200 Committer: Jakob Frank <[email protected]> Committed: Fri May 8 10:48:19 2015 +0200 ---------------------------------------------------------------------- .../marmotta/ldpath/model/tests/AndTest.java | 20 ++++++++++++++-- .../ldpath/model/tests/FunctionTest.java | 24 ++++++++++++++++---- .../marmotta/ldpath/model/tests/IsATest.java | 2 +- .../ldpath/model/tests/LiteralLanguageTest.java | 14 +++++++++--- .../ldpath/model/tests/LiteralTypeTest.java | 18 +++++++++++---- .../marmotta/ldpath/model/tests/NotTest.java | 8 +++++++ .../marmotta/ldpath/model/tests/OrTest.java | 20 ++++++++++++++-- .../ldpath/model/tests/PathEqualityTest.java | 16 +++++++++++++ .../marmotta/ldpath/model/tests/PathTest.java | 14 +++++++++--- 9 files changed, 116 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/AndTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/AndTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/AndTest.java index c111544..5c0300c 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/AndTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/AndTest.java @@ -30,8 +30,8 @@ import org.apache.marmotta.ldpath.api.tests.NodeTest; */ public class AndTest<Node> extends ComplexTest<Node> { - private NodeTest<Node> left; - private NodeTest<Node> right; + private final NodeTest<Node> left; + private final NodeTest<Node> right; public AndTest(NodeTest<Node> left, NodeTest<Node> right) { @@ -86,6 +86,22 @@ public class AndTest<Node> extends ComplexTest<Node> { return "Tests the conjunction of two tests"; } + /** + * Get the left Test + * @return the left Test of the And + */ + public NodeTest<Node> getLeft() { + return left; + } + + /** + * Get the right Test + * @return the right Test of the And + */ + public NodeTest<Node> getRight() { + return right; + } + @Override public boolean equals(Object o) { if (this == o) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/FunctionTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/FunctionTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/FunctionTest.java index d0d7742..66b3f5b 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/FunctionTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/FunctionTest.java @@ -18,16 +18,16 @@ package org.apache.marmotta.ldpath.model.tests; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import org.apache.marmotta.ldpath.api.backend.NodeBackend; import org.apache.marmotta.ldpath.api.backend.RDFBackend; import org.apache.marmotta.ldpath.api.functions.TestFunction; import org.apache.marmotta.ldpath.api.selectors.NodeSelector; import org.apache.marmotta.ldpath.api.tests.NodeTest; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + public class FunctionTest<Node> extends NodeTest<Node> { private final TestFunction<Node> test; @@ -62,6 +62,22 @@ public class FunctionTest<Node> extends NodeTest<Node> { return "Delegate the test to a TestFunction"; } + /** + * Get the Function of this Test + * @return the TestFunction + */ + public TestFunction<Node> getTest() { + return test; + } + + /** + * Get the argument list of the TestFunction + * @return the arguments of the TestFunction + */ + public List<NodeSelector<Node>> getArgSelectors() { + return argSelectors; + } + @Override public String getPathExpression(NodeBackend<Node> backend) { final StringBuilder sb = new StringBuilder("fn:"); http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/IsATest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/IsATest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/IsATest.java index 8ddce70..549bbf0 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/IsATest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/IsATest.java @@ -51,7 +51,7 @@ public class IsATest<Node> extends PathEqualityTest<Node> { @Override public String getDescription() { - return "tests if a node has a certain type"; + return "tests if a node has a certain rdf:type"; } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralLanguageTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralLanguageTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralLanguageTest.java index e6a8b62..07f56d7 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralLanguageTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralLanguageTest.java @@ -18,12 +18,12 @@ package org.apache.marmotta.ldpath.model.tests; -import java.util.Locale; - 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 java.util.Locale; + /** * Tests if the language of the literal node matches the language configured for the test. If the language of the test * is null, only allows literal nodes without language definition. @@ -33,7 +33,7 @@ import org.apache.marmotta.ldpath.api.tests.NodeTest; */ public class LiteralLanguageTest<Node> extends NodeTest<Node> { - private String lang; + private final String lang; public LiteralLanguageTest(String lang) { @@ -95,6 +95,14 @@ public class LiteralLanguageTest<Node> extends NodeTest<Node> { return "Tests the language of the literal nodes passed as argument"; } + /** + * Get the language to test for + * @return the language tag. + */ + public String getLang() { + return lang; + } + @Override public boolean equals(Object o) { if (this == o) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralTypeTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralTypeTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralTypeTest.java index 02d00d8..b4d1768 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralTypeTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/LiteralTypeTest.java @@ -17,12 +17,12 @@ */ package org.apache.marmotta.ldpath.model.tests; -import java.net.URI; - 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 java.net.URI; + /** * Literal type tests allow to select only literals of a specified type, e.g. to ensure that only decimal values are * retrieved: @@ -37,7 +37,7 @@ import org.apache.marmotta.ldpath.api.tests.NodeTest; */ public class LiteralTypeTest<Node> extends NodeTest<Node> { - private URI typeUri; + private final URI typeUri; public LiteralTypeTest(String typeUri) { this.typeUri = URI.create(typeUri); @@ -87,7 +87,7 @@ public class LiteralTypeTest<Node> extends NodeTest<Node> { * syntax for representing the signature can be chosen by the implementer. This method is for informational * purposes only. * - * @return + * @return the Signature (human readable) */ @Override public String getSignature() { @@ -97,13 +97,21 @@ public class LiteralTypeTest<Node> extends NodeTest<Node> { /** * A short human-readable description of what the node function does. * - * @return + * @return A short human-readable description of what the node function does. */ @Override public String getDescription() { return "Tests the types of the nodes passed as argument"; } + /** + * Get the type (uri) to test for. + * @return the type to test for. + */ + public URI getTypeUri() { + return typeUri; + } + @Override public boolean equals(Object o) { if (this == o) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/NotTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/NotTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/NotTest.java index e79f23b..ca98892 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/NotTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/NotTest.java @@ -65,6 +65,14 @@ public class NotTest<Node> extends NodeTest<Node> { return "Negates the test given as argument"; } + /** + * Get the delegate that is negated + * @return the delegate NodeTest + */ + public NodeTest<Node> getDelegate() { + return delegate; + } + @Override public boolean equals(Object o) { if (this == o) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/OrTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/OrTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/OrTest.java index e39ee4f..8553cb0 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/OrTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/OrTest.java @@ -28,8 +28,8 @@ import org.apache.marmotta.ldpath.api.tests.NodeTest; */ public class OrTest<Node> extends ComplexTest<Node> { - private NodeTest<Node> left; - private NodeTest<Node> right; + private final NodeTest<Node> left; + private final NodeTest<Node> right; public OrTest(NodeTest<Node> left, NodeTest<Node> right) { this.left = left; @@ -83,6 +83,22 @@ public class OrTest<Node> extends ComplexTest<Node> { return "Tests the disjunction of two tests"; } + /** + * Get the left test of this OR + * @return the left NodeTest + */ + public NodeTest<Node> getLeft() { + return left; + } + + /** + * Get the right test of this OR + * @return the right NodeTest + */ + public NodeTest<Node> getRight() { + return right; + } + @Override public boolean equals(Object o) { if (this == o) { return true; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathEqualityTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathEqualityTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathEqualityTest.java index 528d986..da46028 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathEqualityTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathEqualityTest.java @@ -97,6 +97,22 @@ public class PathEqualityTest<Node> extends NodeTest<Node> { return "Tests whether the two node lists intersect"; } + /** + * Get the Path/Selector to run the test on + * @return the Selector to test + */ + public NodeSelector<Node> getPath() { + return path; + } + + /** + * Get the expected value to test for + * @return the value to test for. + */ + public Node getNode() { + return node; + } + @Override public boolean equals(Object o) { if (this == o) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c5a4d1b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathTest.java ---------------------------------------------------------------------- diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathTest.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathTest.java index 0c79a60..00b0958 100644 --- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathTest.java +++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/tests/PathTest.java @@ -18,13 +18,13 @@ package org.apache.marmotta.ldpath.model.tests; -import java.util.Collection; - import org.apache.marmotta.ldpath.api.backend.NodeBackend; import org.apache.marmotta.ldpath.api.backend.RDFBackend; import org.apache.marmotta.ldpath.api.selectors.NodeSelector; import org.apache.marmotta.ldpath.api.tests.NodeTest; +import java.util.Collection; + /** * Tests whether the path given as argument for the constructor yields at least one node when evaluated * from the context node to which the test is applied. @@ -33,7 +33,7 @@ import org.apache.marmotta.ldpath.api.tests.NodeTest; */ public class PathTest<Node> extends NodeTest<Node> { - private NodeSelector<Node> path; + private final NodeSelector<Node> path; public PathTest(NodeSelector<Node> path) { this.path = path; @@ -91,6 +91,14 @@ public class PathTest<Node> extends NodeTest<Node> { return "Tests whether the node list is non-empty"; } + /** + * Get the Path/Selector to check existence for + * @return the Selector to check. + */ + public NodeSelector<Node> getPath() { + return path; + } + @Override public boolean equals(Object o) { if (this == o) { return true; }
