Skip to content

Commit

Permalink
Merge branch 'main' into 219-load-module-from-parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan authored Aug 14, 2024
2 parents 7123a9c + 88f2231 commit 16900fc
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,29 @@ public void load(final InputStream is, final String lang) throws IOException {

@Override
public String toString() {
return binding.asMap().toString();
return binding.asMap()
.entrySet()
.stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
e -> toString(e.getValue())
))
.toString();
}

private static String toString(RDFNode node) {
if (node.isLiteral()) {
return "\"" + node.asLiteral().getLexicalForm() + "\"";
} else if (node.isURIResource() || node.isResource()) {
return "<" + node.asResource().getURI() + ">";
} else {
return node.toString();
}
}

public String toTruncatedString() {
return binding.asMap().entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), getTruncatedValue(e.getValue().toString()))).
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), getTruncatedValue(toString(e.getValue())))).
collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)).toString();
}

Expand Down

0 comments on commit 16900fc

Please sign in to comment.