use of org.apache.sis.util.iso.DefaultInternationalString in project sis by apache.
the class PT_FreeText method toCharSequence.
/**
* Returns the content of this {@code <gco:CharacterString>} as an {@code InternationalString}.
*
* @return the character sequence for this {@code <gco:CharacterString>}.
*/
@Override
protected CharSequence toCharSequence() {
// May be null.
String defaultValue = toString();
if (defaultValue != null && contains(defaultValue)) {
/*
* If the <gco:CharacterString> value is repeated in one of the
* <lan:LocalisedCharacterString> elements, keep only the localized
* version (because it specifies the locale, while the unlocalized
* string saids nothing on that matter).
*/
defaultValue = null;
}
/*
* Create the international string with all locales found in the <gml:textGroup>
* element. If the <gml:textGroup> element is missing or empty, then we will use
* an instance of SimpleInternationalString instead than the more heavy
* DefaultInternationalString.
*/
DefaultInternationalString i18n = null;
final TextGroup[] textGroup = this.textGroup;
if (textGroup != null) {
for (final TextGroup group : textGroup) {
if (group != null) {
final LocalisedCharacterString[] localised = group.localized;
if (localised != null) {
for (final LocalisedCharacterString text : localised) {
if (text != null) {
if (i18n == null) {
i18n = new DefaultInternationalString(defaultValue);
}
i18n.add(text.locale, text.text);
}
}
}
}
}
}
if (i18n == null && defaultValue != null) {
return new SimpleInternationalString(defaultValue);
}
return i18n;
}
use of org.apache.sis.util.iso.DefaultInternationalString in project sis by apache.
the class NamedIdentifierTest method createI18N.
/**
* Creates an internationalized name with a code set to "name" localized in English, French and Japanese.
*/
private NamedIdentifier createI18N() {
final DefaultInternationalString i18n = new DefaultInternationalString();
i18n.add(Locale.ENGLISH, "name");
i18n.add(Locale.FRENCH, "nom");
i18n.add(Locale.JAPANESE, "名前");
return new NamedIdentifier(Citations.EPSG, i18n);
}
Aggregations