01: ////////////////////////////////////////////////////////////////////////////////
02: // checkstyle: Checks Java source code for adherence to a set of rules.
03: // Copyright (C) 2001-2007 Oliver Burn
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU Lesser General Public
07: // License as published by the Free Software Foundation; either
08: // version 2.1 of the License, or (at your option) any later version.
09: //
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: package com.puppycrawl.tools.checkstyle.api;
20:
21: // TODO: check that this class is in the right package
22: // as soon as architecture has settled. At the time of writing
23: // this class is not necessary as a part of the public api
24:
25: import java.util.TreeSet;
26:
27: /**
28: * Collection of messages.
29: * @author Oliver Burn
30: * @version 1.0
31: */
32: public final class LocalizedMessages {
33: /** contains the messages logged **/
34: private final TreeSet mMessages = new TreeSet();
35:
36: /** @return the logged messages **/
37: public LocalizedMessage[] getMessages() {
38: return (LocalizedMessage[]) mMessages
39: .toArray(new LocalizedMessage[mMessages.size()]);
40: }
41:
42: /** Reset the object. **/
43: public void reset() {
44: mMessages.clear();
45: }
46:
47: /**
48: * Logs a message to be reported.
49: * @param aMsg the message to log
50: **/
51: public void add(LocalizedMessage aMsg) {
52: mMessages.add(aMsg);
53: }
54:
55: /** @return the number of messages */
56: public int size() {
57: return mMessages.size();
58: }
59: }
|