1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.action;
17
18 import org.seasar.cubby.util.Messages;
19
20
21
22
23
24
25 public class MessageInfo {
26
27
28 private String key;
29
30
31 private Object[] arguments;
32
33
34
35
36
37
38 public String getKey() {
39 return key;
40 }
41
42
43
44
45
46
47
48 public void setKey(final String key) {
49 this.key = key;
50 }
51
52
53
54
55
56
57 public Object[] getArguments() {
58 if (arguments == null) {
59 return null;
60 }
61 return arguments.clone();
62 }
63
64
65
66
67
68
69
70 public void setArguments(final Object... arguments) {
71 final Object[] copyArguments = new Object[arguments.length];
72 System.arraycopy(arguments, 0, copyArguments, 0, arguments.length);
73 this.arguments = copyArguments;
74 }
75
76
77
78
79
80
81
82
83 public String toMessage(final String fieldNameKey) {
84 final Object[] args;
85 if (fieldNameKey != null) {
86 if (this.arguments != null) {
87 args = new Object[this.arguments.length + 1];
88 final String paramNameText = Messages.getText(fieldNameKey);
89 args[0] = paramNameText;
90 System.arraycopy(this.arguments, 0, args, 1,
91 this.arguments.length);
92 } else {
93 args = new Object[] { Messages.getText(fieldNameKey) };
94 }
95 } else {
96 args = this.arguments;
97 }
98 return Messages.getText(key, args);
99 }
100
101 }