com.foobar.Utils Java Examples

The following examples show how to use com.foobar.Utils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NumberFormatProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public NumberFormat getIntegerInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            String pattern =
                MessageFormat.format(patterns[INTEGERSTYLE],
                                     dialect[i],
                                     dialect[i]);
            FooNumberFormat nf = new FooNumberFormat(pattern,
                DecimalFormatSymbols.getInstance(locale));
            nf.setMaximumFractionDigits(0);
            nf.setDecimalSeparatorAlwaysShown(false);
            nf.setParseIntegerOnly(true);
            return nf;
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #2
Source File: DateFormatSymbolsProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public DateFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDateFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDateFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #3
Source File: DecimalFormatSymbolsProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DecimalFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDecimalFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDecimalFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #4
Source File: NumberFormatProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public NumberFormat getIntegerInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            String pattern =
                MessageFormat.format(patterns[INTEGERSTYLE],
                                     dialect[i],
                                     dialect[i]);
            FooNumberFormat nf = new FooNumberFormat(pattern,
                DecimalFormatSymbols.getInstance(locale));
            nf.setMaximumFractionDigits(0);
            nf.setDecimalSeparatorAlwaysShown(false);
            nf.setParseIntegerOnly(true);
            return nf;
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #5
Source File: DateFormatSymbolsProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public DateFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDateFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDateFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #6
Source File: DecimalFormatSymbolsProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public DecimalFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDecimalFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDecimalFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #7
Source File: CurrencyNameProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getDisplayName(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u65e5\u672c\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u65e5\u672c\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u65e5\u672c\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u65e5\u672c\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #8
Source File: TimeZoneNameProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public String getDisplayName(String id, boolean dst, int style, Locale language) {
    if (!Utils.supportsLocale(Arrays.asList(avail), language)) {
        throw new IllegalArgumentException("locale is not one of available locales: "+language);
    }

    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], language)) {
            String[][] namesForALocale = names[i];
            for (int j = 0; j < namesForALocale.length; j++) {
                String[] array = namesForALocale[j];
                if (id.equals(array[0])) {
                    String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];
                    return ret;
                }
            }
        }
    }
    return null;
}
 
Example #9
Source File: CurrencyNameProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getDisplayName(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u65e5\u672c\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u65e5\u672c\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u65e5\u672c\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u65e5\u672c\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #10
Source File: CurrencyNameProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public String getSymbol(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #11
Source File: CurrencyNameProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public String getSymbol(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #12
Source File: TimeZoneNameProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public String getDisplayName(String id, boolean dst, int style, Locale language) {
    if (!Utils.supportsLocale(Arrays.asList(avail), language)) {
        throw new IllegalArgumentException("locale is not one of available locales: "+language);
    }

    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], language)) {
            String[][] namesForALocale = names[i];
            for (int j = 0; j < namesForALocale.length; j++) {
                String[] array = namesForALocale[j];
                if (id.equals(array[0])) {
                    String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];
                    return ret;
                }
            }
        }
    }
    return null;
}
 
Example #13
Source File: DateFormatSymbolsProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public DateFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDateFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDateFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #14
Source File: CurrencyNameProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public String getSymbol(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #15
Source File: DecimalFormatSymbolsProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public DecimalFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDecimalFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDecimalFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #16
Source File: DecimalFormatSymbolsProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public DecimalFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDecimalFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDecimalFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #17
Source File: NumberFormatProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public NumberFormat getIntegerInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            String pattern =
                MessageFormat.format(patterns[INTEGERSTYLE],
                                     dialect[i],
                                     dialect[i]);
            FooNumberFormat nf = new FooNumberFormat(pattern,
                DecimalFormatSymbols.getInstance(locale));
            nf.setMaximumFractionDigits(0);
            nf.setDecimalSeparatorAlwaysShown(false);
            nf.setParseIntegerOnly(true);
            return nf;
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #18
Source File: CurrencyNameProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public String getSymbol(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #19
Source File: CurrencyNameProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getDisplayName(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u65e5\u672c\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u65e5\u672c\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u65e5\u672c\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u65e5\u672c\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #20
Source File: TimeZoneNameProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public String getDisplayName(String id, boolean dst, int style, Locale language) {
    if (!Utils.supportsLocale(Arrays.asList(avail), language)) {
        throw new IllegalArgumentException("locale is not one of available locales: "+language);
    }

    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], language)) {
            String[][] namesForALocale = names[i];
            for (int j = 0; j < namesForALocale.length; j++) {
                String[] array = namesForALocale[j];
                if (id.equals(array[0])) {
                    String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];
                    return ret;
                }
            }
        }
    }
    return null;
}
 
