KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > form > config > MappingConfig


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.controller.form.config;
8
9
10 import java.net.URISyntaxException JavaDoc;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13
14 import com.inversoft.verge.mvc.config.BaseConfig;
15 import com.inversoft.verge.mvc.controller.GenericResult;
16 import com.inversoft.verge.mvc.controller.Result;
17
18
19 /**
20  * This class stores an Mapping configuration.
21  *
22  * @author Brian Pontarelli
23  * @since 2.0
24  * @version 2.0
25  */

26 public class MappingConfig extends BaseConfig implements Result {
27
28     private GenericResult result;
29
30
31     /**
32      * Constructs a new Mapping configuration object with the given name, URL
33      * and forward flag that determines if this Mapping is a forward or a
34      * redirect.
35      *
36      * @param name The name of the mapping
37      * @param url The URL of the mapping
38      * @param forward The forward flag
39      * @asserts If the url is null
40      */

41     public MappingConfig(String JavaDoc name, String JavaDoc url, boolean forward, String JavaDoc category) {
42         super(name);
43
44         assert (url != null) : "url == null";
45         result = new GenericResult(url, category, forward);
46     }
47
48
49     /**
50      * Returns the value of the url for this Mapping
51      *
52      * @return The value of the url
53      */

54     public String JavaDoc getURL() {
55         return result.getURL();
56     }
57
58     /**
59      * Returns whether or not this Mapping is a forward or a redirect
60      *
61      * @return Whether this Mapping is a forward or a redirect
62      */

63     public boolean isForward() {
64         return result.isForward();
65     }
66
67     /**
68      * Returns the URL category used to construct the URL of this Mapping. This
69      * category must be a defined category for use by the {@link
70      * com.inversoft.verge.util.url.URLGenerator URLGenerator} class.
71      *
72      * @return The category
73      */

74     public String JavaDoc getCategory() {
75         return result.getCategory();
76     }
77
78     /**
79      * Returns the value of the url for this Mapping after applying the category
80      * if any. If the Mapping is not a forward, this simply returns the URL as
81      * is.
82      *
83      * @return The fully generated URL
84      */

85     public String JavaDoc getGeneratedURL(HttpServletRequest JavaDoc request)
86     throws URISyntaxException JavaDoc {
87         return result.getGeneratedURL(request);
88     }
89 }
Popular Tags