1 package com.calipso.reportgenerator.reportcalculator; 2 3 import java.io.Serializable ; 4 import java.util.HashMap ; 5 6 9 10 public class SharedInteger extends SharedData implements Serializable , Comparable , CubeValue { 11 12 private Integer value; 13 static final private HashMap integers = new HashMap (5003, 0.80f); 14 15 public SharedInteger(Integer value) { 16 this.value = value; 17 integers.put(value, this); 18 } 19 20 public static SharedInteger newFrom(Integer integer) { 21 Object o = integers.get(integer); 22 if(o == null) { 23 return new SharedInteger(integer); 24 } else { 25 return (SharedInteger) o; 26 } 27 } 28 29 public String toString() { 30 return value.toString(); 31 } 32 33 public int intValue() { 34 return value.intValue(); 35 } 36 37 public int compareTo(Object o) { 38 return value.compareTo(((SharedInteger)o).value); 39 } 40 41 public Object getValue() { 42 return value; 43 } 44 } 45 | Popular Tags |