Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 74   Methods: 3
NCLOC: 19   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ObjectPool.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Licensed to the Apache Software Foundation (ASF) under one or more
 3    * contributor license agreements. See the NOTICE file distributed with
 4    * this work for additional information regarding copyright ownership.
 5    * The ASF licenses this file to You under the Apache License, Version 2.0
 6    * (the "License"); you may not use this file except in compliance with
 7    * the License. You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    *
 17    * $Id: ObjectPool.java 541508 2007-05-25 01:54:12Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.util;
 21   
 22    /**
 23    * ObjectPool is an abstract Object Pool implementation. In order to
 24    * create a working ObjectPool, one must extend ObjectPool and implement
 25    * the createObject method.
 26    *
 27    * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $
 28    */
 29    public abstract class ObjectPool {
 30    private ObjectQueue pool = new ObjectQueue();
 31   
 32    /**
 33    * createObject needs to be implemented in order to allow the ObjectPool
 34    * to produce Pooled objects.
 35    *
 36    * @return Poolable a new Poolable object instance
 37    */
 38    protected abstract Poolable createObject();
 39   
 40    /**
 41    * getObject retrieves a Poolable object from the Object pool, creating
 42    * a new instance if necessary.
 43    *
 44    * @return Poolable a Poolable object instance
 45    */
 46  0 public Poolable getObject() {
 47  0 Poolable result = (Poolable) pool.remove();
 48  0 if (result == null) {
 49  0 result = createObject();
 50  0 result.setPool(this);
 51    }
 52  0 return result;
 53    }
 54   
 55    /**
 56    * putObject should be called by Poolable objects or consumers of Poolable
 57    * objects to return a Pooled object to the Object Pool.
 58    *
 59    * @param object The Poolable object instance
 60    */
 61  0 public void putObject(Poolable object) {
 62  0 pool.add(object);
 63    }
 64   
 65    /**
 66    * isEmpty returns whether the ObjectPool is currently empty.
 67    *
 68    * @return Whether to ObjectPool is empty
 69    */
 70  0 public boolean isEmpty() {
 71  0 return pool.isEmpty();
 72    }
 73    }
 74