Code example for URI

Methods: getAuthority, getHost, getPort, getScheme

0
	 * @param pdURI - A URI to be checked for conformance to PLANETS URI scheme 
	 * @return true if the parameter is a well formed PLANETS URI 
	 */ 
	public static boolean isPlanetsURI(URI pdURI) {
		// Get the port, host and scheme from the supplied  
		int _port = pdURI.getPort();
		String _host = pdURI.getHost();
		String _scheme = pdURI.getScheme();
		 
		// Check for nulls 
		if ((_host == null) | (_scheme == null)) {
			return false; 
		} 
		 
		// Now perform the checks and return the result 
		return ((_port > -1) && (_host.length() > 0) && _scheme.equals(PLANETS_SCHEME));
	} 
	 
	/** 
	 * Checks to see if a URI is a PLANETS Data Registry URI 
	 * The URI argument must be of the following form: 
	 * <p/> 
	 * <code>planets://<i>server:port</i>/dr/</code> 
	 *  
	 * @param pdURI - A URI to be checked for conformance as a PLANETS data URI 
	 * @return true if the URI is a PLANETS data URI 
	 */ 
	public static boolean isDataRegistryURI(URI pdURI) {
		boolean _retVal = false;
		if (PDURIHelper.isPlanetsURI(pdURI)) {
			// Check the first path component is a data registry identifier 
			String _path = pdURI.normalize().getPath(); 
			if (_path.length() > 1) {
				_retVal = pdURI.normalize().getPath().substring(1).split("/")[0].toLowerCase().equals(DATA_REG_PART);
			} 
		} 
		return _retVal;
	} 
	 
	/** 
	 * For a given PLANETS URI returns the serer identifier. 
	 * The URI argument must be of the following form: 
	 * <p/> 
	 * <code>planets://<i>server:port</i></code> 
	 *  
	 * @param pdURI - A URI from which to parse the PLANETS server name 
	 * @return the ID of the server as a String 
	 */ 
	public static String getPlanetsServerIdentifier(URI pdURI) {
		String _serverID = null;
		if (PDURIHelper.isPlanetsURI(pdURI)) {
			_serverID = pdURI.getScheme() + "://" + pdURI.getAuthority();
		} 
		return _serverID;
	} 
	 
	/**