1 package org.seasar.cubby.validator;
2
3 import java.text.MessageFormat;
4 import java.util.MissingResourceException;
5
6 import org.seasar.cubby.util.Messages;
7
8
9
10
11
12
13 abstract public class BaseValidator implements Validator {
14
15
16
17
18 private String messageKey;
19
20
21
22
23
24 protected void setMessageKey(final String messageKey) {
25 this.messageKey = messageKey;
26 }
27
28
29
30
31
32
33 protected String getMessage(final Object... args) {
34 String message = Messages.getText(messageKey);
35 return MessageFormat.format(message, args);
36 }
37
38
39
40
41
42
43 protected String getPropertyMessage(final String key) {
44 try {
45 return Messages.getText(key);
46 } catch (MissingResourceException ex) {
47 return key;
48 }
49 }
50
51 }