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.request;
14  
15  import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
16  import org.abstracthorizon.danube.webdav.xml.dav.DAVFactory;
17  
18  import org.xml.sax.Attributes;
19  import org.xml.sax.SAXException;
20  
21  /**
22   * This class models WebDAV's lockinfo tag
23   *
24   * @author Daniel Sendula
25   */
26  public class LockInfo extends LockEntry {
27  
28      /** Owner */
29      protected Owner owner;
30  
31      /**
32       * Constructor
33       * @param parent parent parser handler
34       * @param factory factory
35       */
36      public LockInfo(XMLParserHandler parent, DAVFactory factory) {
37          super(parent, factory);
38          lockScope = factory.newLockScope(this);
39          lockType = factory.newLockType(this);
40      }
41  
42      @Override
43      public Object start(Object current, String tag, Attributes attributes) throws SAXException {
44          if ("owner".equals(tag)) {
45              owner = new Owner(this);
46              return owner;
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          return this;
55      }
56  
57      /**
58       * Returns owner
59       * @return owner
60       */
61      public Object getOwner() {
62          if (owner != null) {
63              return owner.getOwner();
64          } else {
65              return null;
66          }
67      }
68  
69      @Override
70      public String toString() {
71          if (owner == null) {
72              return "LockInfo[" + lockScope + "," + lockType + "]";
73          } else {
74              return "LockInfo[" + lockScope + "," + lockType + "," + owner + "]";
75          }
76      }
77  }