use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction method getDescription.
public String getDescription() {
List<NaturalLanguageStringBean> descriptions = _model.getDescriptions();
if (descriptions == null || descriptions.isEmpty()) {
return null;
}
NaturalLanguageStringBean nls = descriptions.get(0);
return nls.getValue();
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class AbstractSearchResultFactoryImpl method setDescription.
private boolean setDescription(Set<String> serviceAlertDescriptions, List<NaturalLanguageStringBean> descriptions, boolean htmlizeNewlines) {
boolean descriptionsAdded = false;
if (descriptions != null) {
for (NaturalLanguageStringBean description : descriptions) {
if (description.getValue() != null) {
serviceAlertDescriptions.add((htmlizeNewlines ? description.getValue().replace("\n", "<br/>") : description.getValue()));
descriptionsAdded = true;
}
}
}
return descriptionsAdded;
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getBestString.
public NaturalLanguageStringV2Bean getBestString(List<NaturalLanguageStringBean> strings) {
if (strings == null || strings.isEmpty())
return null;
NaturalLanguageStringBean noLang = null;
for (NaturalLanguageStringBean nls : strings) {
String lang = nls.getLang();
if (lang == null) {
noLang = nls;
continue;
}
/**
* To better match the language, we let Locale handle canonicalization
*/
Locale locale = new Locale(lang);
if (locale.getLanguage().equals(_locale.getLanguage()))
return getString(nls);
}
if (noLang != null)
return getString(noLang);
return null;
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class AlertsForAgencyAction method fillTranslations.
private void fillTranslations(List<NaturalLanguageStringBean> input, TranslatedString.Builder output) {
for (NaturalLanguageStringBean nls : input) {
Translation.Builder translation = output.addTranslationBuilder();
translation.setText(nls.getValue());
if (nls.getLang() != null) {
translation.setLanguage(nls.getLang());
}
}
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertAction method setDescription.
public void setDescription(String description) {
List<NaturalLanguageStringBean> descriptions = _model.getDescriptions();
if (descriptions == null) {
descriptions = new ArrayList<NaturalLanguageStringBean>();
_model.setDescriptions(descriptions);
}
if (descriptions.isEmpty()) {
descriptions.add(new NaturalLanguageStringBean());
}
NaturalLanguageStringBean nls = descriptions.get(0);
nls.setValue(description);
nls.setLang(Locale.getDefault().getLanguage());
}
Aggregations