View Javadoc

1   /*--
2    Copyright (C) 2005 Tim Solley.
3    All rights reserved.
4   
5    Redistribution and use in source and binary forms, with or without
6    modification, are permitted provided that the following conditions
7    are met:
8   
9    1. Redistributions of source code must retain the above copyright
10   notice, this list of conditions, and the following disclaimer.
11  
12   2. Redistributions in binary form must reproduce the above copyright
13   notice, this list of conditions, and the disclaimer that follows
14   these conditions in the documentation and/or other materials
15   provided with the distribution.
16  
17   3. The name "Deadbolt" may be used to endorse or promote products
18   derived from this software without prior written permission.
19  
20   4. Products derived from this software may not be called "Deadbolt", nor
21   may "Deadbolt" appear in their name, without prior written permission
22   from the Deadbolt Project Management timsolley@yahoo.com.
23  
24   In addition, we request (but do not require) that you include in the
25   end-user documentation provided with the redistribution and/or in the
26   software itself an acknowledgement equivalent to the following:
27   "This product includes software developed by the
28   Deadbolt Project (http://deadbolt.sourceforge.net/)."
29   Alternatively, the acknowledgment may be graphical using the logos
30   available at http://deadbolt.sourceforge.net.
31  
32   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
33   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35   DISCLAIMED.  IN NO EVENT SHALL THE DEADBOLT AUTHORS OR THE PROJECT
36   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43   SUCH DAMAGE.
44  
45   This software consists of voluntary contributions made by many
46   individuals on behalf of the Deadbolt Project and was originally
47   created by Tim Solley timsolley@yahoo.com.  For more information
48   on the Deadbolt Project, please see <http://deadbolt.sourceforge.net/>.
49   */
50  
51  package net.sf.deadbolt.model;
52  
53  import java.util.Map;
54  import java.util.TreeMap;
55  
56  /***
57   * This class is a value object that contains information about a Room. This
58   * includes information such as the list of Handlers, the error page, and any
59   * initial parameters.
60   * 
61   * @author Tim Solley <timsolley@yahoo.com>
62   */
63  public class Room {
64      private TreeMap handlers;
65  
66      private String errorPage;
67  
68      private Map initParams;
69  
70      /***
71       * @return Returns the initParams.
72       */
73      public Map getInitParams() {
74          return initParams;
75      }
76  
77      /***
78       * @param initParams
79       *            The initParams to set.
80       */
81      public void setInitParams(Map initParams) {
82          this.initParams = initParams;
83      }
84  
85      /***
86       * @return Returns the errorPage.
87       */
88      public String getErrorPage() {
89          return errorPage;
90      }
91  
92      /***
93       * @param errorPage
94       *            The errorPage to set.
95       */
96      public void setErrorPage(String errorPage) {
97          this.errorPage = errorPage;
98      }
99  
100     /***
101      * @return Returns the handler.
102      */
103     public TreeMap getHandlers() {
104         return handlers;
105     }
106 
107     /***
108      * @param handler
109      *            The handler to set.
110      */
111     public void setHandler(TreeMap handlers) {
112         this.handlers = handlers;
113     }
114     
115     /***
116      * 
117      * @param key
118      * @return
119      */
120     public String getInitParam(String key) {
121         return (String) initParams.get(key);
122     }
123     
124     /***
125      * Returns whether an initial parameter with this name exists.  Useful for
126      * checking params in your handlers.
127      * @param key
128      * @return
129      */
130     public boolean initParamExists(String key) {
131         if(initParams.get(key) == null) {
132             return false;
133         } else {
134             return true;
135         }
136     }
137 }