Example #21
Source File: NumberFormatProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public NumberFormat getIntegerInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            String pattern =
                MessageFormat.format(patterns[INTEGERSTYLE],
                                     dialect[i],
                                     dialect[i]);
            FooNumberFormat nf = new FooNumberFormat(pattern,
                DecimalFormatSymbols.getInstance(locale));
            nf.setMaximumFractionDigits(0);
            nf.setDecimalSeparatorAlwaysShown(false);
            nf.setParseIntegerOnly(true);
            return nf;
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #22
Source File: TimeZoneNameProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public String getDisplayName(String id, boolean dst, int style, Locale language) {
    if (!Utils.supportsLocale(Arrays.asList(avail), language)) {
        throw new IllegalArgumentException("locale is not one of available locales: "+language);
    }

    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], language)) {
            String[][] namesForALocale = names[i];
            for (int j = 0; j < namesForALocale.length; j++) {
                String[] array = namesForALocale[j];
                if (id.equals(array[0])) {
                    String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];
                    return ret;
                }
            }
        }
    }
    return null;
}
 
Example #23
Source File: CurrencyNameProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getDisplayName(String c, Locale locale) {
    if (!Utils.supportsLocale(Arrays.asList(avail), locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    if (c.equals("JPY")) {
        if (Utils.supportsLocale(avail[0], locale)) {
            return "\u65e5\u672c\u5186\u3084\u3002";
        } else if (Utils.supportsLocale(avail[1], locale)) {
            return "\u65e5\u672c\u5186\u3069\u3059\u3002";
        } else if (Utils.supportsLocale(avail[2], locale)) {
            return "\u65e5\u672c\u5186\u3067\u3059\u3002";
        } else if (Utils.supportsLocale(avail[3], locale)) {
            return "\u65e5\u672c\u5186\u3070\u3064\u3070\u3064\u3002";
        }
    }
    return null;
}
 
Example #24
Source File: DateFormatSymbolsProviderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DateFormatSymbols getInstance(Locale locale) {
    if (!Utils.supportsLocale(availList, locale)) {
        throw new IllegalArgumentException("locale is not supported: "+locale);
    }

    FooDateFormatSymbols fdfs = symbols.get(locale);
    if (fdfs == null) {
        for (int index = 0; index < avail.length; index ++) {
            if (Utils.supportsLocale(avail[index], locale)) {
                fdfs = new FooDateFormatSymbols(index);
                symbols.put(locale, fdfs);
                break;
            }
        }
    }
    return fdfs;
}
 
Example #25
Source File: BreakIteratorProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public BreakIterator getSentenceInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            return new FooBreakIterator(Type.SENTENCE, i);
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #26
Source File: BreakIteratorProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public BreakIterator getLineInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            return new FooBreakIterator(Type.LINE, i);
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #27
Source File: DateFormatProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public DateFormat getTimeInstance(int style, Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            return new FooDateFormat(timePattern[style]+dialect[i], locale);
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #28
Source File: NumberFormatProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public NumberFormat getCurrencyInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            String pattern =
                MessageFormat.format(patterns[CURRENCYSTYLE],
                                     dialect[i],
                                     dialect[i]);
            FooNumberFormat nf = new FooNumberFormat(pattern,
                DecimalFormatSymbols.getInstance(locale));
            adjustForCurrencyDefaultFractionDigits(nf);
            return nf;
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #29
Source File: DateFormatProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            return new FooDateFormat(
                datePattern[dateStyle]+" "+timePattern[timeStyle]+dialect[i], locale);
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}
 
Example #30
Source File: BreakIteratorProviderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public BreakIterator getWordInstance(Locale locale) {
    for (int i = 0; i < avail.length; i ++) {
        if (Utils.supportsLocale(avail[i], locale)) {
            return new FooBreakIterator(Type.WORD, i);
        }
    }
    throw new IllegalArgumentException("locale is not supported: "+locale);
}