KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > web > ActionResultFactory


1 /*
2  * $Id: ActionResultFactory.java,v 1.3 2004/12/26 00:26:17 michelson Exp $
3  *
4  * Copyright (c) 2004 j2biz Group, http://www.j2biz.com Koeln / Duesseldorf ,
5  * Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation; either version 2 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  * Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.web;
27
28 import com.j2biz.blogunity.i18n.I18N;
29 import com.j2biz.blogunity.i18n.I18NMessageManager;
30
31 public class ActionResultFactory {
32
33     public static IActionResult buildForward(String JavaDoc path) {
34         return new ForwardImpl(path);
35     }
36
37     public static IActionResult buildInclude(String JavaDoc path) {
38         return new IncludeImpl(path);
39     }
40
41     public static IActionResult buildRedirect(String JavaDoc path) {
42         return new RedirectImpl(path);
43     }
44
45     public static IActionResult buildForward(String JavaDoc i18nKey, String JavaDoc path) {
46         return new ForwardImpl(i18nKey, path);
47     }
48
49     public static IActionResult buildInclude(String JavaDoc i18nKey, String JavaDoc path) {
50         return new IncludeImpl(i18nKey, path);
51     }
52
53     public static IActionResult buildRedirect(String JavaDoc i18nKey, String JavaDoc path) {
54         return new RedirectImpl(i18nKey, path);
55     }
56
57     private static abstract class AbstractActionResultImpl implements IActionResult {
58
59         private String JavaDoc path;
60
61         private String JavaDoc i18nKey = I18N.MESSAGES.UNKNOWN;
62
63         public AbstractActionResultImpl(String JavaDoc path) {
64             this.path = path;
65         }
66
67         public AbstractActionResultImpl(String JavaDoc i18nKey, String JavaDoc path) {
68             this.path = path;
69             this.i18nKey = i18nKey;
70         }
71
72         /*
73          * (non-Javadoc)
74          *
75          * @see com.j2biz.blogunity.web.IActionResult#getPath()
76          */

77         public String JavaDoc getPath() {
78             return path;
79         }
80
81         /*
82          * (non-Javadoc)
83          *
84          * @see com.j2biz.blogunity.web.IActionResult#getKey()
85          */

86         public String JavaDoc getKey() {
87             return i18nKey;
88         }
89
90         /*
91          * (non-Javadoc)
92          *
93          * @see com.j2biz.blogunity.web.IActionResult#getValue()
94          */

95         public String JavaDoc getValue() {
96             return I18NMessageManager.getInstance().getNavigationText(i18nKey);
97         }
98
99     }
100
101     private static class ForwardImpl extends AbstractActionResultImpl {
102
103         public ForwardImpl(String JavaDoc path) {
104             super(path);
105         }
106
107         public ForwardImpl(String JavaDoc i18nKey, String JavaDoc path) {
108             super(i18nKey, path);
109         }
110
111         public int getType() {
112             return FORWARD;
113         }
114
115     }
116
117     private static class IncludeImpl extends AbstractActionResultImpl {
118
119         public IncludeImpl(String JavaDoc path) {
120             super(path);
121         }
122
123         public IncludeImpl(String JavaDoc i18nKey, String JavaDoc path) {
124             super(i18nKey, path);
125         }
126
127         public int getType() {
128             return INCLUDE;
129         }
130
131     }
132
133     private static class RedirectImpl extends AbstractActionResultImpl {
134
135         public RedirectImpl(String JavaDoc path) {
136             super(path);
137         }
138
139         public RedirectImpl(String JavaDoc i18nKey, String JavaDoc path) {
140             super(i18nKey, path);
141         }
142
143         public int getType() {
144             return REDIRECT;
145         }
146
147     }
148 }
Popular Tags