View Javadoc

1   /**
2    * Copyright (c) 2012, University of Konstanz, Distributed Systems Group
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    * * Redistributions of source code must retain the above copyright
8    * notice, this list of conditions and the following disclaimer.
9    * * Redistributions in binary form must reproduce the above copyright
10   * notice, this list of conditions and the following disclaimer in the
11   * documentation and/or other materials provided with the distribution.
12   * * Neither the name of the University of Konstanz nor the
13   * names of its contributors may be used to endorse or promote products
14   * derived from this software without specific prior written permission.
15   * 
16   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19   * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20   * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26   */
27  package org.perfidix.meter;
28  
29  /**
30   * Small enum to store the different kinds of memories.
31   * 
32   * @author Sebastian Graf, University of Konstanz
33   */
34  public enum Memory {
35  
36      /** Enum for byte. */
37      Byte("B", "byte", 1),
38      /** Enum for KibiByte. */
39      KibiByte("KiB", "kibiByte", 1024),
40      /** Enum for MebiByte. */
41      Mebibyte("MiB", "mebibyte", 1048576);
42  
43      /**
44       * The unit of one size.
45       */
46      private final String unit;
47  
48      /**
49       * The description of one size.
50       */
51      private final String unitDescription;
52  
53      /**
54       * Number of bytes.
55       */
56      private final double numberOfBytes;
57  
58      /**
59       * The constructor for the memory sizes.
60       * 
61       * @param paramUnit
62       *            to give
63       * @param paramUnitDesc
64       *            to give
65       * @param paramBytes
66       *            to give
67       */
68      private Memory(final String paramUnit, final String paramUnitDesc, final int paramBytes) {
69          unit = paramUnit;
70          unitDescription = paramUnitDesc;
71          numberOfBytes = paramBytes;
72      }
73  
74      /**
75       * Getting the number of bytes.
76       * 
77       * @return the number of bytes
78       */
79      public double getNumberOfBytes() {
80          return numberOfBytes;
81      }
82  
83      /**
84       * Getting the unit.
85       * 
86       * @return the unit
87       */
88      public String getUnit() {
89          return unit;
90      }
91  
92      /**
93       * Getting the full unitname.
94       * 
95       * @return the full unitname
96       */
97      public String getUnitDescription() {
98          return unitDescription;
99      }
100 
101 }