001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.monitoring.statistics;
016    
017    /**
018     * @author Rajesh Thiagarajan
019     * @author Brian Wing Shun Chan
020     */
021    public class CountStatistics extends BaseStatistics {
022    
023            public CountStatistics(String name) {
024                    super(name);
025            }
026    
027            public void decrementCount() {
028                    _count--;
029    
030                    setLastSampleTime(System.currentTimeMillis());
031            }
032    
033            public long getCount() {
034                    return _count;
035            }
036    
037            public void incrementCount() {
038                    _count++;
039    
040                    setLastSampleTime(System.currentTimeMillis());
041            }
042    
043            public void reset() {
044                    super.reset();
045    
046                    _count = 0;
047            }
048    
049            public void setCount(long count) {
050                    _count = count;
051    
052                    setLastSampleTime(System.currentTimeMillis());
053            }
054    
055            private long _count;
056    
057    }