Example #1
0
 /**
  * Validate an URL with pattern
  * http://developer.android.com/reference/android/util/Patterns.html#WEB_URL or #IP_ADDRESS
  *
  * @param url The URL to validate
  * @return true if the URL matches the pattern, false otherwise
  */
 public static boolean isUrlValid(String url) {
   return (url == null)
       ? false
       : (Patterns.WEB_URL.matcher(url).matches() || Patterns.IP_ADDRESS.matcher(url).matches());
 }
 /**
  * Elides any IP addresses in the specified {@link String} with {@link #IP_ELISION}.
  *
  * @param original String potentially containing IPs.
  * @return String with elided IPs.
  */
 @VisibleForTesting
 protected static String elideIp(String original) {
   return Patterns.IP_ADDRESS.matcher(original).replaceAll(IP_ELISION);
 }
Example #3
0
 /**
  * Check whether an IP address is correct using Patterns.IP_ADDRESS. Does *not* accept port
  * numbers.
  *
  * @param ip to check
  * @return true if the given IP is correct
  */
 public static boolean isCorrectIPAddress(String ip) {
   return Patterns.IP_ADDRESS.matcher(ip).matches();
 }