Tabnine Logo
String.regionMatches
Code IndexAdd Tabnine to your IDE (free)

How to use
regionMatches
method
in
java.lang.String

Best Java code snippets using java.lang.String.regionMatches (Showing top 20 results out of 7,695)

origin: netty/netty

/**
 * Checks if two strings have the same suffix of specified length
 *
 * @param s   string
 * @param p   string
 * @param len length of the common suffix
 * @return true if both s and p are not null and both have the same suffix. Otherwise - false
 */
public static boolean commonSuffixOfLength(String s, String p, int len) {
  return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len);
}
origin: commons-io/commons-io

/**
 * Checks if one string starts with another using the case-sensitivity rule.
 * <p>
 * This method mimics {@link String#startsWith(String)} but takes case-sensitivity
 * into account.
 *
 * @param str  the string to check, not null
 * @param start  the start to compare against, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkStartsWith(final String str, final String start) {
  return str.regionMatches(!sensitive, 0, start, 0, start.length());
}
origin: spring-projects/spring-framework

/**
 * Test if the given {@code String} starts with the specified prefix,
 * ignoring upper/lower case.
 * @param str the {@code String} to check
 * @param prefix the prefix to look for
 * @see java.lang.String#startsWith
 */
public static boolean startsWithIgnoreCase(@Nullable String str, @Nullable String prefix) {
  return (str != null && prefix != null && str.length() >= prefix.length() &&
      str.regionMatches(true, 0, prefix, 0, prefix.length()));
}
origin: square/okhttp

boolean matches(String hostname) {
 if (pattern.startsWith(WILDCARD)) {
  int firstDot = hostname.indexOf('.');
  return (hostname.length() - firstDot - 1) == canonicalHostname.length()
    && hostname.regionMatches(false, firstDot + 1, canonicalHostname, 0,
    canonicalHostname.length());
 }
 return hostname.equals(canonicalHostname);
}
origin: commons-io/commons-io

/**
 * Checks if one string contains another at a specific index using the case-sensitivity rule.
 * <p>
 * This method mimics parts of {@link String#regionMatches(boolean, int, String, int, int)}
 * but takes case-sensitivity into account.
 *
 * @param str  the string to check, not null
 * @param strStartIndex  the index to start at in str
 * @param search  the start to search for, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkRegionMatches(final String str, final int strStartIndex, final String search) {
  return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length());
}
origin: spring-projects/spring-framework

/**
 * Test if the given {@code String} ends with the specified suffix,
 * ignoring upper/lower case.
 * @param str the {@code String} to check
 * @param suffix the suffix to look for
 * @see java.lang.String#endsWith
 */
public static boolean endsWithIgnoreCase(@Nullable String str, @Nullable String suffix) {
  return (str != null && suffix != null && str.length() >= suffix.length() &&
      str.regionMatches(true, str.length() - suffix.length(), suffix, 0, suffix.length()));
}
origin: square/dagger

/** Returns true if {@code string.substring(offset).startsWith(substring)}. */
private static boolean substringStartsWith(String string, int offset, String substring) {
 return string.regionMatches(offset, substring, 0, substring.length());
}
origin: prestodb/presto

  public int parseInto(
      ReadWritablePeriod period, String periodStr,
      int position, Locale locale) {
    if (periodStr.regionMatches(true, position, iText, 0, iText.length())) {
      return position + iText.length();
    }
    return ~position;
  }
}
origin: commons-io/commons-io

/**
 * Checks if one string ends with another using the case-sensitivity rule.
 * <p>
 * This method mimics {@link String#endsWith} but takes case-sensitivity
 * into account.
 *
 * @param str  the string to check, not null
 * @param end  the end to compare against, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkEndsWith(final String str, final String end) {
  final int endLen = end.length();
  return str.regionMatches(!sensitive, str.length() - endLen, end, 0, endLen);
}
origin: square/okhttp

/**
 * Sets the URL target of this request.
 *
 * @throws IllegalArgumentException if {@code url} is not a valid HTTP or HTTPS URL. Avoid this
 * exception by calling {@link HttpUrl#parse}; it returns null for invalid URLs.
 */
public Builder url(String url) {
 if (url == null) throw new NullPointerException("url == null");
 // Silently replace web socket URLs with HTTP URLs.
 if (url.regionMatches(true, 0, "ws:", 0, 3)) {
  url = "http:" + url.substring(3);
 } else if (url.regionMatches(true, 0, "wss:", 0, 4)) {
  url = "https:" + url.substring(4);
 }
 return url(HttpUrl.get(url));
}
origin: redisson/redisson

