String specificEpithet = nonViralName.getSpecificEpithet();\r
String infraSpecificEpithet = nonViralName.getInfraSpecificEpithet();\r
\r
- boolean rankExists = false;\r
-\r
StringBuffer replaceFullName = new StringBuffer(fullName);\r
List<NamePosition> genusOrUninomialPosition = getPosition(genusOrUninomial, fullName);\r
List<NamePosition> infraGenericEpithetPosition = getPosition(infraGenericEpithet, fullName);\r
replaceFullName.insert(0, italicBeginTag);\r
\r
if (nameExists(specificEpithetPosition)) {\r
+ boolean insertSpecificEpithetEndTag = true;\r
+\r
if ((specificEpithet.equals(infraSpecificEpithet) && countPattern(infraSpecificEpithet, fullName) == 2) |\r
(! specificEpithet.equals(infraSpecificEpithet) && countPattern(infraSpecificEpithet, fullName) == 1)) {\r
// infraSpecificEpithet exists\r
replaceFullName.insert(infraSpecificEpithetEndLocation + italicBeginTag.length(), italicEndTag);\r
}\r
}\r
+ } else if (rankPosition != null && ! nameExists(rankPosition)) {\r
+ // Rank information does not exist\r
+ insertSpecificEpithetEndTag = false;\r
+ \r
+ // Insert italicEndTag\r
+ replaceFullName.insert(infraSpecificEpithetEndLocation + italicBeginTag.length(), italicEndTag);\r
}\r
}\r
- \r
- int specificEpithetLocation = replaceFullName.indexOf(specificEpithet) + specificEpithet.length();\r
- if (specificEpithetPosition.contains(NamePosition.end)) {\r
- replaceFullName.append(italicEndTag);\r
- } else {\r
- replaceFullName.insert(specificEpithetLocation, italicEndTag);\r
+\r
+ // Insert an italicEndTag for the specificEpithet\r
+ if (insertSpecificEpithetEndTag) {\r
+ int specificEpithetLocation = replaceFullName.indexOf(specificEpithet) + specificEpithet.length();\r
+ if (specificEpithetPosition.contains(NamePosition.end)) {\r
+ replaceFullName.append(italicEndTag);\r
+ } else {\r
+ replaceFullName.insert(specificEpithetLocation, italicEndTag);\r
+ }\r
}\r
} else if (nameExists(infraGenericEpithetPosition)) {\r
int infraGenericEpithetLocation = replaceFullName.indexOf(infraGenericEpithet) + \r