vgritsenko    02/01/26 09:31:44

  Modified:    src/java/org/apache/cocoon/components/language/markup/xsp
                        XSPCookieHelper.java
  Log:
  Remove duplicated code
  
  Revision  Changes    Path
  1.4       +24 -61    
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPCookieHelper.java
  
  Index: XSPCookieHelper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPCookieHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSPCookieHelper.java      22 Jan 2002 00:17:11 -0000      1.3
  +++ XSPCookieHelper.java      26 Jan 2002 17:31:44 -0000      1.4
  @@ -43,7 +43,7 @@
    * private static String returnCookieProperty(Map ,String ,int ,String );
    * </pre>
    *
  - * @version CVS $Revision: 1.3 $ $Date: 2002/01/22 00:17:11 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/01/26 17:31:44 $
    */
   public class XSPCookieHelper extends XSPObjectHelper {
       /**
  @@ -205,7 +205,7 @@
        */
       public static Cookie getCookie(Map objectModel,
                                      String cookieName,
  -                                   int cookieIndex) throws SAXException
  +                                   int cookieIndex)
       {
           boolean retrieveByName = false;
           boolean retrieveByIndex = false;
  @@ -224,7 +224,7 @@
   
           Cookie[] cookies = request.getCookies();
           if (cookies != null && retrieveByName) {
  -            for(count=0; count<cookies.length; count++) {
  +            for(count = 0; count < cookies.length; count++) {
                   currentCookie = cookies[count];
                   if (currentCookie.getName().equals(cookieName)) {
                       matchFound = true;
  @@ -242,7 +242,6 @@
               return currentCookie;
           else
               return null;
  -
       }
   
       /**
  @@ -507,66 +506,30 @@
        *             the property will be returned.
        */
       private static String returnCookieProperty(Map objectModel,
  -                                                String cookieName,
  -                                                int cookieIndex,
  -                                                String propertyPrefix)
  +                                               String cookieName,
  +                                               int cookieIndex,
  +                                               String propertyPrefix)
       {
  -        boolean retrieveByName = false;
  -        boolean retrieveByIndex = false;
  -        boolean matchFound = false;
  -
  -        Cookie currentCookie = null;
  -
  -        Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
  -
  -        int count                          = 0;
  +        Cookie currentCookie = getCookie(objectModel, cookieName, cookieIndex);
   
           String returnValue = null;
  -
  -        if (cookieName != null) {
  -            retrieveByName = true;
  -        } else if (cookieIndex >=0) {
  -            retrieveByIndex =  true;
  -        }
  -
  -        Cookie[] cookies = request.getCookies();
  -        if (cookies != null && cookies.length > 0) {
  -            if (retrieveByName) {
  -                count = 0;
  -                while (count < cookies.length && !matchFound) {
  -                    currentCookie = cookies[count];
  -
  -                    if (currentCookie.getName().equals(cookieName))
  -                        matchFound = true;
  -                    count++;
  -                }
  -            } else if (retrieveByIndex) {
  -                if(cookies.length > cookieIndex)
  -                {
  -                    currentCookie = cookies[cookieIndex];
  -                    matchFound = true;
  -                }
  -            }
  -
  -            if (matchFound)
  -            {
  -                if(propertyPrefix.equals("C"))
  -                    returnValue = currentCookie.getComment();
  -                else if(propertyPrefix.equals("D"))
  -                    returnValue = currentCookie.getDomain();
  -                else if(propertyPrefix.equals("M"))
  -                    returnValue = Integer.toString(currentCookie.getMaxAge());
  -                else if(propertyPrefix.equals("N"))
  -                    returnValue = currentCookie.getName();
  -                else if(propertyPrefix.equals("P"))
  -                    returnValue = currentCookie.getPath();
  -                else if(propertyPrefix.equals("S"))
  -                    returnValue = returnValue.valueOf(currentCookie.getSecure());
  -                else if(propertyPrefix.equals("V"))
  -                    returnValue = currentCookie.getValue();
  -                else if(propertyPrefix.equals("Ve"))
  -                    returnValue = Integer.toString(currentCookie.getVersion());
  -            }
  +        if (currentCookie != null) {
  +            if(propertyPrefix.equals("C"))
  +                returnValue = currentCookie.getComment();
  +            else if(propertyPrefix.equals("D"))
  +                returnValue = currentCookie.getDomain();
  +            else if(propertyPrefix.equals("M"))
  +                returnValue = Integer.toString(currentCookie.getMaxAge());
  +            else if(propertyPrefix.equals("N"))
  +                returnValue = currentCookie.getName();
  +            else if(propertyPrefix.equals("P"))
  +                returnValue = currentCookie.getPath();
  +            else if(propertyPrefix.equals("S"))
  +                returnValue = returnValue.valueOf(currentCookie.getSecure());
  +            else if(propertyPrefix.equals("V"))
  +                returnValue = currentCookie.getValue();
  +            else if(propertyPrefix.equals("Ve"))
  +                returnValue = Integer.toString(currentCookie.getVersion());
           }
   
           return returnValue;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to