test/jdk/java/util/PluggableLocale/providersrc/FooNumberFormat.java
changeset 52265 297450fcab26
parent 52264 d6c322e900b2
parent 52203 5e894b0f5e63
child 52266 7530494ed51d
equal deleted inserted replaced
52264:d6c322e900b2 52265:297450fcab26
     1 /*
       
     2  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 package com.foo;
       
    25 
       
    26 import java.text.*;
       
    27 
       
    28 /**
       
    29  * FooNumberFormat provides DecimalFormat methods required for the SPI testing.
       
    30  */
       
    31 public class FooNumberFormat extends NumberFormat {
       
    32     private DecimalFormat df;
       
    33 
       
    34     public FooNumberFormat(String pattern, DecimalFormatSymbols dfs) {
       
    35         df = new DecimalFormat(pattern, dfs);
       
    36     }
       
    37 
       
    38     @Override
       
    39     public StringBuffer format(double number,
       
    40                                StringBuffer toAppendTo,
       
    41                                FieldPosition pos) {
       
    42         return df.format(number, toAppendTo, pos);
       
    43     }
       
    44 
       
    45     @Override
       
    46     public StringBuffer format(long number,
       
    47                                StringBuffer toAppendTo,
       
    48                                FieldPosition pos) {
       
    49         return df.format(number, toAppendTo, pos);
       
    50     }
       
    51 
       
    52     @Override
       
    53     public Number parse(String source, ParsePosition parsePosition) {
       
    54         return df.parse(source, parsePosition);
       
    55     }
       
    56 
       
    57     @Override
       
    58     public boolean equals(Object other) {
       
    59         return other instanceof FooNumberFormat
       
    60             && df.equals(((FooNumberFormat)other).df);
       
    61     }
       
    62 
       
    63     @Override
       
    64     public int hashCode() {
       
    65         return df.hashCode();
       
    66     }
       
    67 
       
    68     // DecimalFormat specific methods required for testing
       
    69 
       
    70     public String toPattern() {
       
    71         return df.toPattern();
       
    72     }
       
    73 
       
    74     public DecimalFormatSymbols getDecimalFormatSymbols() {
       
    75         return df.getDecimalFormatSymbols();
       
    76     }
       
    77 
       
    78     public void setDecimalSeparatorAlwaysShown(boolean newValue) {
       
    79         df.setDecimalSeparatorAlwaysShown(newValue);
       
    80     }
       
    81 }