Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1066

Node_Factory.createLiteralByValue creates malformed literals from BigDecimal values

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Jena 2.13.0, Jena 3.0.0
    • Fix Version/s: Jena 3.0.1
    • Component/s: Core, Datatypes
    • Labels:


      I've been working with some numeric data and have run into some problems when using:

          Node_Factory.createLiteralByValue(Object value, RDFDatatype dtype) 

      when value is a BigDecimal.

      Jena ultimately uses BigDecimal.toString() to generate lexical forms for well-formed-ness checking and to provide results for .getLexicalForm() on the resulting Node_Literal. Unfortunately Java 1.5 changed the behaviour of BigDecimal.toString() and added BigDecimal.toPlainString() which it describes as an analog of the java 1.4 BigDecimal.toString() and which specifically does not use exponential notation in its output. xsd:decimal lexicalforms do not allow exponential notation

      I'll attached small java program that illustrates the problem. The cases where a dud literal form (i.e. as a literal in exponent from) are fair enough.

      I've also locally created a fix that special cases instances of BigDecimal in a couple of places. Patch file to be attached.

      With the fix applied the literals arising from Node_Factory.createLiteralByValue calls with a BigDecimal value are wellformed.


        1. BigDecimalTestCase.java
          2 kB
          Stuart Williams
        2. git-diff.txt
          1 kB
          Stuart Williams



            • Assignee:
              andy Andy Seaborne
              skw@lilac-cottage.org.uk Stuart Williams


              • Created:

                Issue deployment