KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > server > RequestImpl


1
2 /*
3  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
4  * [See end of file]
5  */

6
7
8 package org.joseki.server;
9
10
11 import java.util.* ;
12
13 /** General pupose implementation of an operation.
14  * provides methods to create the operation as well as meet
15  * the Request interface.
16  * @author Andy Seaborne
17  * @version $Id: RequestImpl.java,v 1.5 2004/04/30 14:13:13 andy_seaborne Exp $
18  */

19 public class RequestImpl implements Request
20 {
21     // Where and how the operation will be performed
22
Processor processor ;
23     ModelSource modelSource ;
24     Dispatcher dispatcher ;
25     
26     // How the operation was described.
27
String JavaDoc opName = null;
28     String JavaDoc modelURI = null ;
29     String JavaDoc requestURL = null ;
30
31     final static Object JavaDoc noValue = new Object JavaDoc() ;
32     // Arguments - models
33
// Parameters - key/value pairs
34
List args = new ArrayList();
35     Map params = new HashMap();
36
37     public RequestImpl(String JavaDoc u, String JavaDoc url, String JavaDoc name, Dispatcher d, ModelSource aModel, Processor proc)
38     {
39         modelURI = u ;
40         requestURL = url ;
41         opName = name ;
42         dispatcher = d ;
43         modelSource = aModel ;
44         processor = proc ;
45     }
46
47     public boolean takesArg() { return true ; }
48     
49     public boolean containsParam(String JavaDoc name) { return params.containsKey(name) ; }
50     
51     public void setParam(String JavaDoc name, String JavaDoc value)
52     {
53         if ( value == null )
54             params.put(name, noValue) ;
55         else
56             params.put(name, value) ;
57     }
58     
59     public void addArg(Object JavaDoc m) { args.add(m) ; }
60
61     public String JavaDoc getName() { return opName ; }
62     public String JavaDoc getModelURI() { return modelURI ; }
63     public String JavaDoc getRequestURL() { return requestURL ; }
64
65     public ModelSource getModelSource() { return modelSource ; }
66     public Processor getProcessor() { return processor ; }
67     public void setProcessor(Processor proc) { processor = proc ; }
68     public Dispatcher getDispatcher() { return dispatcher ; }
69
70     public Map getParams() { return params ; }
71     public String JavaDoc getParam(String JavaDoc param) { return (String JavaDoc)params.get(param); }
72     
73     public List getDataArgs() { return args ; }
74 }
75
76 /*
77  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
78  * All rights reserved.
79  *
80  * Redistribution and use in source and binary forms, with or without
81  * modification, are permitted provided that the following conditions
82  * are met:
83  * 1. Redistributions of source code must retain the above copyright
84  * notice, this list of conditions and the following disclaimer.
85  * 2. Redistributions in binary form must reproduce the above copyright
86  * notice, this list of conditions and the following disclaimer in the
87  * documentation and/or other materials provided with the distribution.
88  * 3. The name of the author may not be used to endorse or promote products
89  * derived from this software without specific prior written permission.
90  *
91  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
92  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
93  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
94  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
95  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
96  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
97  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
98  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
99  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
100  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101  */

102
Popular Tags