jscience
  1. jscience
  2. JSCIENCE-106

jsr-275 0.8 UnitConverter formatting not idempotent

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: Version 6.0
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      106

      Description

      Idempotence might not be the correct term but UnitFormat isn't capable to parse
      back formatted unit when applied to TransformedUnit.

      degree_angle [s*60/1]^-1 is such an example where UnitConverter brackets cause
      parsing error. CompoundUnit seems to do soas well. Formatting on the other hand
      can only handle add, multiply and rational converters.

      My solution to fix the problem is to introduce toString and valueOf methods to
      converters and to delegate the formatting to them allowing new unit converters
      to be implemented without worrying about formatting/parsing.

        Activity

        Hide
        tuomas_kiviaho added a comment -

        I pulled out trunk from CVS and I noticed that square backets are not used
        anymore so give example is invalid.

        Nevertheless CompoundUnit and other converters were also neglected.
        TransformedUnit can't be expanded so there really can't be other converters
        although there is a fallback section still in the code. I assume assertion to be
        more appropriate approach.

        CompoundUnit seems not to be working correctly. From documentation I dug out and
        example NonSI.HOUR.compound(NonSI.MINUTE) that evaluates to h:min (the other
        example at javadoc pointed to absent NonSI.DEGREE_MINUTE). ':' separator is
        determined to be part of identifier so the parser is unable to split the expression.

        Show
        tuomas_kiviaho added a comment - I pulled out trunk from CVS and I noticed that square backets are not used anymore so give example is invalid. Nevertheless CompoundUnit and other converters were also neglected. TransformedUnit can't be expanded so there really can't be other converters although there is a fallback section still in the code. I assume assertion to be more appropriate approach. CompoundUnit seems not to be working correctly. From documentation I dug out and example NonSI.HOUR.compound(NonSI.MINUTE) that evaluates to h:min (the other example at javadoc pointed to absent NonSI.DEGREE_MINUTE). ':' separator is determined to be part of identifier so the parser is unable to split the expression.

          People

          • Assignee:
            jscience-issues
            Reporter:
            tuomas_kiviaho
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: