You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2017/06/25 09:10:54 UTC
jena git commit: JENA-369: Correct handling for the case of
union-of-one
Repository: jena
Updated Branches:
refs/heads/master 32e5f20ff -> f9c074632
JENA-369: Correct handling for the case of union-of-one
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f9c07463
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f9c07463
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f9c07463
Branch: refs/heads/master
Commit: f9c074632739ea916e6f908a6f68dda69a5af58f
Parents: 32e5f20
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Jun 25 10:01:45 2017 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jun 25 10:01:45 2017 +0100
----------------------------------------------------------------------
.../apache/jena/sparql/serializer/FormatterElement.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f9c07463/jena-arq/src/main/java/org/apache/jena/sparql/serializer/FormatterElement.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/serializer/FormatterElement.java b/jena-arq/src/main/java/org/apache/jena/sparql/serializer/FormatterElement.java
index 4a0f867..56dabb7 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/serializer/FormatterElement.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/serializer/FormatterElement.java
@@ -243,10 +243,16 @@ public class FormatterElement extends FormatterBase implements ElementVisitor {
@Override
public void visit(ElementUnion el) {
- if ( el.getElements().size() <= 1 ) {
- // If this is an element of just one (or none), just do it in-place
+ if ( el.getElements().size() == 0 ) {
+ // If this is a union of zero elements, do nothing.
return ;
}
+
+ if ( el.getElements().size() == 0 ) {
+ // If this is a union of one elements, put in a {}-group
+ visitAsGroup(el.getElements().get(0));
+ return;
+ }
if ( UNION_MARKERS ) {
out.print("{");