[Clirr-devel] CVS: clirr/src/java/net/sf/clirr/event Message.java,1.1,1.2
Status: Alpha
Brought to you by:
lkuehne
From: Simon K. <s_k...@us...> - 2004-07-02 02:24:35
|
Update of /cvsroot/clirr/clirr/src/java/net/sf/clirr/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14103 Modified Files: Message.java Log Message: Provide alternative constructor that doesn't register the new Message object with the MessageManager [needed for unit testing]. Index: Message.java =================================================================== RCS file: /cvsroot/clirr/clirr/src/java/net/sf/clirr/event/Message.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Message.java 28 Jun 2004 06:51:21 -0000 1.1 +++ Message.java 2 Jul 2004 02:24:27 -0000 1.2 @@ -27,10 +27,36 @@ { private int id; + /** + * This constructor is equivalent to new Message(id, true). + */ public Message(int id) { + this(id, true); + } + + /** + * Create an instance of this object with the specified message id + * + * @param id is an integer which is used to look up the appropriate + * text string for this message from a resource file. The id of a + * message should be unique. + * + * @param register determines whether the new Message object should be + * registered with the central MessageManager object. This is normally + * desirable, as this allows the unit tests associated with clirr to + * verify that message ids are unique and that translations exist for + * all registered messages. However false can be useful in some + * circumstances, eg when creating Message objects for the purposes + * of unit tests. + */ + public Message(int id, boolean register) + { this.id = id; - MessageManager.getInstance().addMessage(this); + if (register) + { + MessageManager.getInstance().addMessage(this); + } } public int getId() |