1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  package org.abstracthorizon.danube.webdav.xml.dav.request;
14  
15  import org.abstracthorizon.danube.webdav.lock.LockingMechanism;
16  import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
17  import org.abstracthorizon.danube.webdav.xml.dav.DAVAbstractXMLParser;
18  import org.abstracthorizon.danube.webdav.xml.dav.DAVFactory;
19  
20  import org.xml.sax.Attributes;
21  import org.xml.sax.SAXException;
22  
23  
24  
25  
26  
27  
28  public class LockEntry extends DAVAbstractXMLParser {
29  
30      
31      protected LockScope lockScope;
32  
33      
34      protected LockType lockType;
35  
36      
37  
38  
39  
40  
41      public LockEntry(XMLParserHandler parent, DAVFactory factory) {
42          super(parent, factory);
43          lockScope = factory.newLockScope(this);
44          lockType = factory.newLockType(this);
45      }
46  
47      @Override
48      public Object start(Object current, String tag, Attributes attributes) throws SAXException {
49          if ("lockscope".equals(tag)) {
50              return lockScope;
51          } else if ("locktype".equals(tag)) {
52              return lockType;
53          }  else {
54              return super.start(current, tag, attributes);
55          }
56      }
57  
58      @Override
59      public Object end(Object current, String tag, String value) throws SAXException {
60          return this;
61      }
62  
63      
64  
65  
66  
67  
68      public int getType() {
69          return LockingMechanism.TYPE_WRITE;
70      }
71  
72      
73  
74  
75  
76  
77  
78      public int getScope() {
79          if (lockScope == null) {
80              return LockingMechanism.SCOPE_NONE;
81          } else {
82              return lockScope.getScope();
83          }
84      }
85  
86      @Override
87      public String toString() {
88          return "LockEntry[" + lockScope + "," + lockType + "]";
89      }
90  }