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 java.util.Locale;
20  
21  import org.xml.sax.SAXException;
22  
23  /**
24   * This class models WebDAV's getcontentlanguage tag
25   *
26   * @author Daniel Sendula
27   */
28  public class GetContentLanguage extends RequestProperty {
29  
30      /** Cached local content language */
31      protected static String cachedContentLanguage = Locale.getDefault().getLanguage();
32  
33      /** Content language */
34      protected String contentLanguage;
35  
36      /**
37       * Constructor
38       * @param parent parent parser handler
39       */
40      public GetContentLanguage(XMLParserHandler parent) {
41          super(parent);
42      }
43  
44      @Override
45      public Object end(Object current, String tag, String value) throws SAXException {
46          contentLanguage = value;
47          return super.end(current, tag, value);
48      }
49  
50      /**
51       * Returns content language
52       * @return content language
53       */
54      public String getContentLanguage() {
55          return contentLanguage;
56      }
57  
58      /**
59       * Returns {@link org.abstracthorizon.danube.webdav.xml.dav.response.properties.GetContentLanguage}
60       * @param adapter adapter
61       * @param resource resource
62       * @return {@link org.abstracthorizon.danube.webdav.xml.dav.response.properties.GetContentLanguage}
63       */
64      public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
65          return new org.abstracthorizon.danube.webdav.xml.dav.response.properties.GetContentLanguage(cachedContentLanguage);
66      }
67  
68      @Override
69      public String toString() {
70          return "GetContentLanguage[" + contentLanguage + "]";
71      }
72  }