Java Code Examples for org.thymeleaf.util.StringUtils#isEmptyOrWhitespace()

The following examples show how to use org.thymeleaf.util.StringUtils#isEmptyOrWhitespace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TdsExtensibleTemplateResolver.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected String computeResourceName(final IEngineConfiguration configuration, final String ownerTemplate,
    final String template, final String prefix, final String suffix, final Map<String, String> templateAliases,
    final Map<String, Object> templateResolutionAttributes) {

  Validate.notNull(template, "Template name cannot be null");

  // Don't bother computing resource name if template is not extensible
  if (!template.startsWith(EXT_FRAG_PREFIX))
    return template;

  String resourceName = template.substring(PREFIX_LENGTH);
  if (!StringUtils.isEmptyOrWhitespace(prefix))
    resourceName = prefix + resourceName;
  if (!StringUtils.isEmptyOrWhitespace(suffix))
    resourceName = resourceName + suffix;

  TdsContext tdsContext = (TdsContext) applicationContext.getBean("TdsContext");
  resourceName = tdsContext.getThreddsDirectory() + resourceName;


  return resourceName;
}
 
Example 2
Source File: WallRideResourceTemplateResource.java    From wallride with Apache License 2.0 6 votes vote down vote up
public Reader reader() throws IOException {
	// Will never return null, but an IOException if not found
	try {
		final InputStream inputStream = this.resource.getInputStream();
		if (!StringUtils.isEmptyOrWhitespace(this.characterEncoding)) {
			return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream), this.characterEncoding));
		}

		return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream)));
	} catch (AmazonS3Exception e) {
		if (e.getStatusCode() == 404) {
			throw new IOException(e);
		}
		throw e;
	}
}
 
Example 3
Source File: ContactInfoValidator.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void initialize(final ContactInfo contactInfo) {
    if (StringUtils.isEmptyOrWhitespace(expressionType)) {
        LOG.error("Contact info type missing!");
    } else {
        pattern = expressionRepository.findById(expressionType).map(ContactInfoExpression::getPattern).orElse("");
    }
}
 
Example 4
Source File: ContactInfoValidator.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    if (!StringUtils.isEmptyOrWhitespace(pattern)) {
        return Pattern.matches(pattern, value);
    }
    LOG.error("Contact info pattern missing!");
    return false;
}