|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.generic.commonapi.factory.IdFactoryImpl
This Factory generate uniques Id from a material.
Field Summary | |
protected int |
actualBuildsIds
Number of Ids generated actually. |
protected Id |
actualValue
Id just generated. |
protected Id |
chunkValue
Actual value to add to the actualValue to obtain the next Id. |
protected static java.lang.String |
defaultIdClass
The default Class for Ids specified in the properties file. |
protected static java.lang.String |
defaultNetworkSize
The default size key for the target network specified in the properties file. |
protected static java.lang.String |
defaultTopology
The default topology of the target network specified in the properties file. |
protected java.lang.Class |
idClass
Actual instance of Class for new Ids. |
protected java.lang.reflect.Constructor |
idClassConstructorBigInteger
Constructor of actual idClass with only one parameter: a BigInteger. |
protected java.lang.reflect.Constructor |
idClassConstructorByteArray
Constructor of actual idClass with only one parameter: a byte array. |
protected java.lang.reflect.Constructor |
idClassConstructorDouble
Constructor of actual idClass with only one parameter: a double. |
protected java.lang.reflect.Constructor |
idClassConstructorInt
Constructor of actual idClass with only one parameter: an int. |
protected java.lang.reflect.Constructor |
idClassConstructorIntArray
Constructor of actual idClass with only one parameter: an int array. |
protected java.lang.reflect.Constructor |
idClassConstructorString
Constructor of actual idClass with only one parameter: a String. |
protected int |
networkSize
Network size for the target network. |
protected java.lang.String |
propertiesFile
Properties file name whose read properties. |
protected java.util.Random |
random
Random generator for random Id's. |
protected java.lang.String |
topology
Topology of the actual target network. |
Constructor Summary | |
IdFactoryImpl(java.lang.Class idClass,
java.lang.String topology,
int networkSize)
Constructor that builds an instance with these parameters |
|
IdFactoryImpl(java.lang.String propertiesFile)
This constructor reads the properties' file and initializes the IdFactory and Class for new Nodes. |
Method Summary | |
Id |
buildId()
Builds an Id with the actual configuration of network topology and size. |
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. |
Id |
buildId(java.lang.String material)
Generate an Id from a String that contains its internal value. |
Id |
buildKey(java.lang.String string)
Generate an Id from a String with SHA-1 hash function. |
protected Id |
buildRandomId()
Builds a random Id using the BigInteger constructor of the target Id. |
protected void |
init(java.lang.Class idClass,
java.lang.String topology,
int networkSize)
Initialize the new instance with correct values to generate new Ids. |
protected void |
initDistributedAttr()
Initializes the protected attributes to permits the uniform distribution of Ids. |
protected void |
readIdFactoryObject(java.io.ObjectInputStream stream)
This method must be invoked by the different IdFactory implementation to recover all Constructors that this class contains. |
protected void |
writeIdFactoryObject(java.io.ObjectOutputStream stream)
Makes nothing special, only invokes to stream.defaultWriteObject(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String propertiesFile
protected static final java.lang.String defaultIdClass
protected static final java.lang.String defaultTopology
protected static final java.lang.String defaultNetworkSize
protected transient java.lang.reflect.Constructor idClassConstructorInt
protected transient java.lang.reflect.Constructor idClassConstructorDouble
protected transient java.lang.reflect.Constructor idClassConstructorByteArray
protected transient java.lang.reflect.Constructor idClassConstructorIntArray
protected transient java.lang.reflect.Constructor idClassConstructorString
protected transient java.lang.reflect.Constructor idClassConstructorBigInteger
protected java.lang.Class idClass
protected java.lang.String topology
protected int networkSize
protected Id actualValue
protected Id chunkValue
protected int actualBuildsIds
protected java.util.Random random
Constructor Detail |
public IdFactoryImpl(java.lang.String propertiesFile) throws InitializationException
InitializationException
- If occur any problem during
initialization steps.public IdFactoryImpl(java.lang.Class idClass, java.lang.String topology, int networkSize) throws InitializationException
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.
InitializationException
- if occurs some error during initialization of values.Topology
Method Detail |
protected void init(java.lang.Class idClass, java.lang.String topology, int networkSize) throws InitializationException
idClass
- Id class to be build with this factory.topology
- Network topology of the target network.networkSize
- Number of nodes to be build to the target network.
InitializationException
- if occurs some error with the initialization process.protected void initDistributedAttr() throws InitializationException
InitializationException
- if an error occurs during
their initialization.public Id buildId() throws InitializationException
buildId
in interface IdFactory
InitializationException
- when an error occurs during the
initialization of the Id or when this factory method is
nonapplicable.protected Id buildRandomId() throws InitializationException
InitializationException
- if an error occurs during the
initialization of the Id.public Id buildId(double material) throws InitializationException
buildId
in interface IdFactory
material
- double with the internal value for the new Id.
InitializationException
- if an error occurs during the
initialization of the Id or if it is nonapplicable to the
target Id.IdFactory.buildId(double)
public Id buildId(int material) throws InitializationException
buildId
in interface IdFactory
material
- Int with the internal value for the new Id.
InitializationException
- if an error occurs during the
initialization of the Id or if it is nonapplicable to the
target Id.IdFactory.buildId(int)
public Id buildId(byte[] material) throws InitializationException
buildId
in interface IdFactory
material
- Hash code previously generated.
InitializationException
- if an error occurs during the
initialization of the Id or if it is nonapplicable to the
target Id.IdFactory.buildId(byte[])
public Id buildId(int[] material) throws InitializationException
buildId
in interface IdFactory
material
- Internal value of the new Id in int[] format.
InitializationException
- if an error occurs during the
initialization of the Id or if it is nonapplicable to the
target Id.IdFactory.buildId(int[])
public Id buildKey(java.lang.String string) throws InitializationException
buildKey
in interface IdFactory
string
- String to apply default hash function (SHA-1) to
generate Id.
InitializationException
- when an error occurs during the
initialization of the Id or when this factory method is
nonapplicable.IdFactory.buildKey(java.lang.String)
,
planet.util.Utilities.generateByteHash(java.lang.String)
public Id buildId(java.lang.String material) throws InitializationException
buildId
in interface IdFactory
material
- With the String representation of the
internal value.
InitializationException
- when an error occurs during the
initialization of the Id or when this factory method is
nonapplicable.IdFactory.buildId(java.lang.String)
public Id buildId(java.math.BigInteger bigNumber) throws InitializationException
buildId
in interface IdFactory
bigNumber
- BigInteger with the internal value for the new Id.
InitializationException
- when an error occurs during the
initialization of the Id or when this factory method is
nonapplicable.IdFactory.buildId(java.math.BigInteger)
protected void writeIdFactoryObject(java.io.ObjectOutputStream stream) throws java.io.IOException
stream
- Stream to save the actual instance.
java.io.IOException
- if any error has ocurred.protected void readIdFactoryObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
stream
- Stream to read the actual instance.
java.io.IOException
- if occur any error during
default read object, or if there are any error during
building of Node constructor.
java.lang.ClassNotFoundException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |