All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.time4j.format.NumberSymbolProvider Maven / Gradle / Ivy

There is a newer version: 4.38
Show newest version
/*
 * -----------------------------------------------------------------------
 * Copyright © 2013-2015 Meno Hochschild, 
 * -----------------------------------------------------------------------
 * This file (NumberSymbolProvider.java) is part of project Time4J.
 *
 * Time4J is free software: You can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Time4J is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Time4J. If not, see .
 * -----------------------------------------------------------------------
 */

package net.time4j.format;

import java.text.DecimalFormatSymbols;
import java.util.Locale;


/**
 * 

This SPI-interface enables the access to localized * number properties like zero digits and is instantiated via a * {@code ServiceLoader}-mechanism.

* *

If there is no external {@code NumberSymbolProvider} then Time4J will * just delegate to the internal resources or to the JDK.

* * @author Meno Hochschild * @since 2.1 * @see java.util.ServiceLoader * @see java.text.DecimalFormatSymbols#getZeroDigit * @doctags.spec Implementations must have a public no-arg constructor. */ /*[deutsch] *

Dieses SPI-Interface ermöglicht den Zugriff * auf {@code Locale}-abhängige Zahleigenschaften wie Nullziffern * und wird über einen {@code ServiceLoader}-Mechanismus instanziert.

* *

Wird kein externer {@code NumberSymbolProvider} gefunden, wird intern * eine Instanz erzeugt, die an die internen Ressourcen oder das JDK delegiert.

* * @author Meno Hochschild * @since 2.1 * @see java.util.ServiceLoader * @see java.text.DecimalFormatSymbols#getZeroDigit * @doctags.spec Implementations must have a public no-arg constructor. */ public interface NumberSymbolProvider { //~ Statische Felder/Initialisierungen -------------------------------- /** *

Default provider which delegates to standard JVM resources.

* * @see DecimalFormatSymbols */ /*[deutsch] *

Standardimplementierung, die an die Ressourcen der JVM delegiert.

* * @see DecimalFormatSymbols */ NumberSymbolProvider DEFAULT = new NumberSymbolProvider() { @Override public Locale[] getAvailableLocales() { return DecimalFormatSymbols.getAvailableLocales(); } @Override public char getZeroDigit(Locale locale) { return getSymbols(locale).getZeroDigit(); } @Override public char getDecimalSeparator(Locale locale) { return getSymbols(locale).getDecimalSeparator(); } @Override public String getPlusSign(Locale locale) { if (locale.getLanguage().equals("ar")) { return "\u200F+"; } return String.valueOf('+'); } @Override public String getMinusSign(Locale locale) { if (locale.getLanguage().equals("ar")) { return "\u200F\u002D"; } return String.valueOf(getSymbols(locale).getMinusSign()); } private DecimalFormatSymbols getSymbols(Locale loc) { return DecimalFormatSymbols.getInstance(loc); } }; //~ Methoden ---------------------------------------------------------- /** *

Yields the supported languages.

* * @return Locale-array */ /*[deutsch] *

Gibt die unterstützten Sprachen an.

* * @return Locale-array */ Locale[] getAvailableLocales(); /** *

Returns the localized zero digit.

* * @param locale language and country setting * @return zero digit of associated numbering system */ /*[deutsch] *

Liefert die lokalisierte Nullziffer.

* * @param locale language and country setting * @return zero digit of associated numbering system */ char getZeroDigit(Locale locale); /** *

Returns the localized decimal separator.

* * @param locale language and country setting * @return localized decimal separator */ /*[deutsch] *

Liefert das lokalisierte Dezimaltrennzeichen.

* * @param locale language and country setting * @return localized decimal separator */ char getDecimalSeparator(Locale locale); /** *

Returns the localized plus sign.

* * @param locale language and country setting * @return localized plus sign, possibly including RLM- or LRM-markers * @since 3.13/4.10 */ /*[deutsch] *

Liefert das lokalisierte Plus-Zeichen.

* * @param locale language and country setting * @return localized plus sign, possibly including RLM- or LRM-markers * @since 3.13/4.10 */ default String getPlusSign(Locale locale) { return String.valueOf('+'); } /** *

Returns the localized minus sign.

* * @param locale language and country setting * @return localized minus sign, possibly including RLM- or LRM-markers */ /*[deutsch] *

Liefert das lokalisierte Minus-Zeichen.

* * @param locale language and country setting * @return localized minus sign, possibly including RLM- or LRM-markers */ String getMinusSign(Locale locale); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy