[
https://issues.apache.org/jira/browse/JENA-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16559906#comment-16559906
]
ASF GitHub Bot commented on JENA-1578:
--------------------------------------
Github user ajs6f commented on a diff in the pull request:
https://github.com/apache/jena/pull/449#discussion_r205813086
--- Diff:
jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java ---
@@ -1734,4 +1740,243 @@ public String toString() {
}
}
+
+ /**
+ * Assign a varName with a multiple items and whether to include
+ * parenthesis.
+ *
+ * @param varName
+ * @param items
+ * @param isParenthesisNeeded
+ */
+ public void setValues(String varName, Collection<? extends RDFNode>
items, boolean isParenthesisNeeded) {
+ this.valuesReplacements.put(varName, new ValueReplacement(varName,
items, isParenthesisNeeded));
+ }
+
+ /**
+ * Assign a varName with a multiple items.<br>
+ * Can be used to assign multiple values to a single variable or single
+ * value to multiple variables (if using a List) in the SPARQL
query.<br>
+ * See setGroupedValues to assign multiple values to multiple
variables.
+ *
+ * @param varName
+ * @param items
+ */
+ public void setValues(String varName, Collection<? extends RDFNode>
items) {
+ setValues(varName, items, false);
+ }
+
+ /**
+ * Assign a varName with a single item and whether to include
parenthesis.
+ *
+ * @param varName
+ * @param item
+ * @param isParenthesisNeeded
+ */
+ public void setValues(String varName, RDFNode item, boolean
isParenthesisNeeded) {
+ setValues(varName, Arrays.asList(item), isParenthesisNeeded);
+ }
+
+ /**
+ * Assign a varName with a single item.
+ *
+ * @param varName
+ * @param item
+ */
+ public void setValues(String varName, RDFNode item) {
+ setValues(varName, Arrays.asList(item), false);
+ }
+
+ /**
+ * Sets a map of varNames and their items.
+ *
+ * @param valuesItems
+ */
+ public void setValues(Map<String, Collection<? extends RDFNode>>
valuesItems) {
+ for (String varName : valuesItems.keySet()) {
--- End diff --
Just a style thing, really, but I believe this method could be just
`valuesItems.forEach(this::setValues)`.
> SPARQL VALUES for ParameterizedSparqlString
> -------------------------------------------
>
> Key: JENA-1578
> URL: https://issues.apache.org/jira/browse/JENA-1578
> Project: Apache Jena
> Issue Type: New Feature
> Components: ARQ
> Affects Versions: Jena 3.8.0
> Reporter: Greg Albiston
> Priority: Minor
>
> ParameterizedSparqlString provides an API for substituting variables within
> SPARQL queries with bound values. It does not support the SPARQL VALUES
> keyword which allows multiple values to be specified. The VALUES syntax
> supports multiple values for a single variable, sets of values for multiple
> variables and multiple sets of values for multiple values.
> Inquiry on 24/07/18 the mailing list about this feature. Patch is forthcoming.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)