vmassol     2003/02/20 05:50:16

  Modified:    framework/src/java/share/org/apache/cactus ServletURL.java
  Log:
  Better way to express and undefined simulation URL (null object returned by the 
static loadFromRequest() method)
  
  Revision  Changes    Path
  1.11      +17 -18    
jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletURL.java
  
  Index: ServletURL.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletURL.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ServletURL.java   20 Feb 2003 13:47:01 -0000      1.10
  +++ ServletURL.java   20 Feb 2003 13:50:16 -0000      1.11
  @@ -567,6 +567,7 @@
       public static ServletURL loadFromRequest(HttpServletRequest theRequest)
       {
           String qString = theRequest.getQueryString();
  +        boolean isDefined = false;
   
           ServletURL url = new ServletURL();
   
  @@ -575,6 +576,7 @@
   
           if (protocol != null)
           {
  +            isDefined = true;
               url.setProtocol(protocol);
           }
   
  @@ -583,6 +585,7 @@
   
           if (serverName != null)
           {
  +            isDefined = true;
               url.setServerName(serverName);
           }
   
  @@ -591,6 +594,7 @@
   
           if (contextPath != null)
           {
  +            isDefined = true;
               url.setContextPath(contextPath);
           }
   
  @@ -599,6 +603,7 @@
   
           if (servletPath != null)
           {
  +            isDefined = true;
               url.setServletPath(servletPath);
           }
   
  @@ -607,6 +612,7 @@
   
           if (pathInfo != null)
           {
  +            isDefined = true;
               url.setPathInfo(pathInfo);
           }
   
  @@ -615,10 +621,19 @@
   
           if (queryString != null)
           {
  +            isDefined = true;
               url.setQueryString(queryString);
           }
   
  -        LOGGER.debug("URL = [" + url + "]");
  +        if (!isDefined)
  +        {
  +            LOGGER.debug("Undefined simulation URL");
  +            url = null;
  +        }
  +        else
  +        {
  +            LOGGER.debug("Simulation URL = [" + url + "]");
  +        }
   
           return url;
       }
  @@ -658,20 +673,4 @@
           }
       }
   
  -    /**
  -     * @return true if the simulation URL is not defined or false otherwise. 
  -     */
  -    public boolean isDefined()
  -    {
  -        boolean defined = true;
  -
  -        if ((getHost() == null) && (getPort() == -1) 
  -            && (getContextPath() == null) && (getServletPath() == null) 
  -            && (getPathInfo() == null) && (getQueryString() == null))
  -        {
  -            defined = false;
  -        }
  -        
  -        return defined; 
  -    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to