You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2001/03/07 13:56:48 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods WebdavMethodBase.java

juergen     01/03/07 04:56:48

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        WebdavMethodBase.java
  Log:
  added two factory methods for convenience
  
  Revision  Changes    Path
  1.17      +70 -3     jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java
  
  Index: WebdavMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WebdavMethodBase.java	2001/02/26 14:02:09	1.16
  +++ WebdavMethodBase.java	2001/03/07 12:56:47	1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.16 2001/02/26 14:02:09 jericho Exp $
  - * $Revision: 1.16 $
  - * $Date: 2001/02/26 14:02:09 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.17 2001/03/07 12:56:47 juergen Exp $
  + * $Revision: 1.17 $
  + * $Date: 2001/03/07 12:56:47 $
    *
    * ====================================================================
    *
  @@ -145,6 +145,73 @@
   
       // ----------------------------------------------------------- Constructors
   
  +    /**
  +     * Factory method to return a method object based on the methodName.
  +     * If the method name is not known, null is returned
  +     */
  +    public static WebdavMethod factory(String methodName) {
  +        WebdavMethod result = null;
  +        if (methodName.equalsIgnoreCase("COPY")){
  +            result = new CopyMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("DELETE")){
  +            result = new DeleteMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("GET")){
  +            result = new GetMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("HEAD")){
  +            result = new HeadMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("LOCK")){
  +            result = new LockMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("MKCOL")){
  +            result = new MkcolMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("MOVE")){
  +            result = new MoveMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("OPTIONS")){
  +            result = new OptionsMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("POST")){
  +            result = new PostMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("PROPFIND")){
  +            result = new PropFindMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("PROPPATCH")){
  +            result = new PropPatchMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("PUT")){
  +            result = new PutMethod();
  +        }
  +        else if(methodName.equalsIgnoreCase("UNLOCK")){
  +            result = new UnlockMethod();
  +        }
  +        return result;
  +    }
  +
  +        
  +        
  +        
  +    /**
  +     * Factory method to return a method object based on the methodName.
  +     * If the method name is not known, null is returned
  +     */
  +    public static WebdavMethod factory(String methodName, String path) {
  +        WebdavMethod result = factory(methodName);
  +        if (result != null){
  +            result.setPath(path);
  +        }
  +        return result;
  +    }
  +        
  +        
  +        
  +        
  +        
   
       /**
        * Method constructor.
  
  
  

Re: cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods WebdavMethodBase.java

Posted by Remy Maucherat <re...@apache.org>.
Hi Juergen,

>   +    /**
>   +     * Factory method to return a method object based on the
methodName.
>   +     * If the method name is not known, null is returned
>   +     */
>   +    public static WebdavMethod factory(String methodName) {
>   +        WebdavMethod result = null;
>   +        if (methodName.equalsIgnoreCase("COPY")){
>   +            result = new CopyMethod();
>   +        }
>   +        else if(methodName.equalsIgnoreCase("DELETE")){
>   +            result = new DeleteMethod();
>   +        }

<snip>

>   +        return result;
>   +    }

I'm a bit worried that this could limitate pluggability.
For example, I plan to separate the HTTP/1.1 client library and the HTTP/1.1
methods (GET, PUT, ...) from the WebDAV specific parts (the XML resp base,
and all the methods), and perhaps eventually contribute the HTTP library
core to the "commons" subproject (which is a repository for shared code -
http://husted.com/about/commons/).

That patch would prevent that, since it would tie the HTTP parts and the
WebDAV specific stuff together.

Remy