org.apfloat.internal
Class DoubleDataStorageBuilder

java.lang.Object
  extended by org.apfloat.internal.DoubleDataStorageBuilder
All Implemented Interfaces:
DataStorageBuilder

public class DoubleDataStorageBuilder
extends Object
implements DataStorageBuilder

Default data storage creation strategy for the double data type.

Version:
1.5.1
Author:
Mikko Tommila
See Also:
DoubleMemoryDataStorage, DoubleDiskDataStorage

Constructor Summary
DoubleDataStorageBuilder()
          Default constructor.
 
Method Summary
 DataStorage createCachedDataStorage(long size)
          Get a data storage that is cached in memory, if possible, for the requested size of data.
 DataStorage createDataStorage(DataStorage dataStorage)
          Convert cached data storage to the appropriate normal data storage type.
 DataStorage createDataStorage(long size)
          Get an appropriate type of data storage for the requested size of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleDataStorageBuilder

public DoubleDataStorageBuilder()
Default constructor.

Method Detail

createDataStorage

public DataStorage createDataStorage(long size)
                              throws ApfloatRuntimeException
Description copied from interface: DataStorageBuilder
Get an appropriate type of data storage for the requested size of data.

Note that the returned data storage object is not set to have the requested size, so the client should call the object's DataStorage.setSize(long) method before storing data to it.

Specified by:
createDataStorage in interface DataStorageBuilder
Parameters:
size - The size of data to be stored in the storage, in bytes.
Returns:
An empty DataStorage object of an appropriate type for storing size bytes of data.
Throws:
ApfloatRuntimeException

createCachedDataStorage

public DataStorage createCachedDataStorage(long size)
                                    throws ApfloatRuntimeException
Description copied from interface: DataStorageBuilder
Get a data storage that is cached in memory, if possible, for the requested size of data.

Note that the returned data storage object is not set to have the requested size, so the client should call the object's DataStorage.setSize(long) method before storing data to it.

Specified by:
createCachedDataStorage in interface DataStorageBuilder
Parameters:
size - The size of data to be stored in the storage, in bytes.
Returns:
An empty DataStorage object of an appropriate type for storing size bytes of data, cached if possible.
Throws:
ApfloatRuntimeException

createDataStorage

public DataStorage createDataStorage(DataStorage dataStorage)
                              throws ApfloatRuntimeException
Description copied from interface: DataStorageBuilder
Convert cached data storage to the appropriate normal data storage type.

If the data storage already has the appropriate type for its size, the data storage may be returned unchanged. The argument data storage does not necessarily have to be created with the DataStorageBuilder.createCachedDataStorage(long) method, it can be created as well with the DataStorageBuilder.createDataStorage(long) method.

If the given data storage does not have the appropriate type for its size, then a new data storage of the appropriate type is created and the data is copied to it.

Specified by:
createDataStorage in interface DataStorageBuilder
Parameters:
dataStorage - The data storage to be converted, if necessary.
Returns:
A DataStorage that can be the original data storage or a copy of it, with the appropriate type.
Throws:
ApfloatRuntimeException