diff --git a/src/doc/JSR-275.uml b/src/doc/JSR-275.uml new file mode 100644 index 0000000..afdf856 --- /dev/null +++ b/src/doc/JSR-275.uml @@ -0,0 +1,1463 @@ + + + + + + +UMLStandard + + + + +Untitled +5 + +Use Case Model +UMLStandard +useCaseModel +VcAKAm5HLkua0s+gDWv7jwAA +1 + +Main +42MWb3qbPUCE24ty9WEjigAA + +8SsA7P7M+kyY0ty+/t1LmQAA + + + + +Analysis Model +UMLStandard +analysisModel +VcAKAm5HLkua0s+gDWv7jwAA +1 + +Main +True +RobustnessDiagram +b1lpK9K0UEatJHWJLEM+ZgAA + +cBkKshXOyEaIi+360S68WAAA + + + + +Design Model +UMLStandard +designModel +VcAKAm5HLkua0s+gDWv7jwAA +1 + +Main +True +WR7RVMRaZk++bLdyR0MWMQAA + +pc4NorAoZ02H4Z2vZKD1eQAA +4 + +clMaroon +$00B9FFFF +20 +8 +120 +70 +EYisqWLRuEin21GF7Se8XAAA + + +quantity + + +False + + +False + + + + +clMaroon +$00B9FFFF +20 +88 +120 +70 +mtWYKGwud0O8JgiZ275cwgAA + + +unit + + +False + + +False + + + + +clMaroon +$00B9FFFF +212 +16 +59 +45 +sdkIcon +XaPoBenZZEu29iS1fAxisQAA + + +1 +Quantity + + +False + + +False + + + +False +XaPoBenZZEu29iS1fAxisQAA + + +False +XaPoBenZZEu29iS1fAxisQAA + + + +clMaroon +$00B9FFFF +208 +92 +317 +303 +Sh59W1JzjEKyBSV/ecykRAAA + + +1 +Unit + + +False + + +False + + + +Sh59W1JzjEKyBSV/ecykRAAA + + +Sh59W1JzjEKyBSV/ecykRAAA + + +False +Sh59W1JzjEKyBSV/ecykRAAA + + + + +1 + +javax +WR7RVMRaZk++bLdyR0MWMQAA +1 + +measure +/9Fn4Qmh7k6nJQv1LQiS0AAA +2 + +quantity +uSOo6kEo0UuBcq54UmvLXQAA +1 +GzCzyEPljE6YzDaqxqYwNQAA +1 + +quantity +EYisqWLRuEin21GF7Se8XAAA + +5LUtTEJwT0O+Fynr5Yx2RQAA +1 + +clMaroon +$00B9FFFF +12 +56 +44 +286 +154 +sdkIcon +XaPoBenZZEu29iS1fAxisQAA + + +1 +Quantity + + +False + + +False + + + +False +XaPoBenZZEu29iS1fAxisQAA + + +XaPoBenZZEu29iS1fAxisQAA + + + + +1 + +Quantity +EYisqWLRuEin21GF7Se8XAAA +6 +68W8YpSDJEuisxQxT/Vq4QAA +WXh8r+9LS0a2j6G05mbrNQAA +XkMl8Xxay06oFxIBBdRhcQAA +eO8F6STJPkynH0jnPxIL4gAA +NRF7ceZxo0aG5cNmwEEvRgAA +P/EPYj/rq0aUukjE0yoSmwAA +5 + +getUnit +XaPoBenZZEu29iS1fAxisQAA +1 + +pdkReturn +Unit<Q> +/BsxOfOSd0ehXwMIu6U6wgAA + + + +getValue +XaPoBenZZEu29iS1fAxisQAA +1 + +pdkReturn +Number ++yojku0EYEyYgZqPh/JDZQAA + + + +getValue +XaPoBenZZEu29iS1fAxisQAA +2 + +pdkReturn +Number +8z/XDa/m+kKda5+BpuFrGwAA + + +Unit<Q> unit +8z/XDa/m+kKda5+BpuFrGwAA + + + +doubleValue +XaPoBenZZEu29iS1fAxisQAA +2 + +pdkReturn +double +QZL/U1OYp0WHz9l7XnNZFAAA + + +Unit<Q> unit +QZL/U1OYp0WHz9l7XnNZFAAA + + + +longValue +XaPoBenZZEu29iS1fAxisQAA +2 + +pdkReturn +long +4rYAY7nVkEu0lsKFtO1/0gAA + + +Unit<Q> unit +4rYAY7nVkEu0lsKFtO1/0gAA + + + + + +unit +uSOo6kEo0UuBcq54UmvLXQAA +1 +5Lm2Ah6s+kGNHvzklYeXAAAA +1 + +unit +mtWYKGwud0O8JgiZ275cwgAA + +XigisKGk6Umkx9Gp+I0LegAA +1 + +clMaroon +$00B9FFFF +12 +56 +52 +456 +429 +Sh59W1JzjEKyBSV/ecykRAAA + + +1 +Unit + + +False + + +False + + + +Sh59W1JzjEKyBSV/ecykRAAA + + +Sh59W1JzjEKyBSV/ecykRAAA + + +False +Sh59W1JzjEKyBSV/ecykRAAA + + + + +4 + +format +mtWYKGwud0O8JgiZ275cwgAA +9 + +ParseException +vkPackage +oRQMLn37g0S0p6GQfyKzagAA +4 + +ParseException +UMLStandard +create +4UKkYBZpxkGzsZrlJ8fpCgAA +3 + +currentTokenVal +6j6bxQAPCEqIJVTNnKS7ZgAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + +expectedTokenSequencesVal +int +6j6bxQAPCEqIJVTNnKS7ZgAA +1 + +Java +JavaDimensions +JavaDimensions +2 +yeNDjof980mK5+fxXomOMQAA + + + +tokenImageVal +String +6j6bxQAPCEqIJVTNnKS7ZgAA +1 + +Java +JavaDimensions +JavaDimensions +1 +YYmSVxKayUSFgc5mTson4AAA + + + + +ParseException +UMLStandard +create +4UKkYBZpxkGzsZrlJ8fpCgAA + + +ParseException +UMLStandard +create +4UKkYBZpxkGzsZrlJ8fpCgAA +1 + +message +String +6BiNPAb+jky4Tn8DjhbsKwAA + + + +add_escapes +vkPackage +skClassifier +4UKkYBZpxkGzsZrlJ8fpCgAA +2 + +str +String +Y41o1s+8Fka76d3q0rkldwAA + + +return +pdkReturn +String +Y41o1s+8Fka76d3q0rkldwAA + + +1 +tBYCmOiwPEmrJS3J5yl7OwAA +3 + +expectedTokenSequences +* +int +4UKkYBZpxkGzsZrlJ8fpCgAA +1 + +Java +JavaDimensions +JavaDimensions +2 +zACd4TQo+UaWztLMXIEGTQAA + + + +tokenImage +* +String +4UKkYBZpxkGzsZrlJ8fpCgAA +1 + +Java +JavaDimensions +JavaDimensions +1 +6sWvbQBXpU20zFtsa5PzXgAA + + + +eol +vkProtected +String +System.getProperty("line.separator", "\n") +4UKkYBZpxkGzsZrlJ8fpCgAA + + + +Token +vkPackage +oRQMLn37g0S0p6GQfyKzagAA +7 + +Token +UMLStandard +create +YB5KmgJ3d0eBOKBDDO/MJAAA + + +Token +UMLStandard +create +YB5KmgJ3d0eBOKBDDO/MJAAA +1 + +kind +int +ylsrpDUSOU2/B9HYWiYclwAA + + + +Token +UMLStandard +create +YB5KmgJ3d0eBOKBDDO/MJAAA +2 + +kind +int +xwCp6BfjE0arH3N/raqEfQAA + + +image +String +xwCp6BfjE0arH3N/raqEfQAA + + + +getValue +YB5KmgJ3d0eBOKBDDO/MJAAA +1 + +return +pdkReturn +Object +casr0pchvkCLWR9DoJRduwAA + + + +toString +YB5KmgJ3d0eBOKBDDO/MJAAA +1 + +return +pdkReturn +String +7tc7Ge/BuEGcLaUwJYKXXAAA + + + +newToken +skClassifier +YB5KmgJ3d0eBOKBDDO/MJAAA +3 + +ofKind +int +IK4c80HyQkOQu2DfihQRAgAA + + +image +String +IK4c80HyQkOQu2DfihQRAgAA + + +return +pdkReturn +IK4c80HyQkOQu2DfihQRAgAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + + +newToken +skClassifier +YB5KmgJ3d0eBOKBDDO/MJAAA +2 + +ofKind +int +F+NzrdZ1HESzyvUmb1Hj7gAA + + +return +pdkReturn +F+NzrdZ1HESzyvUmb1Hj7gAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + +5 +S+ER+Zj2RUmoLbvLwQYYugAA +YZC1I1yZhkiR0Za7kYRDJwAA +wfIsdVPT40yMRohyLHksgQAA +2LIbVKJMX0yks9t6/TAidgAA +6Ujiwo09iEuw/A4iozBSTwAA +5 +ryIgZpF8MUCWYaIj54u2FAAA +OZDCziIDgEmHpAkZwqaF6wAA +tA1wOg2SlkKgGY4Ibo8eJwAA +SvhLethaBUSr08mgqeXQ5gAA +W6sGRXRIOEisfoQJNQPvtAAA +6 + +kind +vkPackage +int +YB5KmgJ3d0eBOKBDDO/MJAAA + + +beginLine +vkPackage +int +YB5KmgJ3d0eBOKBDDO/MJAAA + + +beginColumn +vkPackage +int +YB5KmgJ3d0eBOKBDDO/MJAAA + + +endLine +vkPackage +int +YB5KmgJ3d0eBOKBDDO/MJAAA + + +endColumn +vkPackage +int +YB5KmgJ3d0eBOKBDDO/MJAAA + + +image +vkPackage +String +YB5KmgJ3d0eBOKBDDO/MJAAA + + + +TokenMgrError +vkPackage +oRQMLn37g0S0p6GQfyKzagAA +6 + +TokenMgrError +UMLStandard +create +WXz8GbdLj0qSscfk9G4ZAgAA + + +TokenMgrError +UMLStandard +create +WXz8GbdLj0qSscfk9G4ZAgAA +2 + +message +String +h4+6qQOyBEmEqgDrUjA8NgAA + + +reason +int +h4+6qQOyBEmEqgDrUjA8NgAA + + + +TokenMgrError +UMLStandard +create +WXz8GbdLj0qSscfk9G4ZAgAA +7 + +EOFSeen +boolean +9qZhxYYZC0GCV7M8YtJUpwAA + + +lexState +int +9qZhxYYZC0GCV7M8YtJUpwAA + + +errorLine +int +9qZhxYYZC0GCV7M8YtJUpwAA + + +errorColumn +int +9qZhxYYZC0GCV7M8YtJUpwAA + + +errorAfter +String +9qZhxYYZC0GCV7M8YtJUpwAA + + +curChar +char +9qZhxYYZC0GCV7M8YtJUpwAA + + +reason +int +9qZhxYYZC0GCV7M8YtJUpwAA + + + +addEscapes +vkProtected +skClassifier +True +WXz8GbdLj0qSscfk9G4ZAgAA +2 + +str +String +xer33lhdr0OBw0Uz17Y0BAAA + + +return +pdkReturn +String +xer33lhdr0OBw0Uz17Y0BAAA + + + +LexicalError +vkProtected +skClassifier +WXz8GbdLj0qSscfk9G4ZAgAA +7 + +EOFSeen +boolean ++KTistYlV0KAGC0mKFAbKAAA + + +lexState +int ++KTistYlV0KAGC0mKFAbKAAA + + +errorLine +int ++KTistYlV0KAGC0mKFAbKAAA + + +errorColumn +int ++KTistYlV0KAGC0mKFAbKAAA + + +errorAfter +String ++KTistYlV0KAGC0mKFAbKAAA + + +curChar +char ++KTistYlV0KAGC0mKFAbKAAA + + +return +pdkReturn +String ++KTistYlV0KAGC0mKFAbKAAA + + + +getMessage +WXz8GbdLj0qSscfk9G4ZAgAA +1 + +return +pdkReturn +String +xAuFzx99i0qss0WInRI9fQAA + + +5 + +LEXICAL_ERROR +vkPackage +skClassifier +ckFrozen +int +0 +WXz8GbdLj0qSscfk9G4ZAgAA + + +STATIC_LEXER_ERROR +vkPackage +skClassifier +ckFrozen +int +1 +WXz8GbdLj0qSscfk9G4ZAgAA + + +INVALID_LEXICAL_STATE +vkPackage +skClassifier +ckFrozen +int +2 +WXz8GbdLj0qSscfk9G4ZAgAA + + +LOOP_DETECTED +vkPackage +skClassifier +ckFrozen +int +3 +WXz8GbdLj0qSscfk9G4ZAgAA + + +errorCode +vkPackage +int +WXz8GbdLj0qSscfk9G4ZAgAA + + + +UnitParserConstants +oRQMLn37g0S0p6GQfyKzagAA +1 +BTV0fEjO50CErlf0uoon/QAA + + +UnitParserTokenManager +vkPackage +oRQMLn37g0S0p6GQfyKzagAA +1 +BTV0fEjO50CErlf0uoon/QAA +8 + +UnitParserTokenManager +UMLStandard +create +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +stream +SimpleCharStream +u6AQRrd1eUmKIytwsyPn3QAA + + + +UnitParserTokenManager +UMLStandard +create +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +2 + +stream +SimpleCharStream +ze1V8q79J0O2Jo0tKNZj0wAA + + +lexState +int +ze1V8q79J0O2Jo0tKNZj0wAA + + + +setDebugStream +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +ds +java.io.PrintStream +R2BYiGE/SkC/+/K6q+9MoAAA + + + +reInit +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +stream +SimpleCharStream +wAOC2fkcnUOd6STT/V4ZJAAA + + + +reInit +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +2 + +stream +SimpleCharStream +6N6wxxzT+U+RquwJUn3UDgAA + + +lexState +int +6N6wxxzT+U+RquwJUn3UDgAA + + + +switchTo +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +lexState +int +nlkmoy3/BU+v5gwOXqu4vgAA + + + +jjFillToken +vkProtected +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +return +pdkReturn +vc8OhdTPKEqN4xfD8Ba6mgAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + + +getNextToken +vkPackage +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +return +pdkReturn +WsFPqys9K0akkgyLKvSVNgAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + +15 + +debugStream +vkPackage +java.io.PrintStream +System.out +ErNvzFqiOUKyT9Ntr7fi/wAA + + +jjbitVec0 +vkPackage +skClassifier +* +ckFrozen +long +{ + 0x0L, 0x0L, 0x20c000000000000L, 0x0L +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +gni4HVK5TU6z0kI79p6U1gAA + + + +jjbitVec1 +vkPackage +skClassifier +* +ckFrozen +long +{ + 0x0L, 0x3f1000000000000L, 0x0L, 0x0L +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +6tqShggAXEWkUG6RPNHBtAAA + + + +jjbitVec2 +vkPackage +skClassifier +* +ckFrozen +long +{ + 0xfffffffefffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +a/hwmZZHEkmeU2jmMmzqUgAA + + + +jjbitVec4 +vkPackage +skClassifier +* +ckFrozen +long +{ + 0x0L, 0x0L, 0xfd73ffffffffffffL, 0xffffffffffffffffL +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +QSGjO8VnzEeVGX0k1Bu6CQAA + + + +jjbitVec5 +vkPackage +skClassifier +* +ckFrozen +long +{ + 0xffffffffffffffffL, 0xfc0effffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +2PZNSoumC0OfZ534Kh2SJQAA + + + +jjnextStates +vkPackage +skClassifier +* +ckFrozen +int +{ + 9, 1, 2, 3, 10, 1, 2, 3, 10, 12, 14, 4, 5, +} +ErNvzFqiOUKyT9Ntr7fi/wAA +1 + +Java +JavaDimensions +JavaDimensions +1 +Rswq0Qw87kmAeHsDv10+mgAA + + + +input_stream +vkProtected +SimpleCharStream +ErNvzFqiOUKyT9Ntr7fi/wAA + + +curChar +vkProtected +char +ErNvzFqiOUKyT9Ntr7fi/wAA + + +curLexState +vkPackage +int +0 +ErNvzFqiOUKyT9Ntr7fi/wAA + + +defaultLexState +vkPackage +int +0 +ErNvzFqiOUKyT9Ntr7fi/wAA + + +jjnewStateCnt +vkPackage +int +ErNvzFqiOUKyT9Ntr7fi/wAA + + +jjround +vkPackage +int +ErNvzFqiOUKyT9Ntr7fi/wAA + + +jjmatchedPos +vkPackage +int +ErNvzFqiOUKyT9Ntr7fi/wAA + + +jjmatchedKind +vkPackage +int +ErNvzFqiOUKyT9Ntr7fi/wAA + + + +oRQMLn37g0S0p6GQfyKzagAA +ErNvzFqiOUKyT9Ntr7fi/wAA +MS8ueXbA0U60hfK48wRh3wAA + + +oRQMLn37g0S0p6GQfyKzagAA +2 + +False +999233tYskygVheGhQt0AwAA +4UKkYBZpxkGzsZrlJ8fpCgAA + + +currentToken +999233tYskygVheGhQt0AwAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + + +oRQMLn37g0S0p6GQfyKzagAA +2 + +False +M7cI4SXi1U63Vk2AoBiCXwAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + +next +vkPackage +M7cI4SXi1U63Vk2AoBiCXwAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + + +oRQMLn37g0S0p6GQfyKzagAA +2 + +False +FoKd4q1nxEe1YBCO7GXTLQAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + +specialToken +vkPackage +FoKd4q1nxEe1YBCO7GXTLQAA +YB5KmgJ3d0eBOKBDDO/MJAAA + + + + +ConversionException +mtWYKGwud0O8JgiZ275cwgAA +1 + +ConversionException +UMLStandard +create +a/zndA8QY0emfqYo0GRNNQAA +1 + +message +String +lgdY5/37VUSkgHp8qO11FwAA + + + + +Unit +mtWYKGwud0O8JgiZ275cwgAA +8 +8ACYa5GUHkWhyo1903+BzgAA +dlxjvMHxFEiS+2cqcM0KtwAA +xod/lcvQiE+6C0Ue9mdXXAAA +eiruX8dDuU62TD6hYC+YmwAA +Jb5l2YrurE297xl2GOlmbwAA +iABuWzxFgk6LVbT57FLNZQAA +66iHt2h33kak2T3NpBh+kQAA +9yeT3iJe1EWwW6rJAGVulQAA +19 + +Unit +UMLStandard +create +vkProtected +Sh59W1JzjEKyBSV/ecykRAAA + + +valueOf +UMLStandard +create +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<?> +D0Ud3DhgF0K4QZdDmZ23YAAA + + +CharSequence charSequencel +D0Ud3DhgF0K4QZdDmZ23YAAA + + + +add +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +Is7H7D+UvEuC5TlBWu9kMQAA + + +double offset +Is7H7D+UvEuC5TlBWu9kMQAA + + + +alternate +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<A> +z06ObhJOQEWOBegQn4wr2gAA + + +String symbol +z06ObhJOQEWOBegQn4wr2gAA + + + +getSymbol +Sh59W1JzjEKyBSV/ecykRAAA +1 + +pdkReturn +String +t6ipoTRnXk602mgsYjszOQAA + + + +asType +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<T> +t5C1y2RsJUKv3io1pxZFCwAA + + +Class<T> type +t5C1y2RsJUKv3io1pxZFCwAA + + + +divide +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +eZ2nxL3ljUm88Q84hh1aAgAA + + +double divisor +eZ2nxL3ljUm88Q84hh1aAgAA + + + +divide +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +1NmkTNePqUqObXwQEuGluQAA + + +long divisor +1NmkTNePqUqObXwQEuGluQAA + + + +divide +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +e06s86R3tUiDTR+BBImRBwAA + + +Unit<?> that +e06s86R3tUiDTR+BBImRBwAA + + + +inverse +Sh59W1JzjEKyBSV/ecykRAAA +1 + +pdkReturn +Unit<?> +aenqDdZmPUqoBf4bUWatcwAA + + + +isCompatible +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +boolean +c8EyUo9JFE6URG4yzf+oqQAA + + +Unit<?> that +c8EyUo9JFE6URG4yzf+oqQAA + + + +multiply +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +zpKjTLZYMEGC70P9fn6wWwAA + + +double factor +zpKjTLZYMEGC70P9fn6wWwAA + + + +multiply +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +mB9qqXsSDUO8nkFDvhYsAgAA + + +long factor +mB9qqXsSDUO8nkFDvhYsAgAA + + + +multiply +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +MmKzHVFMJ0ute1tumwjpmQAA + + +Unit<?> that +MmKzHVFMJ0ute1tumwjpmQAA + + + +pow +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<?> +rylsX7BDe0WLLeNY4b/fPwAA + + +int n +rylsX7BDe0WLLeNY4b/fPwAA + + + +root +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<?> +a8dzOJ7IcE2/E/JGxLrIiQAA + + +int n +a8dzOJ7IcE2/E/JGxLrIiQAA + + + +toMetric +Sh59W1JzjEKyBSV/ecykRAAA +1 + +pdkReturn +Unit<Q> +S9Ej6ea53Uuw9L17HkD00AAA + + + +toString +Sh59W1JzjEKyBSV/ecykRAAA +1 + +pdkReturn +String +ZnmdNuqlqUe0BxVPj7yWSwAA + + + +transform +Sh59W1JzjEKyBSV/ecykRAAA +2 + +pdkReturn +Unit<Q> +KnX/iZhZFUODKbrrv1cfTAAA + + +UnitConverter operation +KnX/iZhZFUODKbrrv1cfTAAA + + +1 + +ONE +ckFrozen +Unit<Dimensionless> +Sh59W1JzjEKyBSV/ecykRAAA + + + +UnitConverter +mtWYKGwud0O8JgiZ275cwgAA + + + + + + +Implementation Model +UMLStandard +implementationModel +VcAKAm5HLkua0s+gDWv7jwAA +1 + +Main +vpARAVlv3Uu2xtpGD6cyXQAA + +C9jOXpcShEetPQwo7XAjMQAA + + + + +Deployment Model +UMLStandard +deploymentModel +VcAKAm5HLkua0s+gDWv7jwAA +1 + +Main +2kacznXMQEm22W1/CUwEkgAA + +/WkLqDQmAUKPUi7NCd1Z1AAA + + + + + + diff --git a/src/doc/quantity.jpg b/src/doc/quantity.jpg new file mode 100644 index 0000000..609458d Binary files /dev/null and b/src/doc/quantity.jpg differ diff --git a/src/doc/unit.jpg b/src/doc/unit.jpg new file mode 100644 index 0000000..b0f89bc Binary files /dev/null and b/src/doc/unit.jpg differ diff --git a/src/main/java/javax/measure/quantity/ElectricCapacitance.java b/src/main/java/javax/measure/quantity/ElectricCapacitance.java new file mode 100644 index 0000000..e0e23e2 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricCapacitance.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric capacitance. + * The metric system unit for this quantity is "F" (Farad). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricCapacitance extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricCharge.java b/src/main/java/javax/measure/quantity/ElectricCharge.java new file mode 100644 index 0000000..3b0b6dd --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricCharge.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric charge. + * The metric system unit for this quantity is "C" (Coulomb). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricCharge extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricConductance.java b/src/main/java/javax/measure/quantity/ElectricConductance.java new file mode 100644 index 0000000..1721021 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricConductance.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric conductance. + * The metric system unit for this quantity "S" (Siemens). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricConductance extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricCurrent.java b/src/main/java/javax/measure/quantity/ElectricCurrent.java new file mode 100644 index 0000000..bc70672 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricCurrent.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents the amount of electric charge flowing past + * a specified circuit point per unit time. + * The metric system unit for this quantity is "A" (Ampere). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricCurrent extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricInductance.java b/src/main/java/javax/measure/quantity/ElectricInductance.java new file mode 100644 index 0000000..7e992f5 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricInductance.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric inductance. + * The metric system unit for this quantity is "H" (Henry). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricInductance extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricPotential.java b/src/main/java/javax/measure/quantity/ElectricPotential.java new file mode 100644 index 0000000..20c1ce1 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricPotential.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric potential or electromotive force. + * The metric system unit for this quantity is "V" (Volt). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricPotential extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/ElectricResistance.java b/src/main/java/javax/measure/quantity/ElectricResistance.java new file mode 100644 index 0000000..cb95bb0 --- /dev/null +++ b/src/main/java/javax/measure/quantity/ElectricResistance.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents an electric resistance. + * The metric system unit for this quantity is "Ohm" (Ω). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface ElectricResistance extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/LuminousFlux.java b/src/main/java/javax/measure/quantity/LuminousFlux.java new file mode 100644 index 0000000..3f72f27 --- /dev/null +++ b/src/main/java/javax/measure/quantity/LuminousFlux.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents a luminous flux. + * The metric system unit for this quantity is "lm" (lumen). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface LuminousFlux extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/LuminousIntensity.java b/src/main/java/javax/measure/quantity/LuminousIntensity.java new file mode 100644 index 0000000..526d823 --- /dev/null +++ b/src/main/java/javax/measure/quantity/LuminousIntensity.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents the luminous flux density per solid angle as + * measured in a given direction relative to the emitting source. + * The metric system unit for this quantity is "cd" (candela). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface LuminousIntensity extends Quantity { + +} \ No newline at end of file diff --git a/src/main/java/javax/measure/quantity/MagneticFlux.java b/src/main/java/javax/measure/quantity/MagneticFlux.java new file mode 100644 index 0000000..05425fb --- /dev/null +++ b/src/main/java/javax/measure/quantity/MagneticFlux.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents a magnetic flux. + * The metric system unit for this quantity is "Wb" (Weber). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface MagneticFlux extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/MagneticFluxDensity.java b/src/main/java/javax/measure/quantity/MagneticFluxDensity.java new file mode 100644 index 0000000..b8d13d8 --- /dev/null +++ b/src/main/java/javax/measure/quantity/MagneticFluxDensity.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents a magnetic flux density. + * The metric system unit for this quantity is "T" (Tesla). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface MagneticFluxDensity extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/Quantity.java b/src/main/java/javax/measure/quantity/Quantity.java new file mode 100644 index 0000000..56e33d6 --- /dev/null +++ b/src/main/java/javax/measure/quantity/Quantity.java @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +import javax.measure.unit.Unit; + +/** + *

Represents a quantitative properties or attributes of thing. + * Mass, time, distance, heat, and angular separation + * are among the familiar examples of quantitative properties.

+ * + *

{@link QuantityFactory} can be used to generate simple instances of this class.[code] + * Time duration = QuantityFactory.getInstance(Time.class).create(12, MILLI(SECOND)); + * Length distance = QuantityFactory.getInstance(Length.class).create(37.4, MILES); + * [/code]

+ * + *

Quantities are used to specify the quantitative property associated + * to a class through class parameterization.[code] + * Unit pound = ... + * Sensor thermometer = ... + * Vector3D aircraftSpeed = ... + * [/code]

+ * + * @param The type of the quantity. + * + * @author Martin Desruisseaux + * @author Werner Keil + * @author Jean-Marie Dautelle + * @version 1.7 ($Revision: 198 $), $Date: 2010-02-24 19:53:02 +0100 (Mi, 24 Feb 2010) $ + * @see Wikipedia: Quantity + */ +public interface Quantity> extends Comparable> { + + /** + * Returns the magnitude or multitude value of this quantity stated in this + * quantity {@linkplain #getUnit() unit}. + * + * @return the numeric value of this quantity in the units returned by {@link #getUnit()}. + */ + Number getValue(); + + /** + * Returns the original unit of this quantity (the one specified at creation). + * + * @return the original unit of this quantity. + */ + Unit getUnit(); + + /** + * Returns the value of this quantity stated in the specified unit. + * This method is recommended over + * q.getUnit().getConverterTo(unit).convert(q.getValue()), + * it is not only faster but also detects potential overflow if the + * value stated in the specific unit cannot be represented or rounded. + * + * @param unit the unit in which the returned value is stated. + * @return the value of this quantity when stated in the specified unit. + * @throws ArithmeticException if this quantity cannot be converted to + * when stated in the specified unit (e.g. overflow). + */ + Number getValue(Unit unit) throws ArithmeticException; + + /** + * Returns the value of this quantity as double stated + * in the specified unit. This method is recommended over + * q.getUnit().getConverterTo(unit).convert(q.getValue()).doubleValue() + * + * @param unit the unit in which the returned value is stated. + * @return the value of this quantity when stated in the specified unit. + */ + double doubleValue(Unit unit); + + /** + * Returns the value of this quantity as long stated + * in the specified unit. This method is recommended over + * q.getUnit().getConverterTo(unit).convert(q.getValue()).longValue(), + * it is not only faster but also detects potential overflow if the + * value stated in the specific unit cannot be represented as + * long. + * + * @param unit the unit in which the returned value is stated. + * @return the value of this quantity when stated in the specified unit. + * @throws ArithmeticException if this quantity cannot represented as + * a long when stated in the specified unit (e.g. overflow). + */ + long longValue(Unit unit) throws ArithmeticException; +} diff --git a/src/main/java/javax/measure/quantity/QuantityFactory.java b/src/main/java/javax/measure/quantity/QuantityFactory.java new file mode 100644 index 0000000..2299cfb --- /dev/null +++ b/src/main/java/javax/measure/quantity/QuantityFactory.java @@ -0,0 +1,237 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import javax.measure.unit.Unit; +import static javax.measure.unit.MetricSystem.*; + +/** + * A factory producing simple quantities instances (tuples {@link Number}/{@link Unit}). + * + * For example:[code] + * Mass m = QuantityFactory.getInstance(Mass.class).create(23.0, KILOGRAM); // 23.0 Kg + * Time m = QuantityFactory.getInstance(Time.class).create(124, MILLI(SECOND)); // 124 ms + * [/code] + * @param The type of the quantity. + * + * @author Martin Desruisseaux + * @author Werner Keil + * @author Jean-Marie Dautelle + * @version 1.0.5 ($Revision: 202 $), $Date: 2010-02-25 01:24:19 +0100 (Do, 25 Feb 2010) $ + */ +public abstract class QuantityFactory> { + + /** + * Holds the current instances. + */ + @SuppressWarnings("unchecked") + private static final ConcurrentHashMap INSTANCES = new ConcurrentHashMap(); + + /** + * Returns the default instance for the specified quantity type. + * + * @param The type of the quantity + * @param type the quantity type + * @return the quantity factory for the specified type + */ + @SuppressWarnings("unchecked") + public static > QuantityFactory getInstance(final Class type) { + QuantityFactory factory = INSTANCES.get(type); + if (factory != null) return factory; + if (!Quantity.class.isAssignableFrom(type)) + // This exception is not documented because it should never happen if the + // user don't try to trick the Java generic types system with unsafe cast. + throw new ClassCastException(); + factory = new Default(type); + INSTANCES.put(type, factory); + return factory; + } + + /** + * Overrides the default implementation of the factory for the specified + * quantity type. + * + * @param The type of the quantity + * @param type the quantity type + * @param factory the quantity factory + */ + @SuppressWarnings("unchecked") + protected static > void setInstance(final Class type, QuantityFactory factory) { + if (!Quantity.class.isAssignableFrom(type)) + // This exception is not documented because it should never happen if the + // user don't try to trick the Java generic types system with unsafe cast. + throw new ClassCastException(); + INSTANCES.put(type, factory); + } + + /** + * Returns the quantity for the specified number stated in the specified unit. + * + * @param value the value stated in the specified unit + * @param unit the unit + * @return the corresponding quantity + */ + public abstract Q create(Number value, Unit unit); + + /** + * Returns the metric unit for quantities produced by this factory + * or null if unknown. + * + * @return the metric units for this factory quantities. + */ + public abstract Unit getMetricUnit(); + + /** + * The default factory implementation. This factory uses reflection for providing + * a default implementation for every {@link Quantity} sub-types. + * + * @param The type of the quantity + */ + private static final class Default> extends QuantityFactory { + + /** + * The type of the quantities created by this factory. + */ + private final Class type; + + /** + * The metric unit for quantities created by this factory. + */ + private final Unit metricUnit; + + /** + * Creates a new factory for quantities of the given type. + * + * @param type The type of the quantities created by this factory. + */ + Default(final Class type) { + this.type = type; + metricUnit = CLASS_TO_METRIC_UNIT.get(type); + } + @SuppressWarnings("unchecked") + static final HashMap CLASS_TO_METRIC_UNIT = new HashMap(); + static { + CLASS_TO_METRIC_UNIT.put(Dimensionless.class, Unit.ONE); + CLASS_TO_METRIC_UNIT.put(ElectricCurrent.class, AMPERE); + CLASS_TO_METRIC_UNIT.put(LuminousIntensity.class, CANDELA); + CLASS_TO_METRIC_UNIT.put(Temperature.class, KELVIN); + CLASS_TO_METRIC_UNIT.put(Mass.class, KILOGRAM); + CLASS_TO_METRIC_UNIT.put(Length.class, METRE); + CLASS_TO_METRIC_UNIT.put(AmountOfSubstance.class, MOLE); + CLASS_TO_METRIC_UNIT.put(Time.class, SECOND); + CLASS_TO_METRIC_UNIT.put(MagnetomotiveForce.class, AMPERE_TURN); + CLASS_TO_METRIC_UNIT.put(Angle.class, RADIAN); + CLASS_TO_METRIC_UNIT.put(SolidAngle.class, STERADIAN); + CLASS_TO_METRIC_UNIT.put(DataAmount.class, BIT); + CLASS_TO_METRIC_UNIT.put(Frequency.class, HERTZ); + CLASS_TO_METRIC_UNIT.put(Force.class, NEWTON); + CLASS_TO_METRIC_UNIT.put(Pressure.class, PASCAL); + CLASS_TO_METRIC_UNIT.put(Energy.class, JOULE); + CLASS_TO_METRIC_UNIT.put(Power.class, WATT); + CLASS_TO_METRIC_UNIT.put(ElectricCharge.class, COULOMB); + CLASS_TO_METRIC_UNIT.put(ElectricPotential.class, VOLT); + CLASS_TO_METRIC_UNIT.put(ElectricCapacitance.class, FARAD); + CLASS_TO_METRIC_UNIT.put(ElectricResistance.class, OHM); + CLASS_TO_METRIC_UNIT.put(ElectricConductance.class, SIEMENS); + CLASS_TO_METRIC_UNIT.put(MagneticFlux.class, WEBER); + CLASS_TO_METRIC_UNIT.put(MagneticFluxDensity.class, TESLA); + CLASS_TO_METRIC_UNIT.put(ElectricInductance.class, HENRY); + CLASS_TO_METRIC_UNIT.put(LuminousFlux.class, LUMEN); + CLASS_TO_METRIC_UNIT.put(Illuminance.class, LUX); + CLASS_TO_METRIC_UNIT.put(RadioactiveActivity.class, BECQUEREL); + CLASS_TO_METRIC_UNIT.put(RadiationDoseAbsorbed.class, GRAY); + CLASS_TO_METRIC_UNIT.put(RadiationDoseEffective.class, SIEVERT); + CLASS_TO_METRIC_UNIT.put(CatalyticActivity.class, KATAL); + CLASS_TO_METRIC_UNIT.put(Velocity.class, METRES_PER_SECOND); + CLASS_TO_METRIC_UNIT.put(Acceleration.class, METRES_PER_SQUARE_SECOND); + CLASS_TO_METRIC_UNIT.put(Area.class, SQUARE_METRE); + CLASS_TO_METRIC_UNIT.put(Volume.class, CUBIC_METRE); + } + + + @Override + @SuppressWarnings("unchecked") + public Q create(final Number value, final Unit unit) { + return (Q) Proxy.newProxyInstance(type.getClassLoader(), + new Class[]{type}, new GenericHandler(value, unit)); + } + + @Override + public Unit getMetricUnit() { + return metricUnit; + } + } + + /** + * The method invocation handler for implementation backed by any kind of {@link Number}. + * This is a fall back used when no specialized handler is available for the number type. + */ + private static final class GenericHandler> implements InvocationHandler { + final Unit unit; + final Number value; + + GenericHandler(final Number value, final Unit unit) { + this.unit = unit; + this.value = value; + } + + @SuppressWarnings("unchecked") + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) { + final String name = method.getName(); + if (name.equals("doubleValue")) { // Most frequent. + final Unit toUnit = (Unit) args[0]; + if ((value instanceof Double) && ((toUnit == unit) || (toUnit.equals(unit)))) + return ((Double)value).doubleValue(); // Returns value directly. + return unit.getConverterTo(toUnit).convert(value.doubleValue()); + } else if (name.equals("longValue")) { + final Unit toUnit = (Unit) args[0]; + if ((value instanceof Long) && ((toUnit == unit) || (toUnit.equals(unit)))) + return ((Long)value).doubleValue(); // Returns value directly. + double doubleValue = unit.getConverterTo(toUnit).convert(value.doubleValue()); + if ((doubleValue < Long.MIN_VALUE) || (doubleValue > Long.MAX_VALUE)) + throw new ArithmeticException("Overflow: " + doubleValue + " cannot be represented as a long"); + return (long) doubleValue; + } else if (name.equals("getValue")) { + if (args == null) { + return value; + } else { + final Unit toUnit = (Unit) args[0]; + if ((value instanceof Number) && ((toUnit == unit) || (toUnit.equals(unit)))) { + return value; // Returns value directly. + } + return unit.getConverterTo(toUnit).convert(value); + } + } else if (name.equals("getUnit")) { + return unit; + } else if (name.equals("toString")) { + final StringBuilder buffer = new StringBuilder(); + return buffer.append(value).append(' ').append(unit).toString(); + } else if (name.equals("hashCode")) { + return value.hashCode() * 31 + unit.hashCode(); + } else if (name.equals("equals")) { + final Object obj = args[0]; + if (!(obj instanceof Quantity)) + return false; + final Quantity that = (Quantity) obj; + if (!unit.isCompatible(that.getUnit())) + return false; + return value.doubleValue() == that.doubleValue(unit); + } else if (name.equals("compareTo")) { + final Quantity that = (Quantity) args[0]; + return Double.compare(value.doubleValue(), that.doubleValue(unit)); + } else { + throw new UnsupportedOperationException(name); + } + } + } +} diff --git a/src/main/java/javax/measure/quantity/RadiationDoseAbsorbed.java b/src/main/java/javax/measure/quantity/RadiationDoseAbsorbed.java new file mode 100644 index 0000000..8f7ad8a --- /dev/null +++ b/src/main/java/javax/measure/quantity/RadiationDoseAbsorbed.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents the amount of energy deposited per unit of mass. + * The system unit for this quantity is "Gy" (Gray). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface RadiationDoseAbsorbed extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/RadiationDoseEffective.java b/src/main/java/javax/measure/quantity/RadiationDoseEffective.java new file mode 100644 index 0000000..98218ca --- /dev/null +++ b/src/main/java/javax/measure/quantity/RadiationDoseEffective.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents the effective (or "equivalent") dose of radiation + * received by a human or some other living organism. + * The metric system unit for this quantity is "Sv" (Sievert). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface RadiationDoseEffective extends Quantity { + +} diff --git a/src/main/java/javax/measure/quantity/RadioactiveActivity.java b/src/main/java/javax/measure/quantity/RadioactiveActivity.java new file mode 100644 index 0000000..77e05fb --- /dev/null +++ b/src/main/java/javax/measure/quantity/RadioactiveActivity.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.quantity; + +/** + * Represents a radioactive activity. + * The metric system unit for this quantity is "Bq" (Becquerel). + * + * @author Jean-Marie Dautelle + * @version 1.0, April 15, 2009 + */ +public interface RadioactiveActivity extends Quantity { + +} diff --git a/src/main/java/javax/measure/unit/ConversionException.java b/src/main/java/javax/measure/unit/ConversionException.java new file mode 100644 index 0000000..d71ff7d --- /dev/null +++ b/src/main/java/javax/measure/unit/ConversionException.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.unit; + +/** + * Signals that a problem of some sort has occurred either when creating a + * converter between two units or during the conversion itself. + * + * @author Jean-Marie Dautelle + * @author Werner Keil + * @version 1.4 ($Revision: 198 $), $Date: 2010-02-24 19:53:02 +0100 (Mi, 24 Feb 2010) $ + */ +public class ConversionException extends RuntimeException { + + /** The serialVersionUID */ + private static final long serialVersionUID = -2846245619420930853L; + + /** + * Constructs a ConversionException with the specified detail + * message. + * + * @param message the detail message. + */ + public ConversionException(String message) { + super(message); + } +} diff --git a/src/main/java/javax/measure/unit/Dimension.java b/src/main/java/javax/measure/unit/Dimension.java new file mode 100644 index 0000000..2358760 --- /dev/null +++ b/src/main/java/javax/measure/unit/Dimension.java @@ -0,0 +1,292 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.unit; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.measure.quantity.Dimensionless; + +/** + *

This class represents the dimension of an unit. Two units u1 + * and u2 are {@linkplain Unit#isCompatible compatible} if and + * only if (u1.getDimension().equals(u2.getDimension()))) + *

+ * + *

Instances of this class are immutable.

+ * + * @author Jean-Marie Dautelle + * @author Werner Keil + * + * @version 1.0.3 ($Revision: 176 $), $Date: 2010-02-22 19:09:37 +0100 (Mo, 22 Feb 2010) $ + * @see + * BIPM: SI Brochure Chapter 1.3 + */ +public final class Dimension implements Serializable { + + /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = 2377803885472362640L; + + /** + * Holds the current physical model. + */ + private static Model model = Model.STANDARD; + + /** + * Holds dimensionless. + */ + public static final Dimension NONE = new Dimension(Unit.ONE); + + /** + * Holds length dimension (L). + */ + public static final Dimension LENGTH = new Dimension('L'); + + /** + * Holds mass dimension (M). + */ + public static final Dimension MASS = new Dimension('M'); + + /** + * Holds time dimension (T). + */ + public static final Dimension TIME = new Dimension('T'); + + /** + * Holds electric current dimension (I). + */ + public static final Dimension ELECTRIC_CURRENT = new Dimension('I'); + + /** + * Holds temperature dimension (Θ). + */ + public static final Dimension TEMPERATURE = new Dimension('Θ'); + + /** + * Holds amount of substance dimension (N). + */ + public static final Dimension AMOUNT_OF_SUBSTANCE = new Dimension('N'); + + /** + * Holds luminous intensity dimension (J). + */ + public static final Dimension LUMINOUS_INTENSITY = new Dimension('J'); + + /** + * Holds the pseudo unit associated to this dimension. + */ + private final Unit pseudoUnit; + + /** + * Creates a new dimension associated to the specified symbol. + * + * @param symbol the associated symbol. + */ + private Dimension(char symbol) { + pseudoUnit = new BaseUnit("[" + symbol + "]"); + } + + /** + * Creates a dimension having the specified pseudo-unit + * (base unit or product of base unit). + * + * @param pseudoUnit the pseudo-unit identifying this dimension. + */ + private Dimension(Unit pseudoUnit) { + this.pseudoUnit = pseudoUnit; + } + + /** + * Returns the product of this dimension with the one specified. + * + * @param that the dimension multiplicand. + * @return this * that + */ + public final Dimension multiply(Dimension that) { + return new Dimension(this.pseudoUnit.multiply(that.pseudoUnit)); + } + + /** + * Returns the quotient of this dimension with the one specified. + * + * @param that the dimension divisor. + * @return this / that + */ + public final Dimension divide(Dimension that) { + return new Dimension(this.pseudoUnit.divide(that.pseudoUnit)); + } + + /** + * Returns this dimension raised to an exponent. + * + * @param n the exponent. + * @return the result of raising this dimension to the exponent. + */ + public final Dimension pow(int n) { + return new Dimension(this.pseudoUnit.pow(n)); + } + + /** + * Returns the given root of this dimension. + * + * @param n the root's order. + * @return the result of taking the given root of this dimension. + * @throws ArithmeticException if n == 0. + */ + public final Dimension root(int n) { + return new Dimension(this.pseudoUnit.root(n)); + } + + /** + * Returns the fundamental dimensions and their exponent whose product is + * this dimension or null if this dimension is a fundamental + * dimension. + * + * @return the mapping between the fundamental dimensions and their exponent. + */ + Map getProductDimensions() { + Map, Integer> pseudoUnits = pseudoUnit.getProductUnits(); + if (pseudoUnit == null) return null; + Map fundamentalDimensions = new HashMap(); + for (Map.Entry, Integer> entry : pseudoUnits.entrySet()) { + fundamentalDimensions.put(new Dimension(entry.getKey()), entry.getValue()); + } + return fundamentalDimensions; + } + + /** + * Returns the representation of this dimension. + * + * @return the representation of this dimension. + */ + @Override + public String toString() { + return pseudoUnit.toString(); + } + + /** + * Indicates if the specified dimension is equals to the one specified. + * + * @param that the object to compare to. + * @return true if this dimension is equals to that dimension; + * false otherwise. + */ + @Override + public boolean equals(Object that) { + if (this == that) + return true; + return (that instanceof Dimension) && pseudoUnit.equals(((Dimension) that).pseudoUnit); + } + + /** + * Returns the hash code for this dimension. + * + * @return this dimension hashcode value. + */ + @Override + public int hashCode() { + return pseudoUnit.hashCode(); + } + + /** + * Sets the model used to determinate the units dimensions. + * + * @param model the new model to be used when calculating unit dimensions. + */ + public static void setModel(Model model) { + Dimension.model = model; + } + + /** + * Returns the model used to determinate the units dimensions + * (default {@link Model#STANDARD STANDARD}). + * + * @return the model used when calculating unit dimensions. + */ + public static Model getModel() { + return Dimension.model; + } + + /** + * This interface represents the mapping between {@linkplain BaseUnit base units} + * and {@linkplain Dimension dimensions}. Custom models may allow + * conversions not possible using the {@linkplain #STANDARD standard} model. + * For example:[code] + * public static void main(String[] args) { + * Dimension.Model relativistic = new Dimension.Model() { + * RationalConverter metreToSecond = new RationalConverter(BigInteger.ONE, BigInteger.valueOf(299792458)); // 1/c + * + * public Dimension getDimension(BaseUnit unit) { + * if (unit.equals(METRE)) return Dimension.TIME; + * return Dimension.Model.STANDARD.getDimension(unit); + * } + * + * public UnitConverter getTransform(BaseUnit unit) { + * if (unit.equals(METRE)) return metreToSecond; + * return Dimension.Model.STANDARD.getTransform(unit); + * }}; + * Dimension.setModel(relativistic); + * + * // Converts 1.0 GeV (energy) to kg (mass). + * System.out.println(Unit.valueOf("GeV").getConverterTo(KILOGRAM).convert(1.0)); + * } + * + * > 1.7826617302520883E-27[/code] + */ + public interface Model { + + /** + * Holds the standard model (default). + */ + public Model STANDARD = new Model() { + + public Dimension getDimension(BaseUnit unit) { + if (unit.equals(MetricSystem.METRE)) + return Dimension.LENGTH; + if (unit.equals(MetricSystem.KILOGRAM)) + return Dimension.MASS; + if (unit.equals(MetricSystem.KELVIN)) + return Dimension.TEMPERATURE; + if (unit.equals(MetricSystem.SECOND)) + return Dimension.TIME; + if (unit.equals(MetricSystem.AMPERE)) + return Dimension.ELECTRIC_CURRENT; + if (unit.equals(MetricSystem.MOLE)) + return Dimension.AMOUNT_OF_SUBSTANCE; + if (unit.equals(MetricSystem.CANDELA)) + return Dimension.LUMINOUS_INTENSITY; + return new Dimension(new BaseUnit("[" + unit.getSymbol() + "]")); + } + + public UnitConverter getTransform(BaseUnit unit) { + return UnitConverter.IDENTITY; + } + }; + + /** + * Returns the dimension of the specified base unit (a dimension + * particular to the base unit if the base unit is not recognized). + * + * @param unit the base unit for which the dimension is returned. + * @return the dimension of the specified unit. + */ + Dimension getDimension(BaseUnit unit); + + /** + * Returns the normalization transform of the specified base unit + * ({@link UnitConverter#IDENTITY IDENTITY} if the base unit is + * not recognized). + * + * @param unit the base unit for which the transform is returned. + * @return the normalization transform. + */ + UnitConverter getTransform(BaseUnit unit); + } +} diff --git a/src/main/java/javax/measure/unit/SystemOfUnits.java b/src/main/java/javax/measure/unit/SystemOfUnits.java new file mode 100644 index 0000000..dbe590f --- /dev/null +++ b/src/main/java/javax/measure/unit/SystemOfUnits.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.unit; + +import java.util.HashSet; +import java.util.Set; + +/** + *

This class represents a system of units, it groups units together + * for historical or cultural reasons. Nothing prevents a unit from + * belonging to several system of units at the same time + * (for example an imperial system would have many of the units + * held by {@link USCustomarySystem}).

+ * + * @author Jean-Marie Dautelle + * @author Werner Keil + * @version 1.1 ($Revision: 169 $), $Date: 2010-02-21 18:48:40 +0100 (So, 21 Feb 2010) $ + */ +public abstract class SystemOfUnits { + + /** + * Default constructor. + */ + protected SystemOfUnits() { + } + + /** + * Returns a read only view over the units defined in this system. + * + * @return the collection of units. + */ + public abstract Set> getUnits(); + + + /** + * Returns the units defined in this system having the specified + * dimension (convenience method). This method returns all the units + * in this system of units having the specified dimension. + * + * @param dimension the dimension of the units to be returned. + * @return the collection of units of specified dimension. + */ + public Set> getUnits(Dimension dimension) { + final Set> units = new HashSet>(); + for (Unit unit : getUnits()) { + if (unit.getDimension().equals(dimension)) { + units.add(unit); + } + } + return units; + } +} diff --git a/src/main/java/javax/measure/unit/USCustomarySystem.java b/src/main/java/javax/measure/unit/USCustomarySystem.java new file mode 100644 index 0000000..1a9a59e --- /dev/null +++ b/src/main/java/javax/measure/unit/USCustomarySystem.java @@ -0,0 +1,336 @@ +/** + * Copyright (c) 2005-2010, Jean-Marie Dautelle, Werner Keil + * All rights reserved. + * + * See LICENSE.txt for the Specification License + */ +package javax.measure.unit; + +import static javax.measure.unit.MetricSystem.*; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import javax.measure.quantity.Angle; +import javax.measure.quantity.Area; +import javax.measure.quantity.DataAmount; +import javax.measure.quantity.Energy; +import javax.measure.quantity.Length; +import javax.measure.quantity.Mass; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Time; +import javax.measure.quantity.Velocity; +import javax.measure.quantity.Volume; + +/** + *

This class contains units from the United States customary system.

+ * + * @author Jean-Marie Dautelle + * @author Werner Keil + * @version 1.2 ($Revision: 192 $), $Date: 2010-02-24 17:46:38 +0100 (Mi, 24 Feb 2010) $ + * @see Wikipedia: United State Customary Units + */ +public final class USCustomarySystem extends SystemOfUnits { + + /** + * Holds collection of units. + */ + private static final Set> UNITS = new HashSet>(); + + /** + * Default constructor (prevents this class from being instantiated). + */ + private USCustomarySystem() { + } + + /** + * Returns the unique instance of this class. + * + * @return the NonSI instance. + */ + public static USCustomarySystem getInstance() { + return INSTANCE; + } + private static final USCustomarySystem INSTANCE = new USCustomarySystem(); + + + // ////////// + // Length // + // ////////// + /** + * US name for {@link MetricSystem#METRE}. + */ + public static final Unit METER = METRE; + + /** + * A unit of length equal to 0.3048 m (standard name + * ft). + */ + public static final Unit FOOT = addUnit(METER.multiply( + 3048).divide(10000)); + + /** + * A unit of length equal to 1200/3937 m (standard name + * foot_survey_us). See also: foot + */ + public static final Unit FOOT_SURVEY = addUnit(METER.multiply(1200).divide(3937)); + + /** + * A unit of length equal to 0.9144 m (standard name + * yd). + */ + public static final Unit YARD = addUnit(FOOT.multiply(3)); + + /** + * A unit of length equal to 0.0254 m (standard name + * in). + */ + public static final Unit INCH = addUnit(FOOT.divide(12)); + + /** + * A unit of length equal to 1609.344 m (standard name + * mi). + */ + public static final Unit MILE = addUnit(METER.multiply(1609344).divide( + 1000)); + + /** + * A unit of length equal to 1852.0 m (standard name + * nmi). + */ + public static final Unit NAUTICAL_MILE = addUnit(METER.multiply(1852)); + + + // //////// + // Mass // + // //////// + + /** + * A unit of mass equal to 453.59237 grams (avoirdupois pound, + * standard name lb). + */ + public static final Unit POUND = addUnit(KILOGRAM.multiply( + 45359237).divide(100000000)); + + /** + * A unit of mass equal to 1 / 16 {@link #POUND} (standard name oz). + */ + public static final Unit OUNCE = addUnit(POUND.divide(16)); + + /** + * A unit of mass equal to 2000 {@link #POUND} (short ton, standard name + * ton). + */ + public static final Unit TON = addUnit(POUND.multiply(2000)); + + + // /////////////// + // Temperature // + // /////////////// + + /** + * A unit of temperature equal to 5/9 °K (standard name + * °R). + */ + public static final Unit RANKINE = addUnit(KELVIN.multiply(5).divide(9)); + + /** + * A unit of temperature equal to degree Rankine minus + * 459.67 °R (standard name °F). + * + * @see #RANKINE + */ + public static final Unit FAHRENHEIT = addUnit(RANKINE.add(459.67)); + + + // ///////// + // Angle // + // ///////// + + /** + * A unit of angle equal to a full circle or 2π + * {@link MetricSystem#RADIAN} (standard name rev). + */ + public static final Unit REVOLUTION = addUnit(RADIAN.multiply(2).multiply(Math.PI).asType(Angle.class)); + + /** + * A unit of angle equal to 1/360 {@link #REVOLUTION} (standard name deg). + */ + public static final Unit DEGREE_ANGLE = addUnit(REVOLUTION.divide(360)); + + /** + * A unit of angle equal to 1/60 {@link #DEGREE_ANGLE} (standard name '). + */ + public static final Unit MINUTE_ANGLE = addUnit(DEGREE_ANGLE.divide(60)); + + /** + * A unit of angle equal to 1/60 {@link #MINUTE_ANGLE} (standard name "). + */ + public static final Unit SECOND_ANGLE = addUnit(MINUTE_ANGLE.divide(60)); + + + // //////////// + // Duration // + // //////////// + /** + * A unit of time equal to 60 s (standard name + * min). + */ + public static final Unit