planet.generic.commonapi.factory
Class IdFactoryDoubleImpl

java.lang.Object
  extended byplanet.generic.commonapi.factory.IdFactoryImpl
      extended byplanet.generic.commonapi.factory.IdFactoryDoubleImpl
All Implemented Interfaces:
IdFactory, java.io.Serializable

public class IdFactoryDoubleImpl
extends IdFactoryImpl

This Factory generate uniques Id from a material. The Id must to be based on a double representation of its internal value.

Author:
Jordi Pujol
See Also:
Serialized Form

Field Summary
 
Fields inherited from class planet.generic.commonapi.factory.IdFactoryImpl
actualBuildsIds, actualValue, chunkValue, defaultIdClass, defaultNetworkSize, defaultTopology, idClass, idClassConstructorBigInteger, idClassConstructorByteArray, idClassConstructorDouble, idClassConstructorInt, idClassConstructorIntArray, idClassConstructorString, networkSize, propertiesFile, random, topology
 
Constructor Summary
IdFactoryDoubleImpl(java.lang.Class idClass, java.lang.String topology, int networkSize)
          Constructor that builds an instance with these parameters
IdFactoryDoubleImpl(java.lang.String propertiesFile)
          This constructor reads the properties' file and initializes the IdFactory and Class for new Nodes.
 
Method Summary
 Id buildId(java.math.BigInteger bigNumber)
          Generate an Id from the BigInteger as its internal value.
 Id buildId(byte[] material)
          Generate an Id from material in byte[] format as its internal value.
 Id buildId(double material)
          Builds an Id with the double parameter as its internal value.
 Id buildId(int material)
          Builds an Id with the int parameter as its internal value.
 Id buildId(int[] material)
          Generate an Id from material in int[] format, as its internal value.
protected  Id buildRandomId()
          Builds a random Id using the double constructor of the target Id.
protected  void initDistributedAttr()
          Initializes the protected attributes to permits the uniform distribution of Ids.
 
Methods inherited from class planet.generic.commonapi.factory.IdFactoryImpl
buildId, buildId, buildKey, init, readIdFactoryObject, writeIdFactoryObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdFactoryDoubleImpl

public IdFactoryDoubleImpl(java.lang.String propertiesFile)
                    throws InitializationException
This constructor reads the properties' file and initializes the IdFactory and Class for new Nodes. If occur any problem with this initialization, throws a InitializationException exception with short description for the problem.

Throws:
InitializationException - If occur any problem during initialization steps.

IdFactoryDoubleImpl

public IdFactoryDoubleImpl(java.lang.Class idClass,
                           java.lang.String topology,
                           int networkSize)
                    throws InitializationException
Constructor that builds an instance with these parameters

Parameters:
idClass - Id class to build.
topology - Network topology to known how build the new Ids.
networkSize - Size of the network. It is important if is used the topology Topology.CIRCULAR.
Throws:
InitializationException - if occurs some error during initialization of values.
See Also:
Topology
Method Detail

initDistributedAttr

protected void initDistributedAttr()
                            throws InitializationException
Initializes the protected attributes to permits the uniform distribution of Ids.

Overrides:
initDistributedAttr in class IdFactoryImpl
Throws:
InitializationException - if an error occurs during their initialization.

buildRandomId

protected Id buildRandomId()
                    throws InitializationException
Builds a random Id using the double constructor of the target Id.

Overrides:
buildRandomId in class IdFactoryImpl
Returns:
A new Id builded randomly.
Throws:
InitializationException - if an error occurs during the initialization of the Id.

buildId

public Id buildId(double material)
           throws InitializationException
Builds an Id with the double parameter as its internal value.

Specified by:
buildId in interface IdFactory
Overrides:
buildId in class IdFactoryImpl
Parameters:
material - double with the internal value for the new Id.
Returns:
New Id with the double internal value.
Throws:
InitializationException - if an error occurs during the initialization of the Id or if it is nonapplicable to the target Id.
See Also:
IdFactory.buildId(double)

buildId

public Id buildId(int material)
           throws InitializationException
Builds an Id with the int parameter as its internal value.

Specified by:
buildId in interface IdFactory
Overrides:
buildId in class IdFactoryImpl
Parameters:
material - Int with the internal value for the new Id.
Returns:
New Id with the int internal value.
Throws:
Always - InitializationException for nonapplicable constructor.
InitializationException - if an error occurs during the initialization of the Id or if it is nonapplicable to the target Id.
See Also:
IdFactory.buildId(int)

buildId

public Id buildId(byte[] material)
           throws InitializationException
Generate an Id from material in byte[] format as its internal value.

Specified by:
buildId in interface IdFactory
Overrides:
buildId in class IdFactoryImpl
Parameters:
material - Hash code previously generated.
Throws:
InitializationException - if an error occurs during the initialization of the Id or if it is nonapplicable to the target Id.
See Also:
IdFactory.buildId(byte[])

buildId

public Id buildId(int[] material)
           throws InitializationException
Generate an Id from material in int[] format, as its internal value.

Specified by:
buildId in interface IdFactory
Overrides:
buildId in class IdFactoryImpl
Parameters:
material - Internal value of the new Id in int[] format.
Throws:
InitializationException - if an error occurs during the initialization of the Id or if it is nonapplicable to the target Id.
See Also:
IdFactory.buildId(int[])

buildId

public Id buildId(java.math.BigInteger bigNumber)
           throws InitializationException
Generate an Id from the BigInteger as its internal value.

Specified by:
buildId in interface IdFactory
Overrides:
buildId in class IdFactoryImpl
Throws:
InitializationException - when an error occurs during the initialization of the Id or when this factory method is nonapplicable.
See Also:
IdFactory.buildId(java.math.BigInteger)