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  
18  import org.xml.sax.Attributes;
19  import org.xml.sax.SAXException;
20  
21  
22  
23  
24  
25  
26  public class LockScope extends AbstractSimpleXMLHandler {
27  
28      
29      protected boolean exclusive = false;
30  
31      
32  
33  
34  
35      public LockScope(XMLParserHandler parent) {
36          super(parent);
37      }
38  
39      @Override
40      public Object start(Object current, String tag, Attributes attributes) throws SAXException {
41          if ("exclusive".equals(tag)) {
42              exclusive = true;
43              return this;
44          } else if ("shared".equals(tag)) {
45              exclusive = false;
46              return this;
47          } else {
48              return super.start(current, tag, attributes);
49          }
50      }
51  
52      @Override
53      public Object end(Object current, String tag, String value) throws SAXException {
54          if ("exclusive".equals(tag)) {
55              exclusive = true;
56              return this;
57          } else if ("shared".equals(tag)) {
58              exclusive = false;
59              return this;
60          } else {
61              return super.end(current, tag, value);
62          }
63      }
64  
65      
66  
67  
68  
69  
70  
71      public int getScope() {
72          if (exclusive) {
73              return LockingMechanism.SCOPE_EXCLUSIVE;
74          } else {
75              return LockingMechanism.SCOPE_SHARED;
76          }
77      }
78  
79      @Override
80      public String toString() {
81          return "LockScope[exclusive=" + exclusive + "]";
82      }
83  
84  }