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.DAVAbstractXMLParser;
17  import org.abstracthorizon.danube.webdav.xml.dav.DAVFactory;
18  
19  import org.xml.sax.Attributes;
20  import org.xml.sax.SAXException;
21  
22  /**
23   * This class models WebDAV's propertybehaviour tag
24   *
25   * @author Daniel Sendula
26   */
27  public class PropertyBehavior extends DAVAbstractXMLParser {
28  
29      /** Omit flag */
30      protected boolean omit;
31  
32      /** Keep alive */
33      protected KeepAlive keepAlive;
34  
35      /**
36       * Constructor
37       * @param parent parent parser handler
38       * @param factory factory
39       */
40      public PropertyBehavior(XMLParserHandler parent, DAVFactory factory) {
41          super(parent, factory);
42      }
43  
44      @Override
45      public Object start(Object current, String tag, Attributes attributes) throws SAXException {
46          if ("omit".equals(tag)) {
47              omit = true;
48              return this;
49          } else if ("keepalive".equals(tag)) {
50              keepAlive = davFactory.newKeepAlive(this);
51              return keepAlive;
52          }
53          return super.start(current, tag, attributes);
54      }
55  
56      @Override
57      public Object end(Object current, String tag, String value) throws SAXException {
58          return this;
59      }
60  
61      @Override
62      public String toString() {
63          if (keepAlive != null) {
64              return "PropertyBehavior[" + keepAlive + "]";
65          } else {
66              return "PropertyBehavior[omit]";
67          }
68      }
69  }