/*
* -----------------------------------------------------------------------
* Copyright © 2013-2015 Meno Hochschild, <http://www.menodata.de/>
* -----------------------------------------------------------------------
* This file (HijriEra.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 <http://www.gnu.org/licenses/>.
* -----------------------------------------------------------------------
*/
package net.time4j.calendar;
import net.time4j.engine.CalendarEra;
import net.time4j.format.CalendarText;
import net.time4j.format.TextWidth;
import java.util.Locale;
/**
* <p>The Hijri calendar only supports one single era called "Anno Hegirae" with the
* numerical value {@code 1}. </p>
*
* @author Meno Hochschild
* @since 3.5/4.3
*/
/*[deutsch]
* <p>Der islamische Kalender unterstützt nur eine einzige Ära, die "Anno Hegirae"
* genannt wird und den numerischen Wert {@code 1} hat. </p>
*
* @author Meno Hochschild
* @since 3.5/4.3
*/
public enum HijriEra
implements CalendarEra {
//~ Statische Felder/Initialisierungen --------------------------------
/**
* Singleton instance (often abbreviated as "AH").
*/
/*[deutsch]
* Singleton-Instanz (oft als "AH" abgekürzt).
*/
ANNO_HEGIRAE;
//~ Methoden ----------------------------------------------------------
@Override
public int getValue() {
return 1;
}
/**
* <p>Equivalent to the expression {@code getDisplayName(locale, TextWidth.WIDE)}. </p>
*
* @param locale language setting
* @return descriptive text (long form, never {@code null})
* @see #getDisplayName(Locale, TextWidth)
* @since 3.5/4.3
*/
/*[deutsch]
* <p>Entspricht dem Ausdruck {@code getDisplayName(locale, TextWidth.WIDE)}. </p>
*
* @param locale language setting
* @return descriptive text (long form, never {@code null})
* @see #getDisplayName(Locale, TextWidth)
* @since 3.5/4.3
*/
public String getDisplayName(Locale locale) {
return this.getDisplayName(locale, TextWidth.WIDE);
}
/**
* <p>Gets the description text dependent on the locale and style
* parameters. </p>
*
* <p>The second argument controls the width of description. </p>
*
* @param locale language setting
* @param width text width
* @return descriptive text for given locale and style (never {@code null})
* @since 3.5/4.3
*/
/*[deutsch]
* <p>Liefert den sprachabhängigen Beschreibungstext. </p>
*
* <p>Über das zweite Argument kann gesteuert werden, ob eine kurze
* oder eine lange Form des Beschreibungstexts ausgegeben werden soll. Das
* ist besonders sinnvoll in Benutzeroberflächen, wo zwischen der
* Beschriftung und der detaillierten Erläuterung einer graphischen
* Komponente unterschieden wird. </p>
*
* @param locale language setting
* @param width text width
* @return descriptive text for given locale and style (never {@code null})
* @since 3.5/4.3
*/
public String getDisplayName(
Locale locale,
TextWidth width
) {
CalendarText names = CalendarText.getInstance("islamic", locale);
return names.getEras(width).print(this);
}
}