KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > util > XIntPool


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs.util;
18
19 /**
20  * @xerces.internal
21  *
22  * @author Henry Zongaro, IBM
23  * @version $Id: XIntPool.java,v 1.4 2004/10/06 15:14:50 mrglavas Exp $
24  */

25 public final class XIntPool {
26     private static final short POOL_SIZE = 10;
27     private static final XInt[] fXIntPool = new XInt[POOL_SIZE];
28
29     static {
30         for (int i = 0; i < POOL_SIZE; i++)
31             fXIntPool[i] = new XInt(i);
32     }
33
34     public final XInt getXInt(int value) {
35         if (value >= 0 && value < fXIntPool.length)
36             return fXIntPool[value];
37         else
38             return new XInt(value);
39     }
40 }
41
Popular Tags