List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:biz.c24.io.spring.integration.config.XPathRouterParser.java
@Override protected BeanDefinition doParseRouter(Element element, ParserContext parserContext) { BeanDefinitionBuilder xpathRouterBuilder = BeanDefinitionBuilder .genericBeanDefinition("biz.c24.io.spring.integration.router.C24XPathRouter"); String expression = element.getAttribute("xpath-statement"); String expressionRef = element.getAttribute("xpath-statement-ref"); boolean hasRef = StringUtils.hasText(expressionRef); Assert.isTrue(hasRef ^ StringUtils.hasText(expression), "Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required."); if (hasRef) { xpathRouterBuilder.addConstructorArgReference(expressionRef); } else {/*w w w .j a v a 2 s . c o m*/ xpathRouterBuilder.addConstructorArgValue(expression); } return xpathRouterBuilder.getBeanDefinition(); }
From source file:org.openmrs.module.radiology.report.RadiologyReportEditor.java
/** * @should set value to radiology report whos id matches given text * @should set value to radiology report whos uuid matches given text * @should throw illegal argument exception for radiology report not found * @should return null for empty text/*from w ww. ja v a 2 s .c om*/ * * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) */ public void setAsText(String text) throws IllegalArgumentException { final RadiologyReportService radiologyReportService = Context.getService(RadiologyReportService.class); if (StringUtils.hasText(text)) { try { setValue(radiologyReportService.getRadiologyReport(Integer.valueOf(text))); } catch (Exception ex) { final RadiologyReport radiologyReport = radiologyReportService.getRadiologyReportByUuid(text); setValue(radiologyReport); if (radiologyReport == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("RadiologyReport not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:nz.co.senanque.madura.bundle.spring.ManagerBeanDefinitionParser.java
protected void doParse(Element element, BeanDefinitionBuilder bean) { String directory = element.getAttribute("directory"); if (StringUtils.hasText(directory)) { bean.addPropertyValue("directory", directory); }/*from w w w . j av a 2s .c o m*/ String id = element.getAttribute("id"); if (!StringUtils.hasText(id)) { bean.addPropertyValue("id", "bundleManager"); } String time = element.getAttribute("time"); if (StringUtils.hasLength(time)) { bean.addPropertyValue("time", time); } String export = element.getAttribute("export"); if (StringUtils.hasLength(export)) { bean.addPropertyValue("export", export); } String childFirst = element.getAttribute("childFirst"); if (StringUtils.hasLength(childFirst)) { bean.addPropertyValue("childFirst", childFirst); } }
From source file:com.consol.citrus.admin.converter.action.ReceiveMessageActionConverter.java
@Override public TestAction convert(ReceiveModel model) { TestAction action = new TestAction(getActionType(), getSourceModelClass()); action.add(property("endpoint", model)); if (model.getMessage() != null) { if (StringUtils.hasText(model.getMessage().getData())) { action.add(new Property("message.data", "message.data", "Message Data", model.getMessage().getData(), false)); }/* w w w . j a va 2s. c om*/ if (model.getMessage().getPayload() != null) { action.add(new Property("message.payload", "message.payload", "Message Payload", PayloadElementParser.parseMessagePayload(model.getMessage().getPayload().getAnies().get(0)), false)); } if (model.getMessage().getResource() != null && StringUtils.hasText(model.getMessage().getResource().getFile())) { action.add(new Property("message.resource", "message.resource", "Message Resource", model.getMessage().getResource().getFile(), false)); } } action.add(property("actor", "TestActor", model)); return action; }
From source file:csns.web.controller.ProgramController.java
@RequestMapping("/program/search") public String search(@RequestParam(required = false) String term, ModelMap models) { if (StringUtils.hasText(term)) models.addAttribute("programs", programDao.searchPrograms(term, -1)); return "program/search"; }
From source file:org.openmrs.module.household.model.editor.HouseholdDefinitionEditor.java
/** * @should set using id//w ww . j a v a2s . c o m * @should set using uuid */ public void setAsText(String text) throws IllegalArgumentException { HouseholdService hs = Context.getService(HouseholdService.class); if (StringUtils.hasText(text)) { try { setValue(hs.getHouseholdDefinition(Integer.valueOf(text))); } catch (Exception ex) { HouseholdDefinition householdDefinition = hs.getHouseholdDefinitionByUuid(text); setValue(householdDefinition); if (householdDefinition == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("Household Program not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:org.xacml4j.spring.pip.PolicyInformationPointDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder pip = BeanDefinitionBuilder .rootBeanDefinition(PolicyInformationPointFactoryBean.class); pip.addConstructorArgValue(element.getAttribute("id")); String resolvers = element.getAttribute("resolvers"); if (StringUtils.hasText(resolvers)) { pip.addPropertyReference("resolvers", resolvers); }/*from w w w.ja v a2s . com*/ String cache = element.getAttribute("cache"); if (StringUtils.hasText(cache)) { pip.addPropertyReference("cache", cache); } return pip.getBeanDefinition(); }
From source file:org.springbyexample.contact.web.context.ContactApplicationContextInitializer.java
@Override public void initialize(ConfigurableApplicationContext applicationContext) { String springProfilesActive = System.getProperty(SPRING_PROFILES_ACTIVE_PROPERTY); if (StringUtils.hasText(springProfilesActive)) { logger.info("Using set spring profiles. profiles='{}'", springProfilesActive); } else {/*w w w . j a v a 2 s. com*/ applicationContext.getEnvironment().setActiveProfiles(DEFAULT_ACTIVE_PROFILES); logger.info("Setting default spring profiles. profiles='{}'", DEFAULT_ACTIVE_PROFILES); } }
From source file:org.springdata.ehcache.config.xml.TemplateParser.java
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) throws BeanDefinitionStoreException { String id = super.resolveId(element, definition, parserContext); return StringUtils.hasText(id) ? id : ConfigConstants.TEMPLATE_DEFAULT_ID; }
From source file:com.consol.citrus.simulator.servlet.StaticResourceServlet.java
private String getTemplateName(String requestURI) { if (StringUtils.hasText(requestURI) && requestURI.endsWith("/")) { return requestURI.substring(0, requestURI.length() - 1); } else {//from w w w .jav a2 s . c om return requestURI; } }