[Fb-contrib-commit] SF.net SVN: fb-contrib: [541] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/uti
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-05-17 05:03:28
|
Revision: 541 Author: dbrosius Date: 2006-05-16 22:03:21 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=541&view=rev Log Message: ----------- jdk1.5's Integer is pretty useful. Add this class to get the caching functionality that is missing in 1.4 Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Integer14.java 2006-05-17 05:03:21 UTC (rev 541) @@ -0,0 +1,41 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +public class Integer14 +{ + public static final int MIN_CACHE = -32; + public static final int MAX_CACHE = 32; + + private static final Integer[] cachedInts = new Integer[MAX_CACHE-MIN_CACHE+1]; + static { + for (int i = MIN_CACHE; i <= MAX_CACHE; i++) + cachedInts[i-MIN_CACHE] = new Integer(i); + } + + private Integer14() + {} + + public static Integer valueOf(int i) + { + if ((i < MIN_CACHE) || (i > MAX_CACHE)) + return new Integer(i); + return cachedInts[i-MIN_CACHE]; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |