/** * Determines if this {@code String} contains the sequence of characters in the {@code CharSequence} passed. * * @param cs the character sequence to search for. * @return {@code true} if the sequence of characters are contained in this string, otherwise {@code false}. */ public boolean contains(CharSequence cs) { return indexOf(cs) >= 0; }
/** * Searches in this string for the first index of the specified string. The search for the string starts at the * beginning and moves towards the end of this string. * * @param string the string to find. * @return the index of the first character of the specified string in this string, -1 if the specified string is * not a substring. * @throws NullPointerException if {@code string} is {@code null}. */ public int indexOf(CharSequence string) { return indexOf(string, 0); }
/** * Searches in this string for the first index of the specified string. The search for the string starts at the * beginning and moves towards the end of this string. * * @param string the string to find. * @return the index of the first character of the specified string in this string, -1 if the specified string is * not a substring. * @throws NullPointerException if {@code string} is {@code null}. */ public int indexOf(CharSequence string) { return indexOf(string, 0); }
/** * Determines if this {@code String} contains the sequence of characters in the {@code CharSequence} passed. * * @param cs the character sequence to search for. * @return {@code true} if the sequence of characters are contained in this string, otherwise {@code false}. */ public boolean contains(CharSequence cs) { return indexOf(cs) >= 0; }
/** * Searches in this string for the first index of the specified string. The search for the string starts at the * beginning and moves towards the end of this string. * * @param string the string to find. * @return the index of the first character of the specified string in this string, -1 if the specified string is * not a substring. * @throws NullPointerException if {@code string} is {@code null}. */ public int indexOf(CharSequence string) { return indexOf(string, 0); }
/** * Determines if this {@code String} contains the sequence of characters in the {@code CharSequence} passed. * * @param cs the character sequence to search for. * @return {@code true} if the sequence of characters are contained in this string, otherwise {@code false}. */ public boolean contains(CharSequence cs) { return indexOf(cs) >= 0; }
/** * <p>Finds the first index in the {@code CharSequence} that matches the * specified character.</p> * * @param cs the {@code CharSequence} to be processed, not null * @param searchChar the char to be searched for * @param start the start index, negative starts at the string start * @return the index where the search char was found, * -1 if char {@code searchChar} is not found or {@code cs == null} */ //----------------------------------------------------------------------- public static int indexOf(final CharSequence cs, final char searchChar, int start) { if (cs instanceof String) { return ((String) cs).indexOf(searchChar, start); } else if (cs instanceof AsciiString) { return ((AsciiString) cs).indexOf(searchChar, start); } if (cs == null) { return INDEX_NOT_FOUND; } final int sz = cs.length(); for (int i = start < 0 ? 0 : start; i < sz; i++) { if (cs.charAt(i) == searchChar) { return i; } } return INDEX_NOT_FOUND; }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address(AsciiString ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = ip.indexOf('.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address0(CharSequence ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = indexOf(ip, '.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
/** * <p>Finds the first index in the {@code CharSequence} that matches the * specified character.</p> * * @param cs the {@code CharSequence} to be processed, not null * @param searchChar the char to be searched for * @param start the start index, negative starts at the string start * @return the index where the search char was found, * -1 if char {@code searchChar} is not found or {@code cs == null} */ //----------------------------------------------------------------------- public static int indexOf(final CharSequence cs, final char searchChar, int start) { if (cs instanceof String) { return ((String) cs).indexOf(searchChar, start); } else if (cs instanceof AsciiString) { return ((AsciiString) cs).indexOf(searchChar, start); } if (cs == null) { return INDEX_NOT_FOUND; } final int sz = cs.length(); for (int i = start < 0 ? 0 : start; i < sz; i++) { if (cs.charAt(i) == searchChar) { return i; } } return INDEX_NOT_FOUND; }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address(AsciiString ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = ip.indexOf('.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address0(CharSequence ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = indexOf(ip, '.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
/** * <p>Finds the first index in the {@code CharSequence} that matches the * specified character.</p> * * @param cs the {@code CharSequence} to be processed, not null * @param searchChar the char to be searched for * @param start the start index, negative starts at the string start * @return the index where the search char was found, * -1 if char {@code searchChar} is not found or {@code cs == null} */ //----------------------------------------------------------------------- public static int indexOf(final CharSequence cs, final char searchChar, int start) { if (cs instanceof String) { return ((String) cs).indexOf(searchChar, start); } else if (cs instanceof AsciiString) { return ((AsciiString) cs).indexOf(searchChar, start); } if (cs == null) { return INDEX_NOT_FOUND; } final int sz = cs.length(); for (int i = start < 0 ? 0 : start; i < sz; i++) { if (cs.charAt(i) == searchChar) { return i; } } return INDEX_NOT_FOUND; }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address0(CharSequence ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = indexOf(ip, '.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address(AsciiString ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = ip.indexOf('.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
int pos = 0; while (pos < len) { int idx = AsciiString.indexOf(value, ',', pos); int next; if (idx == -1) {
int ipv4End = indexOf(ip, '%', ipv4Start + 7); if (ipv4End < 0) { ipv4End = end;
int end; if (ignoreCase) { if ((end = AsciiString.indexOf(rawNext, ',', begin)) == -1) { if (contentEqualsIgnoreCase(trim(rawNext), expected)) { return true; } while ((end = AsciiString.indexOf(rawNext, ',', begin)) != -1); if ((end = AsciiString.indexOf(rawNext, ',', begin)) == -1) { if (contentEquals(trim(rawNext), expected)) { return true; } while ((end = AsciiString.indexOf(rawNext, ',', begin)) != -1);
/** * Filter the {@link HttpHeaderNames#TE} header according to the * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>. * @param entry An entry whose name is {@link HttpHeaderNames#TE}. * @param out the resulting HTTP/2 headers. */ private static void toHttp2HeadersFilterTE(Entry<CharSequence, CharSequence> entry, Http2Headers out) { if (indexOf(entry.getValue(), ',', 0) == -1) { if (contentEqualsIgnoreCase(trim(entry.getValue()), TRAILERS)) { out.add(TE, TRAILERS); } } else { List<CharSequence> teValues = unescapeCsvFields(entry.getValue()); for (CharSequence teValue : teValues) { if (contentEqualsIgnoreCase(trim(teValue), TRAILERS)) { out.add(TE, TRAILERS); break; } } } }
/** * Filter the {@link HttpHeaderNames#TE} header according to the * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>. * @param entry An entry whose name is {@link HttpHeaderNames#TE}. * @param out the resulting HTTP/2 headers. */ private static void toHttp2HeadersFilterTE(Entry<CharSequence, CharSequence> entry, HttpHeaders out) { if (AsciiString.indexOf(entry.getValue(), ',', 0) == -1) { if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(entry.getValue()), HttpHeaderValues.TRAILERS)) { out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString()); } } else { final List<CharSequence> teValues = StringUtil.unescapeCsvFields(entry.getValue()); for (CharSequence teValue : teValues) { if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(teValue), HttpHeaderValues.TRAILERS)) { out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString()); break; } } } }