* @return The new tag string.
**/
private static String createTagString(final String lang, final String script, final String region, final String trailing,
final String alternateTags) {
LocaleIDParser parser = null;
boolean regionAppended = false;
StringBuilder tag = new StringBuilder();
if (!isEmptyString(lang)) {
appendTag(lang, tag);
} else if (isEmptyString(alternateTags)) {
/*
* Append the value for an unknown language, if
* we found no language.
*/
appendTag(UNDEFINED_LANGUAGE, tag);
} else {
parser = new LocaleIDParser(alternateTags);
String alternateLang = parser.getLanguage();
/*
* Append the value for an unknown language, if
* we found no language.
*/
appendTag(!isEmptyString(alternateLang) ? alternateLang : UNDEFINED_LANGUAGE, tag);
}
if (!isEmptyString(script)) {
appendTag(script, tag);
} else if (!isEmptyString(alternateTags)) {
/*
* Parse the alternateTags string for the script.
*/
if (parser == null) {
parser = new LocaleIDParser(alternateTags);
}
String alternateScript = parser.getScript();
if (!isEmptyString(alternateScript)) {
appendTag(alternateScript, tag);
}
}
if (!isEmptyString(region)) {
appendTag(region, tag);
regionAppended = true;
} else if (!isEmptyString(alternateTags)) {
/*
* Parse the alternateTags string for the region.
*/
if (parser == null) {
parser = new LocaleIDParser(alternateTags);
}
String alternateRegion = parser.getCountry();
if (!isEmptyString(alternateRegion)) {
appendTag(alternateRegion, tag);
regionAppended = true;