1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.decoration;
18
19 import java.io.Serializable;
20 import java.util.Locale;
21 import java.util.MissingResourceException;
22 import java.util.ResourceBundle;
23
24 /***
25 * DecoratorAction
26 *
27 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
28 * @version $Id: DecoratorAction.java 554461 2007-07-08 22:45:49Z ate $
29 */
30 public class DecoratorAction implements Serializable
31 {
32 public static final String RESOURCE_BUNDLE = "org.apache.jetspeed.decoration.resources.DecoratorActions";
33
34 String actionName = null;
35 String actionType = null;
36 String name = null;
37 String link = null;
38 String alt = null;
39 String action = null;
40 String target;
41 boolean custom;
42
43 public static ResourceBundle getResourceBundle(Locale locale)
44 {
45 return getBundle(RESOURCE_BUNDLE, locale);
46 }
47
48 private static ResourceBundle getBundle(String base, Locale locale)
49 {
50 ResourceBundle bundle = null;
51 try
52 {
53 if ( locale != null )
54 {
55 bundle = ResourceBundle.getBundle(base, locale);
56 }
57 else
58 {
59 bundle = ResourceBundle.getBundle(base);
60 }
61 }
62 catch (MissingResourceException mre)
63 {
64 }
65 return bundle;
66 }
67
68 public static String getResourceString(ResourceBundle bundle, String key, String defaultValue)
69 {
70 String value = defaultValue;
71
72 if ( key != null && bundle != null )
73 try
74 {
75 value = bundle.getString(key);
76 }
77 catch (MissingResourceException mre)
78 {
79 }
80 return value;
81 }
82
83 public DecoratorAction(String actionName, String name, String alt, Locale locale, String link, String action, boolean custom, String actionType)
84 {
85 ResourceBundle bundle = getBundle(RESOURCE_BUNDLE, locale);
86 this.actionName = actionName;
87 this.actionType = actionType;
88 this.name = getResourceString(bundle,name,name);
89 this.alt = getResourceString(bundle,alt,alt);
90 this.link = link;
91 this.action = action;
92 this.custom = custom;
93 }
94
95 public DecoratorAction(String actionName, String name, String alt, String link, String action, boolean custom, String actionType)
96 {
97 this.actionName = actionName;
98 this.actionType = actionType;
99 this.name = name;
100 this.alt = alt;
101 this.link = link;
102 this.action = action;
103 this.custom = custom;
104 }
105
106 public DecoratorAction(String name, Locale locale, String link, String action, boolean custom, String actionType)
107 {
108 this(name,name,name,locale,link,action,custom,actionType);
109 }
110
111 public DecoratorAction(String name, Locale locale, String link, String action, String actionType)
112 {
113 this(name,name,name,locale,link,action,false,actionType);
114 }
115
116 public DecoratorAction(String actionName, String name, String alt, String link, String actionType)
117 {
118 this(actionName, name,alt,null,link,null,false,actionType);
119 }
120
121 public String getActionName()
122 {
123 return this.actionName;
124 }
125 public void setActionName( String actionName )
126 {
127 this.actionName = actionName;
128 }
129
130 public String getActionType()
131 {
132 return this.actionType;
133 }
134 public void setActionType( String actionType )
135 {
136 this.actionType = actionType;
137 }
138
139 public String getName()
140 {
141 return this.name;
142 }
143
144 public void setName(String name)
145 {
146 this.name = name;
147 }
148
149 public String getLink()
150 {
151 return this.link;
152 }
153
154 public void setLink(String link)
155 {
156 this.link = link;
157 }
158
159 public String getAlt()
160 {
161 return this.alt;
162 }
163
164 public void setAlt(String alt)
165 {
166 this.alt = alt;
167 }
168
169 public String getAction()
170 {
171 return this.action;
172 }
173
174 public void setAction(String action)
175 {
176 this.action = action;
177 }
178
179 public String getTarget()
180 {
181 return this.target;
182 }
183
184 public void setTarget(String target)
185 {
186 this.target = target;
187 }
188
189 public boolean isCustom()
190 {
191 return custom;
192 }
193
194 public void setCustom(boolean custom)
195 {
196 this.custom = custom;
197 }
198 }