1 28 29 package org.jibx.binding.util; 30 31 32 40 41 public abstract class IntegerCache 42 { 43 44 private static Integer [] s_integers = 45 { 46 new Integer (0), new Integer (1), new Integer (2), new Integer (3), 47 new Integer (4), new Integer (5), new Integer (6), new Integer (7) 48 }; 49 50 56 57 public static Integer getInteger(int value) { 58 if (value >= s_integers.length) { 59 60 synchronized(IntegerCache.class) { 67 int size = s_integers.length * 3 / 2; 68 if (size <= value) { 69 size = value + 1; 70 } 71 Integer [] ints = new Integer [size]; 72 System.arraycopy(s_integers, 0, ints, 0, s_integers.length); 73 for (int i = 0; i < size; i++) { 74 ints[i] = new Integer (i); 75 } 76 s_integers = ints; 77 } 78 } 79 return s_integers[value]; 80 } 81 } 82 | Popular Tags |