01: /*
02: * Created on Nov 17, 2005
03: */
04: package uk.org.ponder.rsf.components;
05:
06: /** An output-only component that encapsulates the location data for a
07: * message as defined in a .properties file and resolved by a MessageLocator.
08: * This reference will be resolved at fixup time by the MessageFixer.
09: * @author Antranig Basman (antranig@caret.cam.ac.uk)
10: *
11: */
12: public class UIMessage extends UIBoundString {
13: public String[] messagekeys;
14: public Object[] arguments;
15:
16: /** Construct a "clustered" message component, suitable for being the label
17: * of a UILink or UICommand, etc.
18: */
19: public static UIMessage make(String messagekey) {
20: return make(messagekey, null);
21: }
22:
23: /** Constructs a "standalone" message component
24: * See {@link #make(String), #make(UIContainer, String, String[], Object[])
25: */
26:
27: public static UIMessage make(String messagekey, Object[] arguments) {
28: UIMessage togo = new UIMessage();
29: togo.messagekeys = new String[] { messagekey };
30: togo.arguments = arguments;
31: return togo;
32: }
33:
34: /** Constructs a "standalone" message component
35: * See {@link #make(String), #make(UIContainer, String, String[], Object[])
36: */
37:
38: private static UIMessage make(String[] messagekeys,
39: Object[] arguments) {
40: UIMessage togo = new UIMessage();
41: togo.messagekeys = messagekeys;
42: togo.arguments = arguments;
43: return togo;
44: }
45:
46: /** Construct a "standalone" message component suitable for appearing as
47: * a top-level label component in the component tree.
48: */
49:
50: public static UIMessage make(UIContainer parent, String ID,
51: String messagekey) {
52: return make(parent, ID, messagekey, null);
53: }
54:
55: /** Constructs a message component suitable for appearing as a top-level
56: * label component in the component tree, making use of more complex
57: * formatting. The arguments array is supplied as if to a standard
58: * Java
59: * <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html">MessageFormat</a>.
60: */
61: public static UIMessage make(UIContainer parent, String ID,
62: String messagekey, Object[] arguments) {
63: UIMessage togo = make(messagekey, arguments);
64: togo.ID = ID;
65: parent.addComponent(togo);
66: return togo;
67: }
68:
69: /** Constructs a top-level message component, supporting defaultible
70: * message fallback as in the Spring
71: * <a href="http://www.springframework.org/docs/api/org/springframework/context/MessageSourceResolvable.html">
72: * MessageSourceResolvable</a> interface.
73: * See {@link #make(UIContainer, String, String, Object[])}
74: */
75: public static UIMessage make(UIContainer parent, String ID,
76: String messagekeys[], Object[] arguments) {
77: UIMessage togo = make(messagekeys, arguments);
78: togo.ID = ID;
79: parent.addComponent(togo);
80: return togo;
81: }
82:
83: }
|