KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > SharedInteger


1 package com.calipso.reportgenerator.reportcalculator;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.HashMap JavaDoc;
5
6 /**
7  * Administra las instancias de Integer
8  */

9
10 public class SharedInteger extends SharedData implements Serializable JavaDoc, Comparable JavaDoc, CubeValue {
11
12   private Integer JavaDoc value;
13   static final private HashMap JavaDoc integers = new HashMap JavaDoc(5003, 0.80f);
14
15   public SharedInteger(Integer JavaDoc value) {
16     this.value = value;
17     integers.put(value, this);
18   }
19
20   public static SharedInteger newFrom(Integer JavaDoc integer) {
21     Object JavaDoc 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 JavaDoc toString() {
30     return value.toString();
31   }
32
33   public int intValue() {
34     return value.intValue();
35   }
36
37   public int compareTo(Object JavaDoc o) {
38     return value.compareTo(((SharedInteger)o).value);
39   }
40
41   public Object JavaDoc getValue() {
42     return value;
43   }
44 }
45
Popular Tags