public static void notEmpty(final String object, final String message) { if (StringUtils.isEmptyOrWhitespace(object)) { throw new IllegalArgumentException(message); } }
public Boolean isEmpty(final Object target) { return Boolean.valueOf(target == null || StringUtils.isEmptyOrWhitespace(target.toString())); }
public Reader reader() throws IOException { final InputStream inputStream = new FileInputStream(this.file); if (!StringUtils.isEmptyOrWhitespace(this.characterEncoding)) { return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream), this.characterEncoding)); } return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream))); }
public Reader reader() throws IOException { final InputStream inputStream = this.servletContext.getResourceAsStream(this.path); if (inputStream == null) { throw new FileNotFoundException(String.format("ServletContext resource \"%s\" does not exist", this.path)); } if (!StringUtils.isEmptyOrWhitespace(this.characterEncoding)) { return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream), this.characterEncoding)); } return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream))); }
public Reader reader() throws IOException { final InputStream inputStream = inputStream(); if (!StringUtils.isEmptyOrWhitespace(this.characterEncoding)) { return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream), this.characterEncoding)); } return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream))); }
public static FragmentExpression parseFragmentExpression(final String input) { final Matcher matcher = FRAGMENT_PATTERN.matcher(input); if (!matcher.matches()) { return null; } final String expression = matcher.group(1); if (StringUtils.isEmptyOrWhitespace(expression)) { return EMPTY_FRAGMENT_EXPRESSION; } return parseFragmentExpressionContent(expression.trim()); }
private static List<String> computeMessageResourceNamesFromBase( final String resourceBaseName, final Locale locale) { final List<String> resourceNames = new ArrayList<String>(5); if (StringUtils.isEmptyOrWhitespace(locale.getLanguage())) { throw new TemplateProcessingException( "Locale \"" + locale.toString() + "\" " + "cannot be used as it does not specify a language."); } resourceNames.add(resourceBaseName + PROPERTIES_FILE_EXTENSION); resourceNames.add(resourceBaseName + "_" + locale.getLanguage() + PROPERTIES_FILE_EXTENSION); if (!StringUtils.isEmptyOrWhitespace(locale.getCountry())) { resourceNames.add( resourceBaseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + PROPERTIES_FILE_EXTENSION); } if (!StringUtils.isEmptyOrWhitespace(locale.getVariant())) { resourceNames.add( resourceBaseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + "-" + locale.getVariant() + PROPERTIES_FILE_EXTENSION); } return resourceNames; }
public Reader reader() throws IOException { final InputStream inputStream; if (this.optionalClassLoader != null) { inputStream = this.optionalClassLoader.getResourceAsStream(this.path); } else { inputStream = ClassLoaderUtils.findResourceAsStream(this.path); } if (inputStream == null) { throw new FileNotFoundException(String.format("ClassLoader resource \"%s\" could not be resolved", this.path)); } if (!StringUtils.isEmptyOrWhitespace(this.characterEncoding)) { return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream), this.characterEncoding)); } return new BufferedReader(new InputStreamReader(new BufferedInputStream(inputStream))); }
if (StringUtils.isEmptyOrWhitespace(targetString)) { if (defaultValue == null) { return "null";
static NumberTokenExpression parseNumberTokenExpression(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } boolean decimalFound = false; final int inputLen = input.length(); for (int i = 0; i < inputLen; i++) { final char c = input.charAt(i); if (Character.isDigit(c)) { continue; } else if (c == DECIMAL_POINT) { if (decimalFound) { return null; } decimalFound = true; continue; } else { return null; } } try { return new NumberTokenExpression(input); } catch (final NumberFormatException e) { // It seems after all it wasn't valid as a number return null; } }
static AssignationSequence internalParseAssignationSequence(final String input, final boolean allowParametersWithoutValue) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final ExpressionParsingState decomposition = ExpressionParsingUtil.decompose(input); if (decomposition == null) { return null; } return composeSequence(decomposition, 0, allowParametersWithoutValue); }
static ExpressionSequence internalParseExpressionSequence(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final ExpressionParsingState decomposition = ExpressionParsingUtil.decompose(input); if (decomposition == null) { return null; } return composeSequence(decomposition, 0); }
static Each internalParseEach(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final ExpressionParsingState decomposition = ExpressionParsingUtil.decompose(input); if (decomposition == null) { return null; } return composeEach(decomposition, 0); }
if (StringUtils.isEmptyOrWhitespace(pattern)) { dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); } else {
private static Expression parseDefaultAsLiteral(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final Expression expr = Expression.parse(input); if (expr == null) { return Expression.parse(TextLiteralExpression.wrapStringIntoLiteral(input)); } return expr; }
private static Expression parseBaseDefaultAsLiteral(final String base) { if (StringUtils.isEmptyOrWhitespace(base)) { return null; } final Expression expr = Expression.parse(base); if (expr == null) { return Expression.parse(TextLiteralExpression.wrapStringIntoLiteral(base)); } return expr; }
private static Expression parseDefaultAsLiteral(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final Expression expr = Expression.parse(input); if (expr == null) { return Expression.parse(TextLiteralExpression.wrapStringIntoLiteral(input)); } return expr; }
if (StringUtils.isEmptyOrWhitespace(input)) { return null;
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { final Each each = EachUtils.parseEach(context, attributeValue); final IStandardExpression iterVarExpr = each.getIterVar(); final Object iterVarValue = iterVarExpr.execute(context); final IStandardExpression statusVarExpr = each.getStatusVar(); final Object statusVarValue; if (statusVarExpr != null) { statusVarValue = statusVarExpr.execute(context); } else { statusVarValue = null; // Will provoke the default behaviour: iterVarValue + 'Stat' } final IStandardExpression iterableExpr = each.getIterable(); final Object iteratedValue = iterableExpr.execute(context); final String iterVarName = (iterVarValue == null? null : iterVarValue.toString()); if (StringUtils.isEmptyOrWhitespace(iterVarName)) { throw new TemplateProcessingException( "Iteration variable name expression evaluated as null: \"" + iterVarExpr + "\""); } final String statusVarName = (statusVarValue == null? null : statusVarValue.toString()); if (statusVarExpr != null && StringUtils.isEmptyOrWhitespace(statusVarName)) { throw new TemplateProcessingException( "Status variable name expression evaluated as null or empty: \"" + statusVarExpr + "\""); } structureHandler.iterateElement(iterVarName, statusVarName, iteratedValue); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { if (StringUtils.isEmptyOrWhitespace(attributeValue)) { return; } final ExpressionSequence expressionSequence = ExpressionSequenceUtils.parseExpressionSequence(context, attributeValue); final List<IStandardExpression> expressions = expressionSequence.getExpressions(); for (final IStandardExpression expression : expressions) { final Object expressionResult = expression.execute(context); final boolean expressionBooleanResult = EvaluationUtils.evaluateAsBoolean(expressionResult); if (!expressionBooleanResult) { throw new TemplateAssertionException( expression.getStringRepresentation(), tag.getTemplateName(), tag.getAttribute(attributeName).getLine(), tag.getAttribute(attributeName).getCol()); } } }