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