/** * Determine whether a parameter name ends at the current position, * that is, whether the given character qualifies as a separator. */ private static boolean isParameterSeparator(char c) { return (c < 128 && separatorIndex[c]) || Character.isWhitespace(c); }
@Override public TextValue trim() { if ( Character.isWhitespace( value ) ) { return StringValue.EMPTY; } else { return this; } }
private static boolean containsText(CharSequence str) { int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
private static boolean isSpace(final String s) { if (s == null) return true; for (int i = 0, len = s.length(); i < len; ++i) { if (!Character.isWhitespace(s.charAt(i))) { return false; } } return true; } }
private static void loadSpace() { for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++) { if (Character.isWhitespace(i) || Character.isSpaceChar(i)) { CONVERT[i] = ' '; } } }
private static int findSpaceBefore( String description, int position ) { while ( !Character.isWhitespace( description.charAt( position ) ) ) { position--; } return position + 1; }
/** * Find the index of the first non-white space character in {@code s} starting at {@code offset}. * * @param seq The string to search. * @param offset The offset to start searching at. * @return the index of the first non-white space character or <{@code 0} if none was found. */ public static int indexOfNonWhiteSpace(CharSequence seq, int offset) { for (; offset < seq.length(); ++offset) { if (!Character.isWhitespace(seq.charAt(offset))) { return offset; } } return -1; }
private static int findLastBlank(String buffer) { for (int i = buffer.length() - 1; i >= 0; i--) { if (Character.isWhitespace(buffer.charAt(i))) { return i; } } return -1; }
public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (Character.isWhitespace(cs.charAt(i)) == false) { return false; } } return true; }
/** * Trim leading and trailing whitespace from the given {@code String}. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimWhitespace(String str) { if (!hasLength(str)) { return str; } int beginIndex = 0; int endIndex = str.length() - 1; while (beginIndex <= endIndex && Character.isWhitespace(str.charAt(beginIndex))) { beginIndex++; } while (endIndex > beginIndex && Character.isWhitespace(str.charAt(endIndex))) { endIndex--; } return str.substring(beginIndex, endIndex + 1); }
private static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; }
/** * Trim leading whitespace from the given {@code String}. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimLeadingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) { sb.deleteCharAt(0); } return sb.toString(); }
public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; }
/** * Trim trailing whitespace from the given {@code String}. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimTrailingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
/** * Check whether the given {@code CharSequence} contains any whitespace characters. * @param str the {@code CharSequence} to check (may be {@code null}) * @return {@code true} if the {@code CharSequence} is not empty and * contains at least 1 whitespace character * @see Character#isWhitespace */ public static boolean containsWhitespace(@Nullable CharSequence str) { if (!hasLength(str)) { return false; } int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
/** * Trim <i>all</i> whitespace from the given {@code String}: * leading, trailing, and in between characters. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimAllWhitespace(String str) { if (!hasLength(str)) { return str; } int len = str.length(); StringBuilder sb = new StringBuilder(str.length()); for (int i = 0; i < len; i++) { char c = str.charAt(i); if (!Character.isWhitespace(c)) { sb.append(c); } } return sb.toString(); }
@Override public void parse(String content, SortedSet<ContentChunkInfo> result) { int position = 0; while (true) { position = content.indexOf(getKeyword(), position); if (position == -1) { return; } position += getKeyword().length(); while (Character.isWhitespace(content.charAt(position))) { position++; } if (content.charAt(position) == '\'') { position = extractLink(position, '\'', content, result); } else if (content.charAt(position) == '"') { position = extractLink(position, '"', content, result); } else { position = extractUnquotedLink(position, content, result); } } }
@Override public void parse(String content, SortedSet<ContentChunkInfo> result) { int position = 0; while (true) { position = content.indexOf(getKeyword(), position); if (position == -1) { return; } position += getKeyword().length(); while (Character.isWhitespace(content.charAt(position))) { position++; } if (content.charAt(position) == '\'') { position = extractLink(position, "'", content, result); } else if (content.charAt(position) == '"') { position = extractLink(position, "\"", content, result); } else { position = extractLink(position, content, result); } } }
/** * Returns true if the body in question probably contains human readable text. Uses a small sample * of code points to detect unicode control characters commonly used in binary file signatures. */ static boolean isPlaintext(Buffer buffer) { try { Buffer prefix = new Buffer(); long byteCount = buffer.size() < 64 ? buffer.size() : 64; buffer.copyTo(prefix, 0, byteCount); for (int i = 0; i < 16; i++) { if (prefix.exhausted()) { break; } int codePoint = prefix.readUtf8CodePoint(); if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) { return false; } } return true; } catch (EOFException e) { return false; // Truncated UTF-8 sequence. } }
public static int getWrapIndex (Array<Glyph> glyphs, int start) { int i = start - 1; for (; i >= 1; i--) { int startChar = glyphs.get(i).id; if (!SimplifiedChinese.legalAtStart(startChar)) continue; int endChar = glyphs.get(i - 1).id; if (!SimplifiedChinese.legalAtEnd(endChar)) continue; // Don't wrap between ASCII chars. if (startChar < 127 && endChar < 127 && !Character.isWhitespace(startChar)) continue; return i; } return start; }