Skip to main content

[json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

  • From: "jitu (JIRA)" < >
  • To:
  • Subject: [json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal
  • Date: Thu, 13 Dec 2012 01:00:11 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated


     [ 
http://java.net/jira/browse/JSON_PROCESSING_SPEC-41?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

jitu updated JSON_PROCESSING_SPEC-41:
-------------------------------------


ME could use a similar algo what scale() is doing to determine if the number 
has a fractional part or not.

I am thinking of rolling the following:
{code}
    /**
     * JSON number type that is used to find out if a number is numerically
     * integer or a decimal.
     */
    enum NumberType {
        /**
         * Represents a number that is numerically integer.
         * The value can be accessed as int, long, or BigInteger using
         * different JsonNumber accessor methods.
         */
        INTEGER,

        /**
         * Represents a number that is numerically decimal. The value can
         * be accessed as double, or BigDecimal using different JsonNumber
         * accessor methods.
         */
        DECIMAL
    }

    /**
     * Returns a JSON number type for this number.
     * A {@link BigDecimal} may be used to store the numeric value internally
     * and the semantics of this method is defined using
     * {@link BigDecimal#scale()}.
     * If the scale of a value is zero, then its number type is
     * {@link NumberType#INTEGER INTEGER} else {@link NumberType#DECIMAL 
DECIMAL}.
     *
     * <p>
     * The number type can be used to invoke appropriate accessor methods to 
get
     * numeric value for the number.
     * <p>
     * <b>For example:</b>
     * <code>
     * <pre>
     * switch(getNumberType()) {
     *     case INTEGER :
     *         long l = getLongValue(); break;
     *     case DECIMAL :
     *         BigDecimal bd = getBigDecimalValue(); break;
     * }
     * </pre>
     * </code>
     *
     * @return a number type
     */
    NumberType getNumberType();
{code}


> Remove NumberType.LONG and rename NumberType.BigDecimal
> -------------------------------------------------------
>
>                 Key: JSON_PROCESSING_SPEC-41
>                 URL: http://java.net/jira/browse/JSON_PROCESSING_SPEC-41
>             Project: json-processing-spec
>          Issue Type: Improvement
>    Affects Versions: 1.0-pr
>            Reporter: jhorstmann
>            Assignee: jitu
>             Fix For: 1.0-pr
>
>
> NumberType would be less confusing if it just stated the distinction 
> whether a number has a fractional part.
> A NumberType of INTEGER would guarantee that calling getBigIntegerValue 
> does not throw an ArithmeticException. The NumberType would be independent 
> of the actual magnitude of the number, thus calling getIntValueExact might 
> still throw an Exception if the number is smaller than Integer.MIN_VALUE of 
> larger than Integer.MAX_VALUE.
> The current NumberType BIG_DECIMAL should be renamed to just DECIMAL or 
> REAL (see http://en.wikipedia.org/wiki/Real_number) and would indicate that 
> the number has a fractional part and calling 
> get(Int|Long|BigInteger)ValueExact might throw an ArithmeticException.
> The algorithm for distinguishing these two types should be based on whether 
> BigDecimal#scale() is 0.  
> Discussion at 
> http://java.net/projects/json-processing-spec/lists/users/archive/2012-12/message/43

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[json-processing-spec issues] [JIRA] Created: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jhorstmann (JIRA) 12/11/2012

[json-processing-spec issues] [JIRA] Commented: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jhorstmann (JIRA) 12/11/2012

[json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/11/2012

[json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/11/2012

[json-processing-spec issues] [JIRA] Issue Comment Edited: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Commented: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

keilw (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Issue Comment Edited: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

keilw (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Issue Comment Edited: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

keilw (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Issue Comment Edited: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

keilw (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Issue Comment Edited: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

keilw (JIRA) 12/12/2012

[json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/13/2012

[json-processing-spec issues] [JIRA] Commented: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jhorstmann (JIRA) 12/13/2012

[json-processing-spec issues] [JIRA] Updated: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/13/2012

[json-processing-spec issues] [JIRA] Resolved: (JSON_PROCESSING_SPEC-41) Remove NumberType.LONG and rename NumberType.BigDecimal

jitu (JIRA) 12/14/2012
 
 
Close
loading
Please Confirm
Close