Java Code Examples for org.apache.commons.lang3.StringUtils#isWhitespace()
The following examples show how to use
org.apache.commons.lang3.StringUtils#isWhitespace() .
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: FilterPreserveLineLoader.java From recheck with GNU Affero General Public License v3.0 | 6 votes |
private boolean canLoad( final String line ) { final boolean comment = line.startsWith( FilterPreserveLine.COMMENT ); if ( comment ) { return true; } final boolean onlyWhiteSpace = StringUtils.isWhitespace( line ); if ( onlyWhiteSpace ) { return true; } final boolean leadingWhitespace = Character.isWhitespace( line.charAt( 0 ) ); if ( leadingWhitespace ) { log.warn( "Please remove leading whitespace from the following line:\n{}", line ); return true; } return false; }
Example 2
Source File: Http2JMeter.java From jsflight with Apache License 2.0 | 6 votes |
public LinkedHashMap<String, Integer> getRequestsByUsers(List<RestoredRequest> requests) { LinkedHashMap<String, Integer> result = new LinkedHashMap<>(); for (RestoredRequest request : requests) { String uuid = getUserUuidByRequest(request); String sessionId = getUserSessionId(request); if (!StringUtils.isWhitespace(uuid)) { Integer filtered = result.get(uuid); if (filtered == null) { filtered = new Integer(0); result.put(uuid, filtered); } else { result.put(uuid, filtered + 1); } } } return result; }
Example 3
Source File: TurnContextImpl.java From botbuilder-java with MIT License | 5 votes |
/** * Deletes an existing activity. * * @param activityId The ID of the activity to delete. * @return A task that represents the work queued to execute. */ public CompletableFuture<Void> deleteActivity(String activityId) { if (StringUtils.isWhitespace(activityId) || StringUtils.isEmpty(activityId)) { throw new IllegalArgumentException("activityId"); } ConversationReference cr = activity.getConversationReference(); cr.setActivityId(activityId); Supplier<CompletableFuture<Void>> actuallyDeleteStuff = () -> getAdapter() .deleteActivity(this, cr); return deleteActivityInternal(cr, onDeleteActivity.iterator(), actuallyDeleteStuff); }
Example 4
Source File: BaseAuthorizationTokenProvider.java From azure-cosmosdb-java with MIT License | 5 votes |
private String generateMessagePayload(String verb, String resourceId, String resourceType, Map<String, String> headers) { String xDate = headers.get(HttpConstants.HttpHeaders.X_DATE); String date = headers.get(HttpConstants.HttpHeaders.HTTP_DATE); // At-least one of date header should present // https://docs.microsoft.com/en-us/rest/api/documentdb/access-control-on-documentdb-resources if (StringUtils.isEmpty(xDate) && (StringUtils.isEmpty(date) || StringUtils.isWhitespace(date))) { headers.put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); xDate = Utils.nowAsRFC1123(); } // for name based, it is case sensitive, we won't use the lower case if (!PathsHelper.isNameBased(resourceId)) { resourceId = resourceId.toLowerCase(); } String xDateOrDateOrEmpty = StringUtils.isEmpty(xDate) ? date.toLowerCase() : ""; int len = verb.length() + resourceType.length() + resourceId.length() + xDate.length() + xDateOrDateOrEmpty.length() + 5; StringBuilder payload = new StringBuilder(len); payload.append(verb.toLowerCase()) .append('\n') .append(resourceType.toLowerCase()) .append('\n') .append(resourceId) .append('\n') .append(xDate.toLowerCase()) .append('\n') .append(xDateOrDateOrEmpty) .append('\n'); return payload.toString(); }
Example 5
Source File: HostParser.java From cyberduck with GNU General Public License v3.0 | 5 votes |
static void parseRootless(final StringReader reader, final Host host) throws HostParserException { // This is not RFC-compliant. // * Rootless-path must not include authentication information. final boolean userInfoResult = parseUserInfo(reader, host); if(host.getProtocol().isHostnameConfigurable() && StringUtils.isWhitespace(host.getHostname())) { // This is not RFC-compliant. // We assume for hostconfigurable-empty-hostnames a hostname on first path segment parseHostname(reader, host); } parsePath(reader, host, false); }
Example 6
Source File: SqlFileParser.java From samza with Apache License 2.0 | 5 votes |
public static List<String> parseSqlFile(String fileName) { Validate.notEmpty(fileName, "fileName cannot be empty."); List<String> sqlLines; try { sqlLines = Files.lines(Paths.get(fileName)).collect(Collectors.toList()); } catch (IOException e) { String msg = String.format("Unable to parse the sql file %s", fileName); LOG.error(msg, e); throw new SamzaException(msg, e); } List<String> sqlStmts = new ArrayList<>(); String lastStatement = ""; for (String sqlLine : sqlLines) { String sql = sqlLine.trim(); if (sql.toLowerCase().startsWith(INSERT_CMD)) { if (StringUtils.isNotEmpty(lastStatement)) { sqlStmts.add(lastStatement); } lastStatement = sql; } else if (StringUtils.isNotBlank(sql) && !sql.startsWith(SQL_COMMENT_PREFIX)) { lastStatement = String.format("%s %s", lastStatement, sql); } } if (!StringUtils.isWhitespace(lastStatement)) { sqlStmts.add(lastStatement); } return sqlStmts; }
Example 7
Source File: Strings.java From azure-cosmosdb-java with MIT License | 4 votes |
public static boolean isNullOrWhiteSpace(String str) { return StringUtils.isEmpty(str) || StringUtils.isWhitespace(str); }
Example 8
Source File: CORSFilter.java From para with Apache License 2.0 | 4 votes |
/** * Determines the request type. * @param request req * @return CORS request type */ public CORSRequestType checkRequestType(final HttpServletRequest request) { CORSRequestType requestType = CORSRequestType.INVALID_CORS; if (request == null) { throw new IllegalArgumentException( "HttpServletRequest object is null"); } String originHeader = request.getHeader(REQUEST_HEADER_ORIGIN); // Section 6.1.1 and Section 6.2.1 if (originHeader != null) { if (originHeader.isEmpty()) { requestType = CORSRequestType.INVALID_CORS; } else if (!isValidOrigin(originHeader)) { requestType = CORSRequestType.INVALID_CORS; } else { String method = StringUtils.trimToEmpty(request.getMethod()); if (HTTP_METHODS.contains(method)) { if ("OPTIONS".equals(method)) { String accessControlRequestMethodHeader = request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD); if (StringUtils.isNotBlank(accessControlRequestMethodHeader)) { requestType = CORSRequestType.PRE_FLIGHT; } else if (StringUtils.isWhitespace(accessControlRequestMethodHeader)) { requestType = CORSRequestType.INVALID_CORS; } else { requestType = CORSRequestType.ACTUAL; } } else if ("GET".equals(method) || "HEAD".equals(method)) { requestType = CORSRequestType.SIMPLE; } else if ("POST".equals(method)) { String contentType = request.getContentType(); if (contentType != null) { contentType = contentType.toLowerCase().trim(); if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES .contains(contentType)) { requestType = CORSRequestType.SIMPLE; } else { requestType = CORSRequestType.ACTUAL; } } } else if (COMPLEX_HTTP_METHODS.contains(method)) { requestType = CORSRequestType.ACTUAL; } } } } else { requestType = CORSRequestType.NOT_CORS; } return requestType; }
Example 9
Source File: RecordStructureManager.java From baleen with Apache License 2.0 | 2 votes |
/** * Check if the annotation contains anything * * @param structure the structure * @return true if empty or white space */ private boolean isWhitespace(Structure structure) { String coveredText = structure.getCoveredText(); return StringUtils.isEmpty(coveredText) || StringUtils.isWhitespace(coveredText); }