
it.tidalwave.observation.bluebill.BirdGender Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - Android - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile
* SCM: https://java.net/hg/bluebill-mobile~android-src
*
**********************************************************************************************************************/
package it.tidalwave.observation.bluebill;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.SortedSet;
import java.util.TreeSet;
import it.tidalwave.role.LocalizedDisplayable;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public enum BirdGender implements LocalizedDisplayable
{
NOT_RECORDED,
MALE,
FEMALE,
YUVENILE,
ADULT;
public static final Class BirdGender = BirdGender.class;
private static final String BUNDLE_NAME = BirdGender.class.getPackage().getName().replace('.', '/') + "/Bundle";
/* package */ static final Comparator LOCALE_COMPARATOR = new Comparator()
{
public int compare (final @Nonnull Locale l1, final @Nonnull Locale l2)
{
return l1.getLanguage().compareTo(l2.getLanguage());
}
};
@Nonnull
public String getDisplayName()
{
return getDisplayName(Locale.getDefault());
}
@Nonnull
public String getDisplayName (final @Nonnull Locale locale)
{
// final ResourceBundle bundle = NbBundle.getBundle(BUNDLE_NAME, locale); FIXME: crashes Android 1.5
final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
return bundle.getString("gender_" + toString());
}
@Nonnull
public String getShortDisplayName (final @Nonnull Locale locale)
{
// final ResourceBundle bundle = NbBundle.getBundle(BUNDLE_NAME, locale); FIXME: crashes Android 1.5
final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
return bundle.getString("shortGender_" + toString());
}
@Nonnull
public Map getDisplayNames()
{
final Map result = new HashMap();
for (final Locale locale : getLocales())
{
result.put(locale, getDisplayName(locale));
}
return result;
}
@Nonnull
public SortedSet getLocales()
{
final TreeSet treeSet = new TreeSet(LOCALE_COMPARATOR);
treeSet.addAll(Arrays.asList(new Locale("en"), new Locale("it"))); // FIXME: french?
return treeSet;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy