result = new Reference(this); } else {
   public Reference getTargetRef()   {   	Reference result = null;   	String scheme = getScheme();   	   	// Step 1 - Resolve relative reference against their base reference   	if(scheme != null)   	{   		// Absolute URI detected   		result = new Reference(this);   	}   	else   	{      	String authority = getAuthority();      	String path = getPath();      	String query = getQuery();      	String fragment = getFragment();      	// Create an empty reference   		result = new Reference();      	result.setScheme(baseRef.getScheme());   		      	if(authority != null)      	{      		result.setAuthority(authority);      		result.setPath(path);      		result.setQuery(query);      	}      	else   		{      		result.setAuthority(baseRef.getAuthority());      		if((path == null) || (path.equals("")))      		{      			result.setPath(baseRef.getPath());      			               if(query != null)               {               	result.setQuery(query);               }               else               {               	result.setQuery(baseRef.getQuery());               }      		}      		else      		{               if(path.startsWith("/"))               {               	result.setPath(path);               }               else               {            		String basePath = baseRef.getPath();            		String mergedPath = null;            		            		if((baseRef.getAuthority() != null) && ((basePath == null) || (basePath.equals(""))))            		{            			mergedPath = "/" + path;            		}            		else            		{               		// Remove the last segment which may be empty if the path is ending with a slash               		int lastSlash = basePath.lastIndexOf('/');               		if(lastSlash == -1)               		{               			mergedPath = path;               		}               		else               		{               			mergedPath = basePath.substring(0, lastSlash + 1) + path;               		}            		}               	               	               	result.setPath(mergedPath);               }                           result.setQuery(query);      			      		}   		}      	      	result.setFragment(fragment);   	}   	   	// Step 2 - Normalize the target reference   	result.normalize();  	   	return result;   }