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.HRef;
17  
18  import org.xml.sax.Attributes;
19  import org.xml.sax.SAXException;
20  
21  /**
22   * This class models WebDAV's owner tag
23   *
24   * @author Daniel Sendula
25   */
26  public class Owner extends AbstractSimpleXMLHandler {
27  
28      /** Owner */
29      protected Object owner;
30  
31      /**
32       * Constructor
33       * @param parent parent
34       */
35      public Owner(XMLParserHandler parent) {
36          super(parent);
37      }
38  
39      @Override
40      public Object start(Object current, String tag, Attributes attributes) throws SAXException {
41          if ("href".equals(tag)) {
42              owner = new HRef(this);
43              return owner;
44          } else {
45              return super.start(current, tag, attributes);
46          }
47      }
48  
49      @Override
50      public Object end(Object current, String tag, String value) throws SAXException {
51          if (this.owner == null) {
52              this.owner = value;
53          }
54          return super.end(current, tag, value);
55      }
56  
57      /**
58       * Returns owner
59       * @return owner
60       */
61      public Object getOwner() {
62          return owner;
63      }
64  
65      @Override
66      public String toString() {
67          if (owner != null) {
68              return "Owner[" + owner + "]";
69          } else {
70              return "Owner[]";
71          }
72      }
73  
74  }