1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  package org.abstracthorizon.danube.webdav.xml.dav.request.properties;
14  
15  import org.abstracthorizon.danube.webdav.ResourceAdapter;
16  import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
17  import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
18  
19  import org.xml.sax.SAXException;
20  
21  
22  
23  
24  
25  
26  public class GetContentLength extends RequestProperty {
27  
28      
29      protected long contentLength = -1;
30  
31      
32  
33  
34  
35      public GetContentLength(XMLParserHandler parent) {
36          super(parent);
37      }
38  
39      @Override
40      public Object end(Object current, String tag, String value) throws SAXException {
41          try {
42              contentLength = Long.parseLong(value);
43          } catch (NumberFormatException e) {
44              contentLength = -1;
45          }
46          return super.end(current, tag, value);
47      }
48  
49      
50  
51  
52  
53      public long getContentLength() {
54          return contentLength;
55      }
56  
57      
58  
59  
60  
61  
62  
63      public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
64          return new org.abstracthorizon.danube.webdav.xml.dav.response.properties.GetContentLength(adapter.resourceLength(resource));
65      }
66  
67      @Override
68      public String toString() {
69          return "GetContentLength[" + getContentLength() + "]";
70      }
71  }