GitHub user ales004 opened a pull request:
https://github.com/apache/jena/pull/132
afn:Sprintf implementation (JENA-967)
Hi,
I implemented the afn:sprintf function. In order to implement it, I had to:
- create a sprintf.java class in the sparql function part.
- implement in the XSDFuncOp.java a function dealing with making sprintf
- create a series of tests checking that the function is working correctly.
While implementing, I realized that the example described in the bug is
just one of the possibilities (printing numbers) as by the Java specification,
String.Format works with all types. I thus implemented the function to work
with all the type that made sense in my opinion (we can discuss about this).
There is still one problem that I am not sure how to solve:
Test 04 and 07 and 08 depend on the user locale (it will be printed as
1.2.. or 1,2.. or with date the day or month depend on the locale). In order to
solve this, we will need to show to String.Format the current locale but I
could not find a way to do this from the XSDFuncOp class.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ales004/jena master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jena/pull/132.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #132
----
commit e2b7c9a9f1c922f8290c704465483e30f9178ef9
Author: ales004 <[email protected]>
Date: 2016-03-17T20:09:47Z
Correct a small typo in the TestFunctions2 file.
commit a0cea2c45a4bc9ed2cfb6601c253e702d9ff5751
Author: ales004 <[email protected]>
Date: 2016-03-17T20:07:25Z
Implemented the afn:sprintf function that uses the String.format Java
function to format an input value to string. In the current implementation, the
input value can be a number, a string, a date or a datetime value. Other types
are not accepted.
----
---
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.
---