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.properties;
14  
15  import org.abstracthorizon.danube.webdav.ResourceAdapter;
16  import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
17  import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
18  
19  import org.xml.sax.SAXException;
20  
21  /**
22   * This class models WebDAV's displayname request property tag
23   *
24   * @author Daniel Sendula
25   */
26  public class DisplayName extends RequestProperty {
27  
28      /** Display name */
29      protected String displayName;
30  
31      /**
32       * Constructor
33       * @param parent parent parser handler
34       */
35      public DisplayName(XMLParserHandler parent) {
36          super(parent);
37      }
38  
39      @Override
40      public Object end(Object current, String tag, String value) throws SAXException {
41          displayName = value;
42          return super.end(current, tag, value);
43      }
44  
45      /**
46       * Returns display name
47       * @return display name
48       */
49      public String getDisplayName() {
50          return displayName;
51      }
52  
53      /**
54       * Returns {@link org.abstracthorizon.danube.webdav.xml.dav.response.properties.DisplayName} if
55       * display name is available or just super value
56       * @param adpater adapter
57       * @param resource resource
58       * @return {@link org.abstracthorizon.danube.webdav.xml.dav.response.properties.DisplayName} if
59       */
60      public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
61          Object root = adapter.findParentResource(resource);
62          if ((root == null) || root.equals(resource)) {
63              return super.processResponse(adapter, resource);
64          } else {
65              return new org.abstracthorizon.danube.webdav.xml.dav.response.properties.DisplayName(adapter.getResourceName(resource));
66          }
67      }
68  
69      @Override
70      public String toString() {
71          return "DisplayName[" + displayName + "]";
72      }
73  }