1 16 17 package org.apache.velocity.tools.struts; 18 19 import java.util.List ; 20 import java.util.Locale ; 21 import org.apache.struts.util.MessageResources; 22 23 47 public class MessageTool extends MessageResourcesTool 48 { 49 50 53 public MessageTool() 54 {} 55 56 57 67 public String get(String key) 68 { 69 return get(key, (Object [])null); 70 } 71 72 84 public String get(String key, String bundle) 85 { 86 return get(key, bundle, (Object [])null); 87 } 88 89 90 102 public String get(String key, Object args[]) 103 { 104 return get(key, null, args); 105 } 106 107 120 public String get(String key, String bundle, Object args[]) 121 { 122 MessageResources res = getResources(bundle); 123 if (res == null) 124 { 125 return null; 126 } 127 128 if (args == null) 130 { 131 return res.getMessage(this.locale, key); 132 } 133 else 134 { 135 return res.getMessage(this.locale, key, args); 136 } 137 } 138 139 150 public String get(String key, List args) 151 { 152 return get(key, args.toArray()); 153 } 154 155 167 public String get(String key, String bundle, List args) 168 { 169 return get(key, bundle, args.toArray()); 170 } 171 172 173 182 public boolean exists(String key) 183 { 184 return exists(key, null); 185 } 186 187 197 public boolean exists(String key, String bundle) 198 { 199 MessageResources res = getResources(bundle); 200 if (res == null) 201 { 202 return false; 203 } 204 205 return res.isPresent(this.locale, key); 207 } 208 209 210 216 public Locale getLocale() 217 { 218 return this.locale; 219 } 220 221 } 222 | Popular Tags |