Github user ales004 commented on a diff in the pull request:
https://github.com/apache/jena/pull/132#discussion_r58619008
--- Diff:
jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java ---
@@ -352,6 +352,60 @@ public static NodeValue javaSubstring(NodeValue
nvString, NodeValue nvStart, Nod
}
}
+ // expecting nvString = format | nvStart = value (int,float,
string,....)
+ public static NodeValue javaSprintf(NodeValue nvFormat, NodeValue
nvValue) {
+ try {
+ String formatForOutput = nvFormat.getString() ;
+ ValueSpaceClassification vlSpClass = nvValue.getValueSpace();
+ switch(vlSpClass){
+ case VSPACE_NUM:
+ NumericType type =
classifyNumeric("javaSprintf",nvValue);
+ switch(type) {
+ case OP_DECIMAL:
+ BigDecimal decimalValue = nvValue.getDecimal();
+ return
NodeValue.makeString(String.format(formatForOutput,decimalValue)) ;
+ case OP_INTEGER:
+ BigInteger integerValue = nvValue.getInteger();
+ return
NodeValue.makeString(String.format(formatForOutput,integerValue)) ;
+ case OP_DOUBLE:
+ Double doubValue = nvValue.getDouble();
+ return
NodeValue.makeString(String.format(formatForOutput,doubValue)) ;
+ case OP_FLOAT:
+ Float floatValue = nvValue.getFloat();
+ return
NodeValue.makeString(String.format(formatForOutput,floatValue)) ;
--- End diff --
Depending on the Locale: 1.23 can be printed as 1.23 or 1,23
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---