View Javadoc

1   //////////////////////////////////////////////////////////////////////////////
2   // Clirr: compares two versions of a java library for binary compatibility
3   // Copyright (C) 2003 - 2005  Lars Kühne
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  //////////////////////////////////////////////////////////////////////////////
19  
20  package net.sf.clirr.core;
21  
22  /***
23   * Class which manages API Difference messages, including expanding message
24   * codes into strings and descriptions.
25   */
26  public final class Message
27  {
28      private int id;
29  
30      /***
31       * This constructor is equivalent to new Message(id, true).
32       */
33      public Message(int id)
34      {
35          this(id, true);
36      }
37  
38      /***
39       * Create an instance of this object with the specified message id
40       *
41       * @param id is an integer which is used to look up the appropriate
42       * text string for this message from a resource file. The id of a
43       * message should be unique.
44       *
45       * @param register determines whether the new Message object should be
46       * registered with the central MessageManager object. This is normally
47       * desirable, as this allows the unit tests associated with clirr to
48       * verify that message ids are unique and that translations exist for
49       * all registered messages. However false can be useful in some
50       * circumstances, eg when creating Message objects for the purposes
51       * of unit tests.
52       */
53      public Message(int id, boolean register)
54      {
55          this.id = id;
56          if (register)
57          {
58              MessageManager.getInstance().addMessage(this);
59          }
60      }
61  
62      public int getId()
63      {
64          return id;
65      }
66  
67      public String toString()
68      {
69          return "Message#" + id;
70      }
71  }