private void setUri(URI uri) throws DataSourceResourceException { if(uri == null || !UriBasedVehicleInterfaceMixin.validateResource(uri)) { throw new DataSourceResourceException("URI is not valid"); } mUri = uri; } }
/** * Convert the parameter to a URI and validate the correctness of its host * and port. * * @return true if the address and port are valid. */ public static boolean validateResource(String uriString) { if(uriString == null) { return false; } try { return validateResource(createUri(uriString)); } catch(DataSourceException e) { Log.d(TAG, "URI is not valid", e); return false; } }
/** * Return true if the address and port are valid. * * @return true if the address and port are valid. */ public static boolean validateResource(String uriString) { try { URI uri = UriBasedVehicleInterfaceMixin.createUri(massageUri(uriString)); return UriBasedVehicleInterfaceMixin.validateResource(uri) && uri.getPort() < 65536; } catch(DataSourceException e) { return false; } }