|
|||||||||||
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.
Nested Class Summary | |
class |
IdFactoryImpl.DistributedIdIterator
Is an Id iterator, for building up to networkSize Id. |
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.Method |
idDivideMethod
Id.divide(long) method for the actual Id implementation. |
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()
Builds the IdFactory. |
Method Summary | |
java.util.Iterator |
buildDistributedIds(int desiredNetworkSize)
The Iterator instance returned permits to build as maximum desiredNetworkSize. |
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 |
buildId(java.lang.String material,
java.lang.String algorithm)
Builds a new Id from an arbitray string applying a one-way hashing algorithm, such as SHA-1 or MD5. |
Id |
buildKey(java.lang.String string)
Generate an Id from a String with SHA-1 hash function. |
Id |
buildRandomId()
Builds a random Id using the Random constructor of the target Id. |
protected void |
initDistributedAttr()
Initializes the protected attributes to permits the uniform distribution of Ids. |
IdFactory |
setValues(java.lang.Class idClass,
java.lang.String topology,
int networkSize)
Sets the specified initial values. |
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 java.lang.Class idClass
protected transient java.lang.reflect.Method idDivideMethod
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() throws InitializationException
InitializationException
- if occurs some error during initialization.Method Detail |
public IdFactory setValues(java.lang.Class idClass, java.lang.String topology, int networkSize) throws InitializationException
setValues
in interface IdFactory
idClass
- Class reference for the current Id implementation.topology
- Desired network topology.networkSize
- Desired network size.
InitializationException
- if any error occurs during the
initialization process.IdFactory.setValues(java.lang.Class, java.lang.String, int)
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.public Id buildRandomId() throws InitializationException
buildRandomId
in interface IdFactory
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)
,
Utilities.generateByteHash(java.lang.String)
public Id buildId(java.lang.String material) throws InitializationException
buildId
in interface IdFactory
material
- Contains the internal value of Id in String format.
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.lang.String material, java.lang.String algorithm) throws InitializationException
buildId
in interface IdFactory
material
- An arbitray string.algorithm
- One-way hashing algorithm such as "SHA" or "MD5".
InitializationException
- when an error occurs during the
initialization of the Id or when this factory method is
nonapplicable.public Id buildId(java.math.BigInteger bigNumber) throws InitializationException
buildId
in interface IdFactory
bigNumber
- BigInteger with the internal value of 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)
public java.util.Iterator buildDistributedIds(int desiredNetworkSize) throws InitializationException
buildDistributedIds
in interface IdFactory
desiredNetworkSize
- Number of nodes Id to obtain.
InitializationException
- if any error has ocurred during the initialization.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |