NameFormatter { public static String canonicalMinimal(ParsedName n) { return buildName(n, false, false, false, false, false, true, true, false, false, false, false, false, false, false); } private  NameFormatter(); static String canonical(ParsedName n); static String canonicalWithoutAuthorship(ParsedName n); static String canonicalMinimal(ParsedName n); static String canonicalComplete(ParsedName n); static String canonicalCompleteHtml(ParsedName n); static String authorshipComplete(ParsedAuthorship n); static String authorString(Authorship authors, boolean inclYear); static String buildName(ParsedName n,
                                 boolean hybridMarker,
                                 boolean rankMarker,
                                 boolean authorship,
                                 boolean genusForinfrageneric,
                                 boolean infrageneric,
                                 boolean decomposition,
                                 boolean asciiOnly,
                                 boolean showQualifier,
                                 boolean showIndet,
                                 boolean nomNote,
                                 boolean showSensu,
                                 boolean showCultivar,
                                 boolean showStrain,
                                 boolean html
  ); static void appendAuthorship(StringBuilder sb, Authorship auth, boolean includeYear); static final char HYBRID_MARKER; }
@Test public void testCanonicalNames() throws Exception { pn.setGenus("Abies"); assertEquals("Abies", pn.canonicalName()); pn.setSpecificEpithet("alba"); assertEquals("Abies alba", pn.canonicalName()); pn = new ParsedName(); pn.setGenus("Abies"); pn.setSpecificEpithet("alba"); pn.setRank(Rank.VARIETY); pn.setCombinationAuthorship(Authorship.yearAuthors("1887", "Mill.")); pn.setBasionymAuthorship(Authorship.authors("Carl.")); pn.setNotho(NamePart.GENERIC); pn.setInfraspecificEpithet("alpina"); pn.setTaxonomicNote("Döring"); pn.setNomenclaturalNote("nom. illeg."); assertEquals("Abies alba alpina", NameFormatter.canonicalMinimal(pn)); assertEquals("× Abies alba var. alpina", NameFormatter.canonicalWithoutAuthorship(pn)); assertEquals("× Abies alba var. alpina (Carl.) Mill., 1887", NameFormatter.canonical(pn)); assertEquals("× Abies alba var. alpina (Carl.) Mill., 1887 Döring, nom. illeg.", NameFormatter.canonicalComplete(pn)); }
@Test public void epithetQualifiers() throws Exception { pn.setGenus("Abies"); pn.setSpecificEpithet("alba"); pn.setEpithetQualifier(NamePart.SPECIFIC, "aff."); assertEquals("Abies alba", NameFormatter.canonicalMinimal(pn)); assertEquals("Abies aff. alba", pn.canonicalName()); assertEquals("Abies aff. alba", pn.canonicalNameComplete()); pn.getEpithetQualifier().clear(); pn.setEpithetQualifier(NamePart.INFRASPECIFIC, "cf."); pn.setInfraspecificEpithet("alpina"); pn.setRank(Rank.VARIETY); pn.setCombinationAuthorship(Authorship.yearAuthors("1887", "Mill.")); pn.setBasionymAuthorship(Authorship.authors("Carl.")); pn.setNotho(NamePart.GENERIC); pn.setNomenclaturalNote("nom. illeg."); assertEquals("Abies alba alpina", NameFormatter.canonicalMinimal(pn)); assertEquals("× Abies alba cf. var. alpina (Carl.) Mill., 1887", NameFormatter.canonical(pn)); assertEquals("× Abies alba cf. var. alpina (Carl.) Mill., 1887, nom. illeg.", NameFormatter.canonicalComplete(pn)); }