Code example for URI

Methods: getHost, getScheme, getSchemeSpecificPart, toString

0
	 *  
	 * @return true if valid 
	 */ 
	@Override 
	public boolean validate(URI uri, boolean is_pattern) {
		if (uri.toString().equals(NullEIDText) || uri.toString().equals(WildcardEIDText))
		{ 
			return true; 
		} 
		 
		if ( is_pattern ) return true;
		 
		 
		if (uri.getHost() == null ) return false;
		 
		if (!uri.getScheme().equals(schemeText) ) return false;
		 
		 
		 
		// There shouldn't be nested path in this Scheme.  
		// For example, this is fine: dtn://endpoint.com/tag 
		//            But, this is not valid: dtn://endpoint.com/tag/nested 
		 
		 
		if (!EndpointID.is_able_to_create_URI(uri.toString()))
		{ 
			Log.d(TAG, "DTNScheme::validate: invalid URI");
			return false; 
		} 
		 
		// a valid dtn scheme uri must have a host component in the 
	    // authority unless it's the special "dtn:none" uri 
	    if (!uri.getSchemeSpecificPart().equals("none") && uri.getHost().length() == 0 ) {
	        return false; 
	    } 
		return true; 
	}