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 2020/04/10 13:02:20 UTC
[jena] branch master updated: JENA-1863: Correctly indent when
using "a"
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/master by this push:
new d12f0f1 JENA-1863: Correctly indent when using "a"
new 53b9e30 Merge pull request #723 from afs/jena1863-format-bgp
d12f0f1 is described below
commit d12f0f1914a6f455496cdd532d03e3e9fa64a4a4
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Wed Apr 8 12:11:23 2020 +0100
JENA-1863: Correctly indent when using "a"
---
.../jena/sparql/serializer/FormatterElement.java | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
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 56dabb7..e3a6aa6 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
@@ -605,7 +605,7 @@ public class FormatterElement extends FormatterBase implements ElementVisitor {
if ( s.length() > subjectWidth )
subjectWidth = s.length();
- String p = slotToString(t.getPredicate());
+ String p = slotToStringProperty(t.getPredicate());
if ( p.length() > predicateWidth )
predicateWidth = p.length();
}
@@ -620,17 +620,23 @@ public class FormatterElement extends FormatterBase implements ElementVisitor {
return printNoCol(s);
}
- // Assumes the indent is TRIPLES_SUBJECT_COLUMN+GAP
+ // Unadorned "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"
private static String RDFTYPE = FmtUtils.stringForNode(RDF.Nodes.type, new SerializationContext());
private int printProperty(Node p) {
- String str = slotToString(p);
- if ( p.equals(RDF.Nodes.type) && str.equals(RDFTYPE) )
- out.print("a");
- else
- out.print(str);
+ String str = slotToStringProperty(p);
+ out.print(str);
out.pad(predicateWidth);
- return str.length();
+ return out.getCol();
+ }
+
+ // String for property - includes the rule for whether to use "a" or not.
+ private String slotToStringProperty(Node p) {
+ String str = slotToString(p);
+ // If rdf:type but no rdf: then str is full URI and we use the "a" form
+ if ( str.equals(RDFTYPE) )
+ return "a";
+ return str;
}
private int printObject(Node obj) {