Java Code Examples for org.springframework.util.StringUtils#containsWhitespace()
The following examples show how to use
org.springframework.util.StringUtils#containsWhitespace() .
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: SignupInterceptor.java From Building-Web-Apps-with-Spring-5-and-Angular with MIT License | 5 votes |
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String emailAddress = request.getParameter("email"); String password = request.getParameter("password"); if(StringUtils.isEmpty(emailAddress) || StringUtils.containsWhitespace(emailAddress) || StringUtils.isEmpty(password) || StringUtils.containsWhitespace(password)) { throw new Exception("Invalid Email Address or Password. Please try again."); } return true; }
Example 2
Source File: ConfigService.java From diamond with Apache License 2.0 | 5 votes |
private void checkParameter(String dataId, String group, String content) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new ConfigServiceException("无效的dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new ConfigServiceException("无效的group"); if (!StringUtils.hasLength(content)) throw new ConfigServiceException("无效的content"); }
Example 3
Source File: ConfigService.java From diamond with Apache License 2.0 | 5 votes |
private void checkParameter(String dataId, String group, String content) { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new ConfigServiceException("无效的dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new ConfigServiceException("无效的group"); if (!StringUtils.hasLength(content)) throw new ConfigServiceException("无效的content"); }
Example 4
Source File: TransactionAttributeEditor.java From spring-analysis-note with MIT License | 4 votes |
/** * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2. * Null or the empty string means that the method is non transactional. */ @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasLength(text)) { // tokenize it with "," String[] tokens = StringUtils.commaDelimitedListToStringArray(text); RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute(); for (String token : tokens) { // Trim leading and trailing whitespace. String trimmedToken = StringUtils.trimWhitespace(token.trim()); // Check whether token contains illegal whitespace within text. if (StringUtils.containsWhitespace(trimmedToken)) { throw new IllegalArgumentException( "Transaction attribute token contains illegal whitespace: [" + trimmedToken + "]"); } // Check token type. if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) { attr.setPropagationBehaviorName(trimmedToken); } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) { attr.setIsolationLevelName(trimmedToken); } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) { String value = trimmedToken.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length()); attr.setTimeout(Integer.parseInt(value)); } else if (trimmedToken.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) { attr.setReadOnly(true); } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) { attr.getRollbackRules().add(new NoRollbackRuleAttribute(trimmedToken.substring(1))); } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) { attr.getRollbackRules().add(new RollbackRuleAttribute(trimmedToken.substring(1))); } else { throw new IllegalArgumentException("Invalid transaction attribute token: [" + trimmedToken + "]"); } } setValue(attr); } else { setValue(null); } }
Example 5
Source File: TransactionAttributeEditor.java From java-technology-stack with MIT License | 4 votes |
/** * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2. * Null or the empty string means that the method is non transactional. * @see java.beans.PropertyEditor#setAsText(java.lang.String) */ @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasLength(text)) { // tokenize it with "," String[] tokens = StringUtils.commaDelimitedListToStringArray(text); RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute(); for (int i = 0; i < tokens.length; i++) { // Trim leading and trailing whitespace. String token = StringUtils.trimWhitespace(tokens[i].trim()); // Check whether token contains illegal whitespace within text. if (StringUtils.containsWhitespace(token)) { throw new IllegalArgumentException( "Transaction attribute token contains illegal whitespace: [" + token + "]"); } // Check token type. if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) { attr.setPropagationBehaviorName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) { attr.setIsolationLevelName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) { String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length()); attr.setTimeout(Integer.parseInt(value)); } else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) { attr.setReadOnly(true); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) { attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1))); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) { attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1))); } else { throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]"); } } setValue(attr); } else { setValue(null); } }
Example 6
Source File: TransactionAttributeEditor.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2. * Null or the empty string means that the method is non transactional. * @see java.beans.PropertyEditor#setAsText(java.lang.String) */ @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasLength(text)) { // tokenize it with "," String[] tokens = StringUtils.commaDelimitedListToStringArray(text); RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute(); for (int i = 0; i < tokens.length; i++) { // Trim leading and trailing whitespace. String token = StringUtils.trimWhitespace(tokens[i].trim()); // Check whether token contains illegal whitespace within text. if (StringUtils.containsWhitespace(token)) { throw new IllegalArgumentException( "Transaction attribute token contains illegal whitespace: [" + token + "]"); } // Check token type. if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) { attr.setPropagationBehaviorName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) { attr.setIsolationLevelName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) { String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length()); attr.setTimeout(Integer.parseInt(value)); } else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) { attr.setReadOnly(true); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) { attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1))); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) { attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1))); } else { throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]"); } } setValue(attr); } else { setValue(null); } }
Example 7
Source File: TransactionAttributeEditor.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2. * Null or the empty string means that the method is non transactional. * @see java.beans.PropertyEditor#setAsText(java.lang.String) */ @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasLength(text)) { // tokenize it with "," String[] tokens = StringUtils.commaDelimitedListToStringArray(text); RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute(); for (int i = 0; i < tokens.length; i++) { // Trim leading and trailing whitespace. String token = StringUtils.trimWhitespace(tokens[i].trim()); // Check whether token contains illegal whitespace within text. if (StringUtils.containsWhitespace(token)) { throw new IllegalArgumentException( "Transaction attribute token contains illegal whitespace: [" + token + "]"); } // Check token type. if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) { attr.setPropagationBehaviorName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) { attr.setIsolationLevelName(token); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) { String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length()); attr.setTimeout(Integer.parseInt(value)); } else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) { attr.setReadOnly(true); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) { attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1))); } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) { attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1))); } else { throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]"); } } setValue(attr); } else { setValue(null); } }
Example 8
Source File: Mention.java From baleen with Apache License 2.0 | 4 votes |
/** Returns true is the covered text contains no whitespace and is entirely upper case */ public boolean isAcronym() { return !StringUtils.containsWhitespace(getText()) && org.apache.commons.lang3.StringUtils.isAllUpperCase(getText()); }