remm        01/05/13 17:09:17

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        XMLResponseMethodBase.java
  Log:
  - XML response base now uses either BaseProperty or one of the specialized
    property implementation.
  - Remove all the redundant inner classes.
  
  Revision  Changes    Path
  1.15      +11 -116   
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
  
  Index: XMLResponseMethodBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XMLResponseMethodBase.java        2001/05/01 21:28:00     1.14
  +++ XMLResponseMethodBase.java        2001/05/14 00:09:16     1.15
  @@ -84,10 +84,10 @@
   import org.apache.commons.httpclient.HttpMethodBase;
   
   import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.BaseProperty;
   import org.apache.webdav.lib.ResponseEntity;
   
  -import org.apache.webdav.lib.properties.GetLastModifiedProperty;
  -import org.apache.webdav.lib.properties.ResourceTypeProperty;
  +import org.apache.webdav.lib.properties.*;
   
   import org.apache.util.WebdavStatus;
   import org.apache.util.DOMUtils;
  @@ -293,14 +293,20 @@
               String localName = DOMUtils.getElementLocalName(element);
   
               if (ResourceTypeProperty.TAG_NAME.equals(localName)) {
  -                property = new ResourceTypePropertyImpl(response, element);
  +                property = new ResourceTypeProperty(response, element);
               } else if (GetLastModifiedProperty.TAG_NAME.equals(localName)) {
  -                property = new GetLastModifiedPropertyImpl(response, element);
  +                property = new GetLastModifiedProperty(response, element);
  +            } else if (CurrentUserPrivilegeSetProperty.TAG_NAME.equals
  +                       (localName)) {
  +                property = 
  +                    new CurrentUserPrivilegeSetProperty(response, element);
  +            } else if (LockDiscoveryProperty.TAG_NAME.equals(localName)) {
  +                property = new LockDiscoveryProperty(response, element);
               }
           }
   
           if (property == null) {
  -            property = new PropertyImpl(response, element);
  +            property = new BaseProperty(response, element);
           }
   
           return property;
  @@ -424,116 +430,5 @@
       }
   
   
  -    /**
  -     * This class implements the Property interface and provides basic
  -     * methods for reading the property.
  -     */
  -    static class PropertyImpl implements Property {
  -
  -        protected Response response;
  -        protected Element element;
  -
  -        PropertyImpl(Response response, Element element) {
  -            this.element = element;
  -            this.response = response;
  -        }
  -
  -        public String getName() {
  -            return element.getTagName();
  -        }
  -
  -        public String getLocalName() {
  -            return DOMUtils.getElementLocalName(element);
  -        }
  -
  -        public String getNamespaceURI() {
  -            return DOMUtils.getElementNamespaceURI(element);
  -        }
  -
  -        public Element getElement() {
  -            return element;
  -        }
  -
  -        public String getPropertyAsString() {
  -            return DOMUtils.getTextValue(element);
  -        }
  -
  -        public int getStatusCode() {
  -            return response.getStatusCode();
  -        }
  -
  -        public String getOwningURL() {
  -            return response.getHref();
  -        }
  -
  -        public String toString () {
  -            StringWriter tmp = new StringWriter();
  -            DOMWriter domWriter = new DOMWriter(tmp, true);
  -            domWriter.print(element);
  -            return tmp.getBuffer().toString();
  -        }
  -    }
  -
  -
  -    /**
  -     * This represents a DAV:resourcetype property.  It provides some
  -     * convenience methods for working with the property.
  -     */
  -    static class ResourceTypePropertyImpl extends PropertyImpl
  -        implements ResourceTypeProperty {
  -
  -        ResourceTypePropertyImpl(Response response, Element element) {
  -            super(response, element);
  -        }
  -
  -        public boolean isCollection() {
  -            boolean isCollection = false;
  -            NodeList tmp = element.getChildNodes();
  -            for (int i = 0;
  -                 tmp != null && !isCollection && i < tmp.getLength(); i++ ) {
  -                try {
  -                    Element child = (Element) tmp.item(i);
  -                    isCollection = isCollection || ("collection".equals(
  -                        DOMUtils.getElementLocalName(child)) &&
  -                        "DAV:".equals(DOMUtils.getElementNamespaceURI(child)));
  -                } catch (ClassCastException e) {
  -                }
  -            }
  -            return (tmp.getLength() > 0);
  -        }
  -    }
  -
  -
  -    /**
  -     * This represents a DAV:getlastmodified property.  It provides some
  -     * convenience methods for working with the property.
  -     */
  -    static class GetLastModifiedPropertyImpl extends PropertyImpl
  -        implements GetLastModifiedProperty {
  -
  -        protected DateFormat format = null;
  -
  -        GetLastModifiedPropertyImpl(Response response, Element element) {
  -            super(response, element);
  -        }
  -
  -        public Date getDate() {
  -            Date date = null;
  -            try {
  -                DateFormat dateFormat = getDateFormat();
  -                date = dateFormat.parse(DOMUtils.getTextValue(element));
  -            } catch (ParseException e) {
  -            }
  -            return date;
  -        }
  -
  -        protected DateFormat getDateFormat() {
  -            if (format == null) {
  -                // RFC 1123, 822. Date and time specification is English.
  -                format = new SimpleDateFormat(DATE_FORMAT, Locale.US);
  -            }
  -            return format;
  -        }
  -    }
   }
   
  
  
  

Reply via email to