List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:org.openmrs.module.encounteralerts.SerializedObjectEditor.java
public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { EncounterAlertsService service = Context.getService(EncounterAlertsService.class); try {//from www . j av a2 s . co m SerializedObject object = service.getEncounterQuery(Integer.valueOf(text)); setValue(object); } catch (Exception ex) { SerializedObject object = service.getEncounterQueryByUuid(text); setValue(object); if (object == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("SerializedObject not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:org.openmrs.module.facilitydata.propertyeditor.FacilityDataFormEditor.java
/** * @see PropertyEditorSupport#setAsText(String) *//*from w w w. j av a2s . c o m*/ @Override public void setAsText(String text) throws IllegalArgumentException { FacilityDataService svc = Context.getService(FacilityDataService.class); if (StringUtils.hasText(text)) { setValue(svc.getFacilityDataForm(Integer.parseInt(text))); } else { setValue(null); } }
From source file:csns.web.editor.QuarterPropertyEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) setValue(new Quarter(Integer.valueOf(text))); }
From source file:org.openmrs.module.facilitydata.propertyeditor.FacilityDataQuestionEditor.java
/** * @see PropertyEditorSupport#setAsText(String) *//* w w w .j a v a 2 s .c om*/ @Override public void setAsText(String text) throws IllegalArgumentException { FacilityDataService svc = Context.getService(FacilityDataService.class); if (StringUtils.hasText(text)) { setValue(svc.getQuestion(Integer.parseInt(text))); } else { setValue(null); } }
From source file:org.openmrs.web.taglib.GlobalPropertyTag.java
public int doStartTag() { Object value;/* w w w . ja va 2s. com*/ if (StringUtils.hasText(listSeparator)) { value = Collections.singletonList(defaultValue); } else { value = defaultValue; } if (StringUtils.hasText(listSeparator)) { String stringVal = (String) Context.getAdministrationService().getGlobalProperty(key, defaultValue); if (stringVal.trim().length() == 0) { value = Collections.emptyList(); } else { value = Arrays.asList(stringVal.split(listSeparator)); } } else { value = (String) Context.getAdministrationService().getGlobalProperty(key, defaultValue); } try { if (var != null) { pageContext.setAttribute(var, value); } else { pageContext.getOut().write(value.toString()); } } catch (Exception e) { log.error("error getting global property", e); } return SKIP_BODY; }
From source file:org.openmrs.module.facilitydata.propertyeditor.FacilityDataFormSchemaEditor.java
/** * @see PropertyEditorSupport#setAsText(String) *///from w w w. j a va 2 s . c o m @Override public void setAsText(String text) throws IllegalArgumentException { FacilityDataService svc = Context.getService(FacilityDataService.class); if (StringUtils.hasText(text)) { setValue(svc.getFacilityDataFormSchema(Integer.parseInt(text))); } else { setValue(null); } }
From source file:org.openmrs.module.idgen.validator.IdentifierSourceValidator.java
/** * @see Validator#validate(Object, Errors) *///w w w .j av a2s .com public void validate(Object o, Errors errors) { IdentifierSource source = (IdentifierSource) o; // Name is required if (!StringUtils.hasText(source.getName())) { errors.reject("Name of IdentifierSource is required"); } }
From source file:org.web4thejob.util.converter.StringToClassConverter.java
@Override public Class<?> convert(String source) { try {/* w w w . ja v a 2 s. c o m*/ if (StringUtils.hasText(source)) { return Class.forName(source); } } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
From source file:org.openmrs.module.facilitydata.propertyeditor.FacilityDataQuestionTypeEditor.java
/** * @see PropertyEditorSupport#setAsText(String) *///from w ww .j a va2s . c om @Override public void setAsText(String text) throws IllegalArgumentException { FacilityDataService svc = Context.getService(FacilityDataService.class); if (StringUtils.hasText(text)) { setValue(svc.getQuestionType(Integer.parseInt(text))); } else { setValue(null); } }
From source file:org.opensprout.osaf.propertyeditor.FormatDatePropertyEditor.java
/** String -> Date */ @Override/*from w ww.ja v a 2s .com*/ public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasText(text)) { setValue(null); } else { try { setValue(format.parse(text)); } catch (ParseException e) { throw new IllegalArgumentException("Invalid date string " + text, e); } } }