KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > ServerURL


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server;
10
11 import org.apache.log4j.Logger;
12 import org.jboss.portal.server.util.Parameters;
13
14 /**
15  * Define an URL at the server level with the concept of
16  * control parameters.
17  *
18  * todo : perhaps introduce the generic notion of scope, to allow more different scoping ?
19  *
20  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
21  * @version $Revision: 1.4 $
22  */

23 public class ServerURL
24 {
25
26    /** Logger accessible by subclasses. */
27    protected static final Logger log = Logger.getLogger(ServerURL.class);
28
29    /** The target of this URL. */
30    protected final ServerObjectID target;
31
32    /** Control scoped parameters. */
33    protected final Parameters controlParameters;
34
35    /** Target scoped parameters. */
36    protected final Parameters targetParameters;
37
38    /** Do we requet secure or not. */
39    protected Boolean JavaDoc secure;
40
41    public ServerURL(ServerObjectID target)
42    {
43       this(target, new Parameters(), new Parameters(), null);
44    }
45
46    private ServerURL(ServerObjectID target, Parameters controlParameters, Parameters targetParameters, Boolean JavaDoc secure)
47    {
48       this.target = target;
49       this.controlParameters = controlParameters;
50       this.targetParameters = targetParameters;
51       this.secure = secure;
52    }
53
54    /**
55     * Return the target or null if there is no target.
56     */

57    public ServerObjectID getTarget()
58    {
59       return target;
60    }
61
62    /**
63     * Set the URL secure or not.
64     *
65     * @param secure true if the URL must be secure
66     */

67    public void setSecure(Boolean JavaDoc secure)
68    {
69       this.secure = secure;
70    }
71
72    /**
73     * Returns wether the URL is secure or not.
74     *
75     * @return true if the URL is secure
76     */

77    public Boolean JavaDoc getSecure()
78    {
79       return secure;
80    }
81
82    /**
83     * Set the control scoped parameter.
84     * If the value is null it clears the parameter.
85     *
86     * @param name the parameter name.
87     * @param value the parameter value.
88     * @throws IllegalArgumentException if the name is null
89     */

90    public void setControlParameter(String JavaDoc name, String JavaDoc value)
91    {
92       if (value != null)
93       {
94          controlParameters.setParameter(name, value);
95       }
96       else
97       {
98          controlParameters.removeParameter(name);
99       }
100    }
101
102    /**
103     * @see #setControlParameter(String, String)
104     * @param name the parameter name.
105     * @param values the parameter values.
106     * @throws IllegalArgumentException if the name is null
107     */

108    public void setControlParameter(String JavaDoc name, String JavaDoc[] values)
109    {
110       if (values != null)
111       {
112          controlParameters.setParameterValues(name, values);
113       }
114       else
115       {
116          controlParameters.removeParameter(name);
117       }
118    }
119
120    /**
121     * Return the control scoped parameters.
122     */

123    public Parameters getControlParameters()
124    {
125       return controlParameters;
126    }
127
128    /**
129     * Set the target scoped parameter.
130     * If the value is null it clears the parameter.
131     *
132     * @param name the parameter name.
133     * @param value the parameter value.
134     * @throws IllegalArgumentException if the name is null
135     */

136    public void setTargetParameter(String JavaDoc name, String JavaDoc value)
137    {
138       if (value != null)
139       {
140          targetParameters.setParameter(name, value);
141       }
142       else
143       {
144          targetParameters.removeParameter(name);
145       }
146    }
147
148    /**
149     * @see #setTargetParameter(String, String)
150     * @param name the parameter name.
151     * @param values the parameter values.
152     * @throws IllegalArgumentException if the name is null
153     */

154    public void setTargetParameter(String JavaDoc name, String JavaDoc[] values)
155    {
156       if (values != null)
157       {
158          targetParameters.setParameterValues(name, values);
159       }
160       else
161       {
162          targetParameters.removeParameter(name);
163       }
164    }
165
166    /**
167     * Return the target scoped parameters.
168     */

169    public Parameters getTargetParameters()
170    {
171       return targetParameters;
172    }
173    
174    /**
175     * Return true if the URL is idempotent.
176     */

177    public boolean isIdempotent()
178    {
179       return true;
180    }
181 }
182
Popular Tags