use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.
the class OwsServiceIdentificationFactory method setTitle.
@Setting(OwsServiceIdentificationFactorySettings.TITLE)
public void setTitle(Object title) throws ConfigurationError {
Validation.notNull("Service Identification Title", title);
if (title instanceof MultilingualString) {
this.title = (MultilingualString) title;
} else if (title instanceof String) {
this.title = createFromString(title);
} else {
throw new ConfigurationError(String.format("%s is not supported as title!", title.getClass().getName()));
}
setRecreate();
}
use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.
the class I18NSerializerTest method test.
private void test(MultilingualString string) {
errors.checkThat(string, is(notNullValue()));
String encoded = new I18NSerializer().encode(string);
System.out.println(encoded);
errors.checkThat(encoded.isEmpty(), is(string.isEmpty()));
MultilingualString decoded = new I18NSerializer().decode(encoded);
errors.checkThat(decoded, is(equalTo(string)));
}
use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.
the class AbstractCapabilitiesBaseTypeDecoder method parseServiceIdentification.
private OwsServiceIdentification parseServiceIdentification(ServiceIdentification serviceIdentification) {
if (serviceIdentification == null) {
return null;
}
OwsCode serviceType = parseCode(serviceIdentification.getServiceType());
Set<String> serviceTypeVersion = Optional.ofNullable(serviceIdentification.getServiceTypeVersionArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
Set<String> fees = Optional.ofNullable(serviceIdentification.getFees()).map(Collections::singleton).orElseGet(Collections::emptySet);
Set<URI> profiles = Optional.ofNullable(serviceIdentification.getProfileArray()).map(Arrays::stream).orElseGet(Stream::empty).map(URI::create).collect(toSet());
Set<String> accessConstraints = Optional.ofNullable(serviceIdentification.getAccessConstraintsArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
MultilingualString title = new MultilingualString();
MultilingualString abstrakt = new MultilingualString();
Optional.ofNullable(serviceIdentification.getTitleArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(title::addLocalization);
Optional.ofNullable(serviceIdentification.getAbstractArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(abstrakt::addLocalization);
Set<OwsKeyword> keywords = Optional.ofNullable(serviceIdentification.getKeywordsArray()).map(Arrays::stream).orElseGet(Stream::empty).flatMap(this::parseKeyword).filter(Objects::nonNull).collect(toSet());
return new OwsServiceIdentification(serviceType, serviceTypeVersion, profiles, fees, accessConstraints, title, abstrakt, keywords);
}
use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.
the class I18NJsonEncoder method decodeMultilingualString.
public MultilingualString decodeMultilingualString(JsonNode json) {
MultilingualString mls = new MultilingualString();
decodeMultilingualString(json, mls);
return mls;
}
use of org.n52.janmayen.i18n.MultilingualString in project arctic-sea by 52North.
the class I18NJsonEncoder method decodeMultilingualString.
private void decodeMultilingualString(JsonNode json, MultilingualString mls) {
Iterator<Entry<String, JsonNode>> it = json.fields();
while (it.hasNext()) {
Entry<String, JsonNode> e = it.next();
Locale locale = LocaleHelper.decode(e.getKey());
mls.addLocalization(locale, e.getValue().asText());
}
}
Aggregations