public CommonNamesPresentationModel (final @Nonnull Taxon taxon, final @Nonnull Locale locale) throws NotFoundException { super(new Object[] { taxon }); language = getMessage(_, "lang_" + locale.getLanguage()); name = taxon.getDisplayName(locale); scientificName = taxon.getScientificName(); } }
@Nonnull private String getDisplayName (final @Nonnull Taxon taxon) { try { return taxon.getDisplayName(primaryTaxonLocale); } catch (NotFoundException e) { // We prepend some zeds to scientific names, so if they are compared against common names, // they go to the bottom of the list. // FIXME: in some locales, Z is not the last letter! return "ZZZZZZZ" + taxon.getScientificName(); } } };
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull protected URI getUriFor (final @Nonnull Taxon taxon) throws NotFoundException, URISyntaxException { final String displayName = taxon.getDisplayName(Locale.UK); final StringBuilder buffer = new StringBuilder(BBC_CONTEXT + "nature/species/"); String separator = ""; for (final String s : displayName.split(" ")) { buffer.append(separator).append(capitalized(s)); separator = "_"; } buffer.append(".rdf"); return new URI(buffer.toString()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private boolean matchesLocalizedNames (final @Nonnull Taxon taxon, final @Nonnull CharSequence match, final @Nonnull NameMatcher nameMatcher) { for (final Locale locale : preferences.get().getTaxonomyLocales()) { try { if (nameMatcher.matches(taxon.getDisplayName(locale), match, locale)) { return true; } } catch (NotFoundException e) { // never mind } } return false; }
final String displayName = taxon.getDisplayName(locale); buffer.append(separator + size1 + style1 + displayName + style2 + size2); style1 = style2 = "";
@Nonnull public String render (final @Nonnull Object... args) { final StringBuilder buffer = new StringBuilder(); String separator = ""; final List<Locale> taxonLocales = preferences.get().getTaxonomyLocales(); for (final Locale locale : taxonLocales) { try { buffer.append(separator).append(taxon.getDisplayName(locale)); separator = ", "; } catch (NotFoundException e) { // a localized name not available, just ignore it } } if (preferences.get().isScientificNamesRenderingEnabled()) { buffer.append(" (").append(taxon.getScientificName()).append(")"); } return buffer.toString(); } }
final String displayName = taxon.getDisplayName(locale); buffer.append(separator + size1 + style1 + displayName + extra + style2 + size2); style1 = style2 = extra = "";
try taxonNames.add(taxon.getDisplayName(primaryLocale));
buffer.append(taxon.getDisplayName(primaryTaxonLocale)).append(separator);