rest = rest.substring(1, rest.length() - 2);
rest = rest.substring(1, rest.length() - 1);
   public String get(String name)   {      String result = null;      try      {	      if(name.startsWith(NAME_CLIENT_ADDRESS))	      {	      	if(name.equals(NAME_CLIENT_ADDRESS))	      	{	      		result = call.getClientAddress();	      	}	      	else	      	{	      		String rest = name.substring(NAME_CLIENT_ADDRESS.length());		      		if((rest.charAt(0) == '[') && (rest.charAt(rest.length() - 1) == ']'))	      		{	      			rest = rest.substring(1, rest.length() - 2);	      				   				if(rest.equals("first"))	   				{	   					result = call.getClientAddresses().get(0);	   				}	   				else if(rest.equals("last"))	   				{	   					result = call.getClientAddresses().get(call.getClientAddresses().size() - 1);	   				}	   				else if((rest.charAt(0) == '"') && (rest.charAt(rest.length() - 1) == '"'))	   				{	   					// Can't lookup by name	   					result = defaultValue;	   				}	   				else	   				{	   					// Lookup by index	   					result = call.getClientAddresses().get(Integer.parseInt(rest));	   				}	      		}	      		else	      		{	      			result = defaultValue;	      		}	      	}	      }	      else if(name.equals(NAME_CLIENT_NAME))	      {	         result = call.getClientName();	      }	      else if(name.startsWith(NAME_COOKIE))	      {	   		String rest = name.substring(NAME_COOKIE.length());		   		if((rest.charAt(0) == '[') && (rest.charAt(rest.length() - 1) == ']'))	   		{	   			rest = rest.substring(1, rest.length() - 2);	   								if(rest.equals("first"))					{			         result = call.getCookies().get(0).getValue();					}					else if(rest.equals("last"))					{						result = call.getCookies().get(call.getCookies().size() - 1).getValue();					}					else if((rest.charAt(0) == '"') && (rest.charAt(rest.length() - 1) == '"'))					{						// Lookup by name		   			rest = rest.substring(1, rest.length() - 2);			         result = CookieUtils.getFirstCookie(call.getCookies(), rest).getValue();					}					else					{						// Lookup by index						result = call.getCookies().get(Integer.parseInt(rest)).getValue();					}	   		}	   		else	   		{	   			result = defaultValue;	   		}	      }	      else if(name.equals(NAME_METHOD))	      {	         result = call.getMethod().getName();	      }	      else if(name.equals(NAME_REDIRECT_URI))	      {	         result = call.getRedirectionRef().toString();	      }	      else if(name.equals(NAME_REFERRER_URI))	      {	         result = call.getReferrerRef().toString();	      }	      else if(name.equals(NAME_RESOURCE_AUTHORITY))	      {	         result = call.getResourceRef().getAuthority();	      }	      else if(name.equals(NAME_RESOURCE_FRAGMENT))	      {	         result = call.getResourceRef().getFragment();	      }	      else if(name.equals(NAME_RESOURCE_HOST_NAME))	      {	         result = call.getResourceRef().getHostName();	      }	      else if(name.equals(NAME_RESOURCE_HOST_PORT))	      {	         result = call.getResourceRef().getHostPort().toString();	      }	      else if(name.equals(NAME_RESOURCE_HOST_IDENTIFIER))	      {	         result = call.getResourceRef().getHostIdentifier();	      }	      else if(name.equals(NAME_RESOURCE_IDENTIFIER))	      {	         result = call.getResourceRef().getIdentifier();	      }	      else if(name.equals(NAME_RESOURCE_PATH))	      {	         result = call.getResourceRef().getPath();	      }	      else if(name.startsWith(NAME_RESOURCE_QUERY))	      {	      	if(name.equals(NAME_RESOURCE_QUERY))	      	{		         result = call.getResourceRef().getQuery();	      	}	      	else	      	{	      		String rest = name.substring(NAME_RESOURCE_QUERY.length());		      		if((rest.charAt(0) == '[') && (rest.charAt(rest.length() - 1) == ']'))	      		{	      			rest = rest.substring(1, rest.length() - 2);	      				   				if(rest.equals("first"))	   				{	   					result = call.getResourceRef().getQueryAsForm().getParameters().get(0).getValue();	   				}	   				else if(rest.equals("last"))	   				{	   					List<Parameter> params = call.getResourceRef().getQueryAsForm().getParameters(); 	   					result = params.get(params.size() - 1).getValue();	   				}	   				else if((rest.charAt(0) == '"') && (rest.charAt(rest.length() - 1) == '"'))	   				{							// Lookup by name			   			rest = rest.substring(1, rest.length() - 2);				         result = call.getResourceRef().getQueryAsForm().getFirstParameter(rest).getValue();	   				}	   				else	   				{	   					// Lookup by index	   					result = call.getResourceRef().getQueryAsForm().getParameters().get(Integer.parseInt(rest)).getValue();	   				}	      		}	      		else	      		{	      			result = defaultValue;	      		}	      	}	      }	      else if(name.equals(NAME_RESOURCE_SCHEME))	      {	         result = call.getResourceRef().getScheme();	      }	      else if(name.equals(NAME_RESOURCE_URI))	      {	         result = call.getResourceRef().toString();	      }	      else if(name.equals(NAME_RESOURCE_USER_INFO))	      {	         result = call.getResourceRef().getUserInfo();	      }	      else if(name.equals(NAME_SERVER_ADDRESS))	      {	         result = call.getServerAddress();	      }	      else if(name.equals(NAME_SERVER_NAME))	      {	         result = call.getServerName();	      }	      else if(name.equals(NAME_STATUS))	      {	         result = Integer.toString(call.getStatus().getHttpCode());	      }		      // Check if the default value should be returned	      if(result == null)	      {	         result = this.defaultValue;	      }      }      catch(Exception e)      {         result = this.defaultValue;      }         return result;   }