Here you can find the source of isValid(String uri)
public static boolean isValid(String uri)
//package com.java2s; import java.net.URI; import java.net.URISyntaxException; public class Main { /**// w ww . j a v a2 s . com * @return true if the string represents a valid URI and the URI is a valid ViPR URL else false */ public static boolean isValid(String uri) { try { return isValid(new URI(uri)); } catch (URISyntaxException e) { return false; } } /** * @return true if the uri represents a valid ViPR URI regardless of class */ public static boolean isValid(final URI uri) { if (uri == null || uri.getScheme() == null || uri.getSchemeSpecificPart() == null || !uri.getScheme().equals("urn") || !uri.getSchemeSpecificPart().startsWith("storageos")) { return false; } /* * (?i) - ignores case of letters in following parentheses * urn:storageos: - matches exact stting, this is consistent for all ViPR uris * [A-Z]+: - This will match the class with any number of letters followed by a colon * [A-F0-9]{8} - used for matchin UUID, This segment is 8 hex characters. * The full UUID pattern is all Hex characters seperated by '-' in specific quantities * :([A-Z0-9]+)? - any amount of letters or numbers preceded by a colon * * Only legal characters (letters(any case), numbers, '-', ':') */ return uri.toString().matches("(?i)(urn:storageos:" + "[A-Z]+:" + "[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}" + ":([A-Z0-9]+)?)"); } }