01: package com.calipso.reportgenerator.reportcalculator;
02:
03: import java.io.Serializable;
04: import java.util.HashMap;
05:
06: /**
07: * Administra las instancias de Integer
08: */
09:
10: public class SharedInteger extends SharedData implements Serializable,
11: Comparable, CubeValue {
12:
13: private Integer value;
14: static final private HashMap integers = new HashMap(5003, 0.80f);
15:
16: public SharedInteger(Integer value) {
17: this .value = value;
18: integers.put(value, this );
19: }
20:
21: public static SharedInteger newFrom(Integer integer) {
22: Object o = integers.get(integer);
23: if (o == null) {
24: return new SharedInteger(integer);
25: } else {
26: return (SharedInteger) o;
27: }
28: }
29:
30: public String toString() {
31: return value.toString();
32: }
33:
34: public int intValue() {
35: return value.intValue();
36: }
37:
38: public int compareTo(Object o) {
39: return value.compareTo(((SharedInteger) o).value);
40: }
41:
42: public Object getValue() {
43: return value;
44: }
45: }
|