From 1e000864e2c889b5036539bf4a3c9f5a3be7e52e Mon Sep 17 00:00:00 2001 From: Enrico Daga Date: Mon, 28 Mar 2022 13:35:12 +0100 Subject: [PATCH] Moving property names to constants. Add documentation #201 -- #202 #203 #233 #235 --- .../com/github/sparqlanything/json/JSONTriplifier.java | 7 +++---- .../java/com/github/sparqlanything/xml/XMLTriplifier.java | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sparql-anything-json/src/main/java/com/github/sparqlanything/json/JSONTriplifier.java b/sparql-anything-json/src/main/java/com/github/sparqlanything/json/JSONTriplifier.java index 867a40e6..75a0cdfe 100644 --- a/sparql-anything-json/src/main/java/com/github/sparqlanything/json/JSONTriplifier.java +++ b/sparql-anything-json/src/main/java/com/github/sparqlanything/json/JSONTriplifier.java @@ -37,7 +37,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -53,7 +52,7 @@ public class JSONTriplifier implements Triplifier, Slicer { private static Logger logger = LoggerFactory.getLogger(JSONTriplifier.class); - + public static final String PROPERTY_JSONPATH = "json.path"; // private String[] getDataSources(URL url) { // return new String[] { url.toString() }; // } @@ -415,7 +414,7 @@ private Iterable sliceFromJSONPath(Properties properties) throws Triplifi Collector collector = surfer.collector(us); List jsonPathExpr = new ArrayList(); final Set>> matches = new HashSet>>(); - List jsonPaths = Triplifier.getPropertyValues(properties, "json.path"); + List jsonPaths = Triplifier.getPropertyValues(properties, PROPERTY_JSONPATH); for(String jpath: jsonPaths) { ValueBox> m = collector.collectAll(jpath); matches.add(m); @@ -489,7 +488,7 @@ public Slice next() { @Override public Iterable slice(Properties properties) throws IOException, TriplifierHTTPException { - List jsonPaths = Triplifier.getPropertyValues(properties, "json.path"); + List jsonPaths = Triplifier.getPropertyValues(properties, PROPERTY_JSONPATH); if(!jsonPaths.isEmpty()){ return sliceFromJSONPath(properties); }else { diff --git a/sparql-anything-xml/src/main/java/com/github/sparqlanything/xml/XMLTriplifier.java b/sparql-anything-xml/src/main/java/com/github/sparqlanything/xml/XMLTriplifier.java index 9ac8f8f3..a9010a89 100644 --- a/sparql-anything-xml/src/main/java/com/github/sparqlanything/xml/XMLTriplifier.java +++ b/sparql-anything-xml/src/main/java/com/github/sparqlanything/xml/XMLTriplifier.java @@ -66,6 +66,8 @@ public class XMLTriplifier implements Triplifier, Slicer { private static final Logger log = LoggerFactory.getLogger(XMLTriplifier.class); + public static final String PROPERTY_XPATH = "xml.path"; + private VTDNav buildVTDNav(Properties properties) throws TriplifierHTTPException, IOException, ParseException { VTDGen vg = new VTDGen(); byte[] bytes = IOUtils.toByteArray(Triplifier.getInputStream(properties)); @@ -395,7 +397,7 @@ public Set getExtensions() { @Override public void triplify(Properties properties, FacadeXGraphBuilder builder) throws IOException, TriplifierHTTPException { - List xpaths = Triplifier.getPropertyValues(properties, "xml.path"); + List xpaths = Triplifier.getPropertyValues(properties, PROPERTY_XPATH); if(!xpaths.isEmpty()){ transformWithXPath(xpaths, properties, builder); }else{ @@ -407,7 +409,7 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws public Iterable slice(Properties properties) throws IOException, TriplifierHTTPException { final String dataSourceId = Triplifier.getRootArgument(properties); final String root = Triplifier.getRootArgument(properties); - List xpaths = Triplifier.getPropertyValues(properties, "xml.path"); + List xpaths = Triplifier.getPropertyValues(properties, PROPERTY_XPATH); try { VTDNav vn = buildVTDNav(properties);