public String populate(URI uri) {

		if ( ! this.matches(uri))
		{
			throw new IllegalArgumentException( "URI does not match regular expression");
		}
		
		String retval = pattern;

		while (retval.contains("{scheme")) {
			retval = subEdit(retval, "{scheme", uri.getScheme(), getScheme());
		}
		while (retval.contains("{host")) {
			retval = subEdit(retval, "{host", uri.getHost(), getHost());
		}
		while (retval.contains("{port}")) {
			if (uri.getPort() == URIMatcher.NO_PORT)
			{
				retval = retval.replace("{port}", "");	
			}
			else
			{
				retval = retval.replace("{port}", Integer.toString(uri.getPort()));	
			}
		}

		while (retval.contains("{path")) {
			retval = subEdit(retval, "{path", uri.getPath(), getPath());
		}
		while (retval.contains("{fragment")) {
			retval = subEdit(retval, "{fragment", uri.getFragment(), getFragment());
		}
		while (retval.contains("{uri}")) {
			retval = retval.replace("{uri}", uri.toString());
		}
		return retval;
	}