001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2014  Oliver Burn
004//
005// This library is free software; you can redistribute it and/or
006// modify it under the terms of the GNU Lesser General Public
007// License as published by the Free Software Foundation; either
008// version 2.1 of the License, or (at your option) any later version.
009//
010// This library is distributed in the hope that it will be useful,
011// but WITHOUT ANY WARRANTY; without even the implied warranty of
012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013// Lesser General Public License for more details.
014//
015// You should have received a copy of the GNU Lesser General Public
016// License along with this library; if not, write to the Free Software
017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018////////////////////////////////////////////////////////////////////////////////
019package com.puppycrawl.tools.checkstyle.api;
020
021// TODO: check that this class is in the right package
022// as soon as architecture has settled. At the time of writing
023// this class is not necessary as a part of the public api
024
025import com.google.common.collect.Sets;
026import java.util.TreeSet;
027
028/**
029 * Collection of messages.
030 * @author Oliver Burn
031 * @version 1.0
032 */
033public final class LocalizedMessages
034{
035    /** contains the messages logged **/
036    private final TreeSet<LocalizedMessage> messages = Sets.newTreeSet();
037
038    /** @return the logged messages **/
039    public TreeSet<LocalizedMessage> getMessages()
040    {
041        return Sets.newTreeSet(messages);
042    }
043
044    /** Reset the object. **/
045    public void reset()
046    {
047        messages.clear();
048    }
049
050    /**
051     * Logs a message to be reported.
052     * @param aMsg the message to log
053     **/
054    public void add(LocalizedMessage aMsg)
055    {
056        messages.add(aMsg);
057    }
058
059    /** @return the number of messages */
060    public int size()
061    {
062        return messages.size();
063    }
064}