001    /**
002     * Copyright (c) 2000-2010 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 BaseStatistics implements Statistics {
022    
023            public BaseStatistics(String name) {
024                    _name = name;
025                    _startTime = System.currentTimeMillis();
026            }
027    
028            public String getDescription() {
029                    return _description;
030            }
031    
032            public long getLastSampleTime() {
033                    return _lastSampleTime;
034            }
035    
036            public long getLastTime() {
037                    return _lastTime;
038            }
039    
040            public long getLowerBound() {
041                    return _lowerBound;
042            }
043    
044            public long getMaxTime() {
045                    return _maxTime;
046            }
047    
048            public long getMinTime() {
049                    return _minTime;
050            }
051    
052            public String getName() {
053                    return _name;
054            }
055    
056            public long getStartTime() {
057                    return _startTime;
058            }
059    
060            public long getUpperBound() {
061                    return _upperBound;
062            }
063    
064            public long getUptime() {
065                    return System.currentTimeMillis() - _startTime;
066            }
067    
068            public void reset() {
069                    _maxTime = 0;
070                    _minTime = 0;
071                    _lastTime = 0;
072                    _startTime = System.currentTimeMillis();
073                    _lastSampleTime = _startTime;
074            }
075    
076            public void setDescription(String description) {
077                    _description = description;
078            }
079    
080            public void setLastSampleTime(long lastSampleTime) {
081                    _lastSampleTime = lastSampleTime;
082            }
083    
084            public void setLastTime(long lastTime) {
085                    _lastTime = lastTime;
086            }
087    
088            public void setLowerBound(long lowerBound) {
089                    _lowerBound = lowerBound;
090            }
091    
092            public void setMaxTime(long maxTime) {
093                    _maxTime = maxTime;
094            }
095    
096            public void setMinTime(long minTime) {
097                    _minTime = minTime;
098            }
099    
100            public void setStartTime(long startTime) {
101                    _startTime = startTime;
102            }
103    
104            public void setUpperBound(long upperBound) {
105                    _upperBound = upperBound;
106            }
107    
108            private String _description;
109            private long _lastSampleTime;
110            private long _lastTime;
111            private long _lowerBound;
112            private long _maxTime;
113            private long _minTime;
114            private String _name;
115            private long _startTime;
116            private long _upperBound;
117    
118    }