1 // Copyright (C) 2006 Philip Aston 2 // All rights reserved. 3 // 4 // This file is part of The Grinder software distribution. Refer to 5 // the file LICENSE which is part of The Grinder distribution for 6 // licensing details. The Grinder distribution is available on the 7 // Internet at http://grinder.sourceforge.net/ 8 // 9 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 10 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 11 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 12 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 13 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 14 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 15 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 16 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 17 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 18 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 19 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 20 // OF THE POSSIBILITY OF SUCH DAMAGE. 21 22 package net.grinder.statistics; 23 24 25 /** 26 * Read-only view of a statistics set, see {@link StatisticsSet}. 27 * 28 * @author Philip Aston 29 */ 30 public interface ImmutableStatisticsSet { 31 32 /** 33 * Clone this object. 34 * 35 * @return A copy of this StatisticsSet. 36 */ 37 StatisticsSet snapshot(); 38 39 /** 40 * Return the value specified by <code>index</code>. 41 * 42 * @param index The index. 43 * @return The value. 44 */ 45 long getValue(StatisticsIndexMap.LongIndex index); 46 47 /** 48 * Return the value specified by <code>index</code>. 49 * 50 * @param index The index. 51 * @return The value. 52 */ 53 double getValue(StatisticsIndexMap.DoubleIndex index); 54 55 /** 56 * Get the total sample value for the sample statistic specified by 57 * <code>index</code>. 58 * 59 * @param index The index. 60 * @return The sum. 61 */ 62 long getSum(StatisticsIndexMap.LongSampleIndex index); 63 64 /** 65 * Get the total sample value for the sample statistic specified by 66 * <code>index</code>. 67 * 68 * @param index The index. 69 * @return The sum. 70 */ 71 double getSum(StatisticsIndexMap.DoubleSampleIndex index); 72 73 /** 74 * Get the number of samples for the sample statistic specified by 75 * <code>index</code>. 76 * 77 * @param index The index. 78 * @return The count. 79 */ 80 long getCount(StatisticsIndexMap.SampleIndex index); 81 82 /** 83 * Get the sample variance for the sample statistic specified by 84 * <code>index</code>. 85 * 86 * @param index The index. 87 * @return The count. 88 */ 89 double getVariance(StatisticsIndexMap.SampleIndex index); 90 91 /** 92 * Return whether all the statistics are zero. This allows us to optimise 93 * cases where there's no information to be processed. 94 * 95 * <p> 96 * This method can return <code>false</code>, even if all of the statistics 97 * are zero; but if it returns <code>true</code> they are guaranteed to be 98 * zero. 99 * </p> 100 * 101 * @return <code>true</code> => all values are zero. 102 */ 103 boolean isZero(); 104 105 /** 106 * Return whether this statistics set has been marked as containing 107 * composite statistics. 108 * 109 * @return <code>true</code> => this statistics set contains composite 110 * statistics. 111 */ 112 boolean isComposite(); 113 }