KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > webdav > SearchRequestFactory


1 /*
2  * (C) Copyright Simulacra Media Ltd, 2004. All rights reserved.
3  *
4  * The program is provided "AS IS" without any warranty express or
5  * implied, including the warranty of non-infringement and the implied
6  * warranties of merchantibility and fitness for a particular purpose.
7  * Simulacra Media Ltd will not be liable for any damages suffered by you as a result
8  * of using the Program. In no event will Simulacra Media Ltd be liable for any
9  * special, indirect or consequential damages or lost profits even if
10  * Simulacra Media Ltd has been advised of the possibility of their occurrence.
11  * Simulacra Media Ltd will not be liable for any third party claims against you.
12  *
13  */

14
15 package com.ibm.webdav;
16
17 import java.util.logging.*;
18
19 import org.w3c.dom.Element JavaDoc;
20
21 import com.ibm.webdav.basicsearch.BasicSearchRequest;
22
23
24 /**
25  * @author Michael Bell
26  * @version 1.0
27  */

28 public class SearchRequestFactory {
29     
30     /**
31      * Logger for this class
32      */

33     private static final Logger m_logger = Logger.getLogger(SearchRequestFactory.class.getName());
34     
35     public SearchRequestFactory() {
36     }
37
38     public static SearchRequest getSearchRequest(Element JavaDoc xmlElement)
39                                           throws WebDAVException {
40         SearchRequest request = null;
41
42         try {
43             if (xmlElement.getNamespaceURI().equals("DAV:") &&
44                     xmlElement.getLocalName()
45                               .equals(BasicSearchRequest.TAG_BASICSEARCH)) {
46                 request = new BasicSearchRequest();
47
48                 request.instantiateFromXML(xmlElement);
49             }
50         } catch (WebDAVException e) {
51             throw e;
52         } catch (Exception JavaDoc e) {
53             m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
54             throw new WebDAVException(WebDAVStatus.SC_INTERNAL_SERVER_ERROR,
55                                       e.getMessage());
56         }
57
58         return request;
59     }
60 }
Popular Tags