View Javadoc

1   /*
2    * Copyright (c) 2006-2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.danube.webdav.xml.dav;
14  
15  import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
16  import org.abstracthorizon.danube.webdav.xml.dav.request.AbstractSimpleXMLHandler;
17  
18  import org.xml.sax.Attributes;
19  import org.xml.sax.SAXException;
20  
21  /**
22   * This class models WebDAV's scope tag
23   *
24   * @author Daniel Sendula
25   */
26  public class LockScope extends AbstractSimpleXMLHandler {
27  
28      /** Exclusive or shared scope */
29      protected boolean exclusive = false;
30  
31      /**
32       * Constructor
33       * @param parent parent parser handler
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      @Override
66      public String toString() {
67          return "LockScope[exclusive=" + exclusive + "]";
68      }
69  
70  }