jgnash.util
Class BigDecimalCache

java.lang.Object
  extended by jgnash.util.BigDecimalCache

public class BigDecimalCache
extends java.lang.Object

A list class to cache BigDecimals at specified indexes. BigDecimalCache operates under the assumption that it may need to expand the size of the list if an index larger than the current capacity is being set. A returned value of null on a get(index) operation means that the value at that index has not been set.

Version:
$Id$
Author:
Craig Cavanaugh

Field Summary
private  java.math.BigDecimal[] cache
           
 
Constructor Summary
BigDecimalCache(int capacity)
           
 
Method Summary
 void clear()
          Clear all of the BigDecimals in the cache.
 void clear(int fromIndex)
          Clears the cache all of BigDecimals starting at fromIndex.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this BigDecimalCache instance, if necessary, to ensure that it can hold at least the number of BigDecimals specified by the minimum capacity argument.
 java.math.BigDecimal get(int index)
          Returns the BigDecimal at the specified position in the cache
 void set(int index, java.math.BigDecimal element)
          Sets the BigDecimal at the specified position in this cache.
 void trimToSize(int size)
          Trims the capacity of this BigDecimalCache instance to the specified size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private java.math.BigDecimal[] cache
Constructor Detail

BigDecimalCache

public BigDecimalCache(int capacity)
Method Detail

trimToSize

public void trimToSize(int size)
Trims the capacity of this BigDecimalCache instance to the specified size.

Parameters:
size - the new capacity of the cache

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of this BigDecimalCache instance, if necessary, to ensure that it can hold at least the number of BigDecimals specified by the minimum capacity argument.

Parameters:
minCapacity - the desired minimum capacity.

get

public final java.math.BigDecimal get(int index)
Returns the BigDecimal at the specified position in the cache

Parameters:
index - index of the BigDecimal to return.
Returns:
the BigDecimal at the specified position in this list.

set

public void set(int index,
                java.math.BigDecimal element)
Sets the BigDecimal at the specified position in this cache.

Parameters:
index - index of the BigDecimal to replace.
element - BigDecimal to be stored at the specified position.

clear

public void clear()
Clear all of the BigDecimals in the cache.


clear

public void clear(int fromIndex)
Clears the cache all of BigDecimals starting at fromIndex.

Parameters:
fromIndex - index of first BigDecimal to be cleared.