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 2018/06/18 18:36:12 UTC
[53/62] [abbrv] marmotta git commit: Remove some more unnecessary code
Remove some more unnecessary code
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/310ce408
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/310ce408
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/310ce408
Branch: refs/heads/master
Commit: 310ce40824c33a2286094cef7244892710f0df40
Parents: 1e9b2b1
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Sun Apr 29 22:06:52 2018 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Sun Apr 29 22:06:52 2018 +0200
----------------------------------------------------------------------
libraries/ostrich/backend/ldpath/CMakeLists.txt | 6 -
.../ostrich/backend/ldpath/ldpath_model.cc | 26 --
libraries/ostrich/backend/ldpath/ldpath_model.h | 46 ---
libraries/ostrich/backend/ldpath/parser_base.cc | 5 -
libraries/ostrich/backend/ldpath/parser_base.h | 304 -------------------
5 files changed, 387 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/310ce408/libraries/ostrich/backend/ldpath/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/ldpath/CMakeLists.txt b/libraries/ostrich/backend/ldpath/CMakeLists.txt
deleted file mode 100644
index 65e33f7..0000000
--- a/libraries/ostrich/backend/ldpath/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}/..)
-
-add_library(marmotta_ldpath
- ldpath_model.h ldpath_model.cc
- parser_base.h parser_base.cc)
-target_link_libraries(marmotta_ldpath ${CMAKE_THREAD_LIBS_INIT})
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/310ce408/libraries/ostrich/backend/ldpath/ldpath_model.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/ldpath/ldpath_model.cc b/libraries/ostrich/backend/ldpath/ldpath_model.cc
deleted file mode 100644
index 17d7721..0000000
--- a/libraries/ostrich/backend/ldpath/ldpath_model.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// Created by wastl on 15.02.16.
-//
-
-#include "ldpath_model.h"
-
-namespace marmotta {
-namespace ldpath {
-namespace model {
-
-std::vector<rdf::Value> PropertySelector::select(
- const RDFBackend *backend, const rdf::Value &context) const {
- return backend->listObjects(context, property);
-}
-
-std::string PropertySelector::getPathExpression() const {
- std::string s = "<";
- s += property.getUri();
- s += ">";
- return s;
-}
-
-}
-}
-}
-
http://git-wip-us.apache.org/repos/asf/marmotta/blob/310ce408/libraries/ostrich/backend/ldpath/ldpath_model.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/ldpath/ldpath_model.h b/libraries/ostrich/backend/ldpath/ldpath_model.h
deleted file mode 100644
index 6275033..0000000
--- a/libraries/ostrich/backend/ldpath/ldpath_model.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Created by wastl on 15.02.16.
-//
-
-#ifndef MARMOTTA_LDPATH_MODEL_H
-#define MARMOTTA_LDPATH_MODEL_H
-
-#include <vector>
-#include <string>
-
-#include "model/rdf_model.h"
-
-namespace marmotta {
-namespace ldpath {
-namespace model {
-
-class RDFBackend {
- public:
- virtual std::vector<rdf::Value> listObjects(const rdf::Value& subject, const rdf::Value& property) const = 0;
-
- virtual std::vector<rdf::Value> listSubjects(const rdf::Value& property, const rdf::Value& object) const = 0;
-};
-
-
-class NodeSelector {
- public:
- virtual std::vector<rdf::Value> select(const RDFBackend* backend, const rdf::Value& context) const = 0;
-
- virtual std::string getPathExpression() const = 0;
-};
-
-class PropertySelector : public NodeSelector {
- public:
- PropertySelector(const rdf::URI& property) : property(property) {}
-
- std::vector<rdf::Value> select(const RDFBackend* backend, const rdf::Value& context) const override;
- std::string getPathExpression() const override;
-
- private:
- rdf::URI property;
-};
-}
-}
-}
-
-#endif //MARMOTTA_LDPATH_MODEL_H
http://git-wip-us.apache.org/repos/asf/marmotta/blob/310ce408/libraries/ostrich/backend/ldpath/parser_base.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/ldpath/parser_base.cc b/libraries/ostrich/backend/ldpath/parser_base.cc
deleted file mode 100644
index 089bcf4..0000000
--- a/libraries/ostrich/backend/ldpath/parser_base.cc
+++ /dev/null
@@ -1,5 +0,0 @@
-//
-// Created by wastl on 15.02.16.
-//
-
-#include "parser_base.h"
http://git-wip-us.apache.org/repos/asf/marmotta/blob/310ce408/libraries/ostrich/backend/ldpath/parser_base.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/ldpath/parser_base.h b/libraries/ostrich/backend/ldpath/parser_base.h
deleted file mode 100644
index ba415de..0000000
--- a/libraries/ostrich/backend/ldpath/parser_base.h
+++ /dev/null
@@ -1,304 +0,0 @@
-//
-// Created by wastl on 15.02.16.
-//
-
-#ifndef MARMOTTA_PARSER_BASE_H
-#define MARMOTTA_PARSER_BASE_H
-
-#include <utility>
-#include <map>
-#include <string>
-
-#include <model/rdf_model.h>
-
-namespace marmotta {
-namespace ldpath {
-namespace parser {
-
-template<Node>
-class LdPathParser<Node> {
-
- private:
- enum Mode { RULE, SELECTOR, TEST, PROGRAM, PREFIX };
-
- /**
- * A map mapping from namespace prefix to namespace URI
- */
- std::map<std::string,std::string> namespaces;
-
- Mode mode;
-
- public:
- LdPathParser(NodeBackend<Node> backend, Reader in) {
- this(backend,null,in);
- }
-
- public LdPathParser(NodeBackend<Node> backend, Configuration config, Reader in) {
- this(in);
- this.backend = backend;
- if(config == null) {
- this.config = new DefaultConfiguration();
- } else {
- this.config = config;
- }
-
- initialise();
- }
-
- public LdPathParser(NodeBackend<Node> backend, InputStream in) {
- this(backend,null,in);
- }
-
- public LdPathParser(NodeBackend<Node> backend, Configuration config, InputStream in) {
- this(in);
- this.backend = backend;
- if(config == null) {
- this.config = new DefaultConfiguration();
- } else {
- this.config = config;
- }
-
- initialise();
- }
-
- public LdPathParser(NodeBackend<Node> backend, InputStream in, String encoding) {
- this(backend,null,in,encoding);
- }
-
- public LdPathParser(NodeBackend<Node> backend, Configuration config, InputStream in, String encoding) {
- this(in,encoding);
- this.backend = backend;
- if(config == null) {
- this.config = new DefaultConfiguration();
- } else {
- this.config = config;
- }
-
- initialise();
- }
-
- public Program<Node> parseProgram() throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
-
- mode = Mode.PROGRAM;
- try {
- return Program();
- } catch(TokenMgrError error){
- throw new ParseException("Unable to parse Program: (Message: "+error.getMessage()+")");
- }
- }
-
- public Entry<String, String> parsePrefix() throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
- mode = Mode.PREFIX;
- try {
- return Namespace();
- } catch (TokenMgrError error) {
- throw new ParseException("Unable to parse Prefix: (Message: "+ error.getMessage()+")");
- }
- }
-
- public Map<String, String> parsePrefixes() throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
- mode = Mode.PREFIX;
- try {
- return Namespaces();
- } catch (TokenMgrError error) {
- throw new ParseException("Unable to parse Prefixes: (Message: "+ error.getMessage()+")");
- }
- }
-
-
- public NodeSelector<Node> parseSelector(Map<String,String> ctxNamespaces) throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
- if(ctxNamespaces != null) {
- namespaces.putAll(ctxNamespaces);
- }
-
- mode = Mode.SELECTOR;
-
- try {
- return Selector();
- } catch(TokenMgrError error){
- throw new ParseException("Unable to parse Selector: (Message: "+error.getMessage()+")");
- }
- }
-
- public NodeTest<Node> parseTest(Map<String, String> ctxNamespaces) throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
- if (ctxNamespaces != null) {
- namespaces.putAll(ctxNamespaces);
- }
- mode = Mode.TEST;
- try {
- return NodeTest();
- } catch (TokenMgrError error) {
- throw new ParseException("Unable to parse Test: (Message: "+ error.getMessage()+")");
- }
- }
-
- public <T> FieldMapping<T,Node> parseRule(Map<String,String> ctxNamespaces) throws ParseException {
- namespaces.clear();
- namespaces.putAll(config.getNamespaces());
- if(ctxNamespaces != null) {
- namespaces.putAll(ctxNamespaces);
- }
-
- mode = Mode.RULE;
-
- try {
- return Rule();
- } catch(TokenMgrError error){
- throw new ParseException("Unable to parse Rule: (Message: "+error.getMessage()+")");
- }
- }
-
- public Node resolveURI(URI uri) {
- return backend.createURI(uri.toString());
- }
-
- 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);
- if(uri == null) {
- throw new ParseException("Namespace "+prefix+" not defined!");
- }
- return uri;
- }
-
-
- public SelectorFunction<Node> getFunction(String uri) throws ParseException {
- if(xsdNodeFunctionMap.get(uri) != null) {
- return xsdNodeFunctionMap.get(uri);
- } else {
- throw new ParseException("function with URI "+uri+" does not exist");
- }
- }
-
- public TestFunction<Node> getTestFunction(String uri) throws ParseException {
- if (xsdNodeTestMap.get(uri) != null) {
- return xsdNodeTestMap.get(uri);
- } else {
- throw new ParseException("test function with URI "+uri+" does not exist");
- }
- }
-
- 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);
- } else {
- throw new ParseException("transformer with URI "+uri+" does not exist");
- }
- }
-
-
- private void initialise() {
- initTransformerMappings();
- initFunctionMappings();
- }
-
- /**
- * Register the function passed as argument in this parser's function map.
- */
- public void registerFunction(SelectorFunction<Node> function) {
- registerFunction(xsdNodeFunctionMap,function);
- }
-
- public void registerFunction(TestFunction<Node> test) {
- registerTest(xsdNodeTestMap, test);
- }
-
- /**
- * Register the result transformer passed as argument for the given type uri.
- */
- public void registerTransformer(String typeUri, NodeTransformer<?,Node> transformer) {
- xsdNodeTransformerMap.put(typeUri,transformer);
- }
-
-
- /**
- * A map mapping from XSD types to node transformers.
- */
- private Map<String, NodeTransformer<?,Node>> xsdNodeTransformerMap;
- private void initTransformerMappings() {
- Map<String, NodeTransformer<?,Node>> transformerMap = new HashMap<String, NodeTransformer<?,Node>>();
-
- transformerMap.putAll(config.getTransformers());
-
- xsdNodeTransformerMap = transformerMap;
- }
-
-
- private Map<String, SelectorFunction<Node>> xsdNodeFunctionMap;
- private Map<String, TestFunction<Node>> xsdNodeTestMap;
- private void initFunctionMappings() {
- Map<String, SelectorFunction<Node>> functionMap = new HashMap<String, SelectorFunction<Node>>();
-
- functionMap.putAll(config.getFunctions());
-
- xsdNodeFunctionMap = functionMap;
-
- Map<String, TestFunction<Node>> testMap = new HashMap<String, TestFunction<Node>>();
- testMap.putAll(config.getTestFunctions());
- xsdNodeTestMap = testMap;
- }
-
- private void registerFunction(Map<String, SelectorFunction<Node>> register, final SelectorFunction<Node> function) {
- register.put(NS_LMF_FUNCS + function.getPathExpression(backend), function);
- }
-
- private void registerTest(Map<String, TestFunction<Node>> register, final TestFunction<Node> test) {
- register.put(NS_LMF_FUNCS + test.getLocalName(), test);
- }
-
- private class Namespace implements Entry<String, String> {
- private String key, val;
- public Namespace(String key, String val) {
- this.key = key;
- this.val = val;
- }
- @Override
- public String getKey() {
- return key;
- }
- @Override
- public String getValue() {
- return val;
- }
- @Override
- public String setValue(String value) {
- String oV = val;
- val = value;
- return oV;
- }
- }
-
-}
-
-}
-}
-}
-
-
-#endif //MARMOTTA_PARSER_BASE_H