jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java
author dfuchs
Fri, 17 May 2013 10:40:21 +0200
changeset 17538 d8d911c4e5d4
parent 12457 c348e06f0e82
permissions -rw-r--r--
8013900: More warnings compiling jaxp. Summary: Some internal implementation classes in Jaxp were redefining equals() without redefining hashCode(). This patch adds hashCode() methods that are consistent with equals(). Reviewed-by: chegar, joehw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
package com.sun.org.apache.xerces.internal.impl.dv.xs;
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
 * Validator for <precisionDecimal> datatype (W3C Schema 1.1)
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
 * @xerces.experimental
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 * @author Ankit Pasricha, IBM
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
class PrecisionDecimalDV extends TypeValidator {
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
    35
    static final class XPrecisionDecimal {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
        // sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
        int sign = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
        // total digits. >= 1
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
        int totalDigits = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
        // integer digits when sign != 0
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
        int intDigits = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
        // fraction digits when sign != 0
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
        int fracDigits = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
        //precision
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
        //int precision = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
        // the string representing the integer part
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
        String ivalue = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
        // the string representing the fraction part
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
        String fvalue = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
        int pvalue = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
        XPrecisionDecimal(String content) throws NumberFormatException {
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
            if(content.equals("NaN")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
                ivalue = content;
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
                sign = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
            if(content.equals("+INF") || content.equals("INF") || content.equals("-INF")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
                ivalue = content.charAt(0) == '+' ? content.substring(1) : content;
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
                return;
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
            initD(content);
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
        void initD(String content) throws NumberFormatException {
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
            int len = content.length();
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
            if (len == 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
                throw new NumberFormatException();
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
            // these 4 variables are used to indicate where the integre/fraction
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
            // parts start/end.
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
            int intStart = 0, intEnd = 0, fracStart = 0, fracEnd = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
            // Deal with leading sign symbol if present
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
            if (content.charAt(0) == '+') {
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
                // skip '+', so intStart should be 1
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
                intStart = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
            else if (content.charAt(0) == '-') {
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
                intStart = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
                sign = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
            // skip leading zeroes in integer part
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
            int actualIntStart = intStart;
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
            while (actualIntStart < len && content.charAt(actualIntStart) == '0') {
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
                actualIntStart++;
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
            // Find the ending position of the integer part
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
            for (intEnd = actualIntStart; intEnd < len && TypeValidator.isDigit(content.charAt(intEnd)); intEnd++);
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
            // Not reached the end yet
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
            if (intEnd < len) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
                // the remaining part is not ".DDD" or "EDDD" or "eDDD", error
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
                if (content.charAt(intEnd) != '.' && content.charAt(intEnd) != 'E' && content.charAt(intEnd) != 'e')
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
                    throw new NumberFormatException();
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
                if(content.charAt(intEnd) == '.') {
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
                    // fraction part starts after '.', and ends at the end of the input
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
                    fracStart = intEnd + 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
                    // find location of E or e (if present)
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
                    // Find the ending position of the fracion part
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
                    for (fracEnd = fracStart;
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
                    fracEnd < len && TypeValidator.isDigit(content.charAt(fracEnd));
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
                    fracEnd++);
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
                else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
                    pvalue = Integer.parseInt(content.substring(intEnd + 1, len));
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
            // no integer part, no fraction part, error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
            if (intStart == intEnd && fracStart == fracEnd)
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
                throw new NumberFormatException();
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
            // ignore trailing zeroes in fraction part
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
            /*while (fracEnd > fracStart && content.charAt(fracEnd-1) == '0') {
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
             fracEnd--;
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
             }*/
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
            // check whether there is non-digit characters in the fraction part
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
            for (int fracPos = fracStart; fracPos < fracEnd; fracPos++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
                if (!TypeValidator.isDigit(content.charAt(fracPos)))
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
                    throw new NumberFormatException();
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
            intDigits = intEnd - actualIntStart;
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
            fracDigits = fracEnd - fracStart;
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
            if (intDigits > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
                ivalue = content.substring(actualIntStart, intEnd);
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
            if (fracDigits > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
                fvalue = content.substring(fracStart, fracEnd);
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
                if(fracEnd < len) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
                    pvalue = Integer.parseInt(content.substring(fracEnd + 1, len));
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
            totalDigits = intDigits + fracDigits;
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   147
        // Construct a canonical String representation of this number
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   148
        // for the purpose of deriving a hashCode value compliant with
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   149
        // equals.
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   150
        // The toString representation will be:
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   151
        // NaN for NaN, INF for +infinity, -INF for -infinity, 0 for zero,
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   152
        // and [1-9].[0-9]*[1-9]?(E[1-9][0-9]*)? for other numbers.
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   153
        private static String canonicalToStringForHashCode(String ivalue, String fvalue, int sign, int pvalue) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   154
            if ("NaN".equals(ivalue)) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   155
                return "NaN";
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   156
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   157
            if ("INF".equals(ivalue)) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   158
                return sign < 0 ? "-INF" : "INF";
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   159
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   160
            final StringBuilder builder = new StringBuilder();
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   161
            final int ilen = ivalue.length();
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   162
            final int flen0 = fvalue.length();
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   163
            int lastNonZero;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   164
            for (lastNonZero = flen0; lastNonZero > 0 ; lastNonZero--) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   165
                if (fvalue.charAt(lastNonZero -1 ) != '0') break;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   166
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   167
            final int flen = lastNonZero;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   168
            int iStart;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   169
            int exponent = pvalue;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   170
            for (iStart = 0; iStart < ilen; iStart++) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   171
                if (ivalue.charAt(iStart) != '0') break;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   172
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   173
            int fStart = 0;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   174
            if (iStart < ivalue.length()) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   175
                builder.append(sign == -1 ? "-" : "");
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   176
                builder.append(ivalue.charAt(iStart));
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   177
                iStart++;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   178
            } else {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   179
                if (flen > 0) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   180
                    for (fStart = 0; fStart < flen; fStart++) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   181
                        if (fvalue.charAt(fStart) != '0') break;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   182
                    }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   183
                    if (fStart < flen) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   184
                        builder.append(sign == -1 ? "-" : "");
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   185
                        builder.append(fvalue.charAt(fStart));
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   186
                        exponent -= ++fStart;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   187
                    } else {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   188
                        return "0";
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   189
                    }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   190
                } else {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   191
                    return "0";
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   192
                }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   193
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   195
            if (iStart < ilen || fStart < flen) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   196
                builder.append('.');
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   197
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   198
            while (iStart < ilen) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   199
                builder.append(ivalue.charAt(iStart++));
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   200
                exponent++;
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   201
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   202
            while (fStart < flen) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   203
                builder.append(fvalue.charAt(fStart++));
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   204
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   205
            if (exponent != 0) {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   206
                builder.append("E").append(exponent);
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   207
            }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   208
            return builder.toString();
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   209
        }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   210
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   211
        @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        public boolean equals(Object val) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
            if (val == this)
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
                return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
            if (!(val instanceof XPrecisionDecimal))
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
                return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
            XPrecisionDecimal oval = (XPrecisionDecimal)val;
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
            return this.compareTo(oval) == EQUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   223
        @Override
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   224
        public int hashCode() {
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   225
            // There's nothing else we can use easily, because equals could
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   226
            // return true for widely different representation of the
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   227
            // same number - and we don't have any canonical representation.
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   228
            // The problem here is that we must ensure that if two numbers
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   229
            // are equals then their hash code must also be equals.
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   230
            // hashCode for 1.01E1 should be the same as hashCode for 0.101E2
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   231
            // So we call cannonicalToStringForHashCode - which implements an
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   232
            // algorithm that invents a normalized string representation
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   233
            // for this number, and we return a hash for that.
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   234
            return canonicalToStringForHashCode(ivalue, fvalue, sign, pvalue).hashCode();
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   235
        }
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   236
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
         * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
        private int compareFractionalPart(XPrecisionDecimal oval) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
            if(fvalue.equals(oval.fvalue))
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
                return EQUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
            StringBuffer temp1 = new StringBuffer(fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
            StringBuffer temp2 = new StringBuffer(oval.fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
            truncateTrailingZeros(temp1, temp2);
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
            return temp1.toString().compareTo(temp2.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
        private void truncateTrailingZeros(StringBuffer fValue, StringBuffer otherFValue) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
            for(int i = fValue.length() - 1;i >= 0; i--)
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
                if(fValue.charAt(i) == '0')
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
                    fValue.deleteCharAt(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
                else
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
                    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
            for(int i = otherFValue.length() - 1;i >= 0; i--)
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
                if(otherFValue.charAt(i) == '0')
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
                    otherFValue.deleteCharAt(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
                else
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
                    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
        public int compareTo(XPrecisionDecimal val) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
            // seen NaN
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
            if(sign == 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
                return INDETERMINATE;
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
            //INF is greater than everything and equal to itself
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
            if(ivalue.equals("INF") || val.ivalue.equals("INF")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
                if(ivalue.equals(val.ivalue))
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
                    return EQUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
                else if(ivalue.equals("INF"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
                    return GREATER_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
                return LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
            //-INF is smaller than everything and equal itself
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
            if(ivalue.equals("-INF") || val.ivalue.equals("-INF")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
                if(ivalue.equals(val.ivalue))
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
                    return EQUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
                else if(ivalue.equals("-INF"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
                    return LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
                return GREATER_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
            if (sign != val.sign)
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
                return sign > val.sign ? GREATER_THAN : LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
            return sign * compare(val);
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
        // To enable comparison - the exponent part of the decimal will be limited
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
        // to the max value of int.
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
        private int compare(XPrecisionDecimal val) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
            if(pvalue != 0 || val.pvalue != 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
                if(pvalue == val.pvalue)
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
                    return intComp(val);
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
                else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
                    if(intDigits + pvalue != val.intDigits + val.pvalue)
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
                        return intDigits + pvalue > val.intDigits + val.pvalue ? GREATER_THAN : LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
                    //otherwise the 2 combined values are the same
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
                    if(pvalue > val.pvalue) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
                        int expDiff = pvalue - val.pvalue;
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
                        StringBuffer buffer = new StringBuffer(ivalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
                        StringBuffer fbuffer = new StringBuffer(fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
                        for(int i = 0;i < expDiff; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
                            if(i < fracDigits) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
                                buffer.append(fvalue.charAt(i));
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
                                fbuffer.deleteCharAt(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
                            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
                            else
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
                                buffer.append('0');
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
                        return compareDecimal(buffer.toString(), val.ivalue, fbuffer.toString(), val.fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
                    else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
                        int expDiff = val.pvalue - pvalue;
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
                        StringBuffer buffer = new StringBuffer(val.ivalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
                        StringBuffer fbuffer = new StringBuffer(val.fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
                        for(int i = 0;i < expDiff; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
                            if(i < val.fracDigits) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
                                buffer.append(val.fvalue.charAt(i));
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
                                fbuffer.deleteCharAt(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
                            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
                            else
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
                                buffer.append('0');
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
                        return compareDecimal(ivalue, buffer.toString(), fvalue, fbuffer.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
            else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
                return intComp(val);
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
         * @param val
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
         * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
        private int intComp(XPrecisionDecimal val) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
            if (intDigits != val.intDigits)
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
                return intDigits > val.intDigits ? GREATER_THAN : LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
            return compareDecimal(ivalue, val.ivalue, fvalue, val.fvalue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
         * @param val
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
         * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
        private int compareDecimal(String iValue, String fValue, String otherIValue, String otherFValue) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
            int ret = iValue.compareTo(otherIValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
            if (ret != 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
                return ret > 0 ? GREATER_THAN : LESS_THAN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
            if(fValue.equals(otherFValue))
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
                return EQUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
            StringBuffer temp1=new StringBuffer(fValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
            StringBuffer temp2=new StringBuffer(otherFValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
            truncateTrailingZeros(temp1, temp2);
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
            ret = temp1.toString().compareTo(temp2.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
            return ret == 0 ? EQUAL : (ret > 0 ? GREATER_THAN : LESS_THAN);
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
        private String canonical;
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   376
        @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
        public synchronized String toString() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
            if (canonical == null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
                makeCanonical();
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
            return canonical;
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
        private void makeCanonical() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
            // REVISIT: to be determined by working group
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
            canonical = "TBD by Working Group";
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
         * @param decimal
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
         * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
        public boolean isIdentical(XPrecisionDecimal decimal) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
            if(ivalue.equals(decimal.ivalue) && (ivalue.equals("INF") || ivalue.equals("-INF") || ivalue.equals("NaN")))
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
                return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
            if(sign == decimal.sign && intDigits == decimal.intDigits && fracDigits == decimal.fracDigits && pvalue == decimal.pvalue
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
                    && ivalue.equals(decimal.ivalue) && fvalue.equals(decimal.fvalue))
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
                return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
            return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
    /* (non-Javadoc)
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
     * @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getAllowedFacets()
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
     */
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   407
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
    public short getAllowedFacets() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
    /* (non-Javadoc)
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
     * @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getActualValue(java.lang.String, com.sun.org.apache.xerces.internal.impl.dv.ValidationContext)
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
     */
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   415
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
    public Object getActualValue(String content, ValidationContext context)
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
    throws InvalidDatatypeValueException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
            return new XPrecisionDecimal(content);
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
        } catch (NumberFormatException nfe) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "precisionDecimal"});
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   425
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
    public int compare(Object value1, Object value2) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
        return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   430
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
    public int getFractionDigits(Object value) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
        return ((XPrecisionDecimal)value).fracDigits;
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   435
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
    public int getTotalDigits(Object value) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
        return ((XPrecisionDecimal)value).totalDigits;
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
17538
d8d911c4e5d4 8013900: More warnings compiling jaxp.
dfuchs
parents: 12457
diff changeset
   440
    @Override
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
    public boolean isIdentical(Object value1, Object value2) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
        if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
            return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
        return ((XPrecisionDecimal)value1).isIdentical((XPrecisionDecimal)value2);
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
}