/**
 * Checks if two strings have the same suffix of specified length
 *
 * @param s   string
 * @param p   string
 * @param len length of the common suffix
 * @return true if both s and p are not null and both have the same suffix. Otherwise - false
 */
public static boolean commonSuffixOfLength(String s, String p, int len) {
  return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len);
}
origin: netty/netty

/**
 * Simple function to match <a href="http://en.wikipedia.org/wiki/Wildcard_DNS_record">DNS wildcard</a>.
 */
static boolean matches(String template, String hostName) {
  if (template.startsWith("*.")) {
    return template.regionMatches(2, hostName, 0, hostName.length())
      || commonSuffixOfLength(hostName, template, template.length() - 1);
  }
  return template.equals(hostName);
}
origin: prestodb/presto

boolean matches(String hostname) {
 if (pattern.startsWith(WILDCARD)) {
  int firstDot = hostname.indexOf('.');
  return (hostname.length() - firstDot - 1) == canonicalHostname.length()
    && hostname.regionMatches(false, firstDot + 1, canonicalHostname, 0,
    canonicalHostname.length());
 }
 return hostname.equals(canonicalHostname);
}
origin: org.apache.commons/commons-lang3

  @Override
  boolean invoke() {
    return data.source.regionMatches(data.ignoreCase, data.toffset, data.other, data.ooffset, data.len);
  }
}.run(data, "String");
origin: prestodb/presto

public int parse(String periodStr, int position) {
  for (String text : iSuffixesSortedDescByLength) {
    if (periodStr.regionMatches(true, position, text, 0, text.length())) {
      if (!matchesOtherAffix(text.length(), periodStr, position)) {
        return position + text.length();
      }
    }
  }
  return ~position;
}
origin: prestodb/presto

public int parse(String periodStr, int position) {
  String text = iText;
  int textLength = text.length();
  if (periodStr.regionMatches(true, position, text, 0, textLength)) {
    if (!matchesOtherAffix(textLength, periodStr, position)) {
      return position + textLength;
    }
  }
  return ~position;
}
origin: redisson/redisson

/**
 * Simple function to match <a href="http://en.wikipedia.org/wiki/Wildcard_DNS_record">DNS wildcard</a>.
 */
static boolean matches(String template, String hostName) {
  if (template.startsWith("*.")) {
    return template.regionMatches(2, hostName, 0, hostName.length())
      || commonSuffixOfLength(hostName, template, template.length() - 1);
  }
  return template.equals(hostName);
}
origin: prestodb/presto

public int scan(String periodStr, final int position) {
  int sourceLength = periodStr.length();
  for (int pos = position; pos < sourceLength; pos++) {
    for (String text : iSuffixesSortedDescByLength) {
      if (periodStr.regionMatches(true, pos, text, 0, text.length())) {
        if (!matchesOtherAffix(text.length(), periodStr, pos)) {
          return pos;
        }
      }
    }
  }
  return ~position;
}
origin: spring-projects/spring-framework

/**
 * Check whether the given FieldError matches the given field.
 * @param field the field that we are looking up FieldErrors for
 * @param fieldError the candidate FieldError
 * @return whether the FieldError matches the given field
 */
protected boolean isMatchingFieldError(String field, FieldError fieldError) {
  if (field.equals(fieldError.getField())) {
    return true;
  }
  // Optimization: use charAt and regionMatches instead of endsWith and startsWith (SPR-11304)
  int endIndex = field.length() - 1;
  return (endIndex >= 0 && field.charAt(endIndex) == '*' &&
      (endIndex == 0 || field.regionMatches(0, fieldError.getField(), 0, endIndex)));
}
origin: joda-time/joda-time

public int parse(String periodStr, int position) {
  for (String text : iSuffixesSortedDescByLength) {
    if (periodStr.regionMatches(true, position, text, 0, text.length())) {
      if (!matchesOtherAffix(text.length(), periodStr, position)) {
        return position + text.length();
      }
    }
  }
  return ~position;
}
java.langStringregionMatches

Javadoc

Tests if two string regions are equal.

A substring of this String object is compared to a substring of the argument other. The result is true if these substrings represent identical character sequences. The substring of this String object to be compared begins at index toffset and has length len. The substring of other to be compared begins at index ooffset and has length len. The result is false if and only if at least one of the following is true:

  • toffset is negative.
  • ooffset is negative.
  • toffset+len is greater than the length of this String object.
  • ooffset+len is greater than the length of the other argument.
  • There is some nonnegative integer k less than len such that: this.charAt(toffset+k) != other.charAt(ooffset+k)

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • split
    Splits this string using the supplied regularExpression. See Pattern#split(CharSequence,int) for an
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • indexOf
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • toLowerCase,
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now