planet.generic.commonapi.factory
Class NetworkFactoryImpl

java.lang.Object
  extended by planet.generic.commonapi.factory.NetworkFactoryImpl
All Implemented Interfaces:
NetworkFactory

public class NetworkFactoryImpl
extends java.lang.Object
implements NetworkFactory

This factory abstracts a NetworkFactory. The file passed by parameter at constructor must contains:

The existing properties in that file are the follows:
  1. DEFAULT_NETWORK: An implementation of Network interface.
  2. DEFAULT_NODEFACTORY: A NodeFactory implementation to use for build nodes within the network.
  3. DEFAULT_SIZE: Number of nodes to generate under the network.
  4. DEFAULT_K: Number of bits for the Ids for the Nodes.
  5. DEFAULT_SERIALIZEDFILE: The file where appear the serialized state of some network.
  6. DEFAULT_TOPOLOGY: Topology of the network to construct.
All those properties can be modified too by invoking concrete methods within the Network.

Author:
Jordi Pujol
See Also:
Network

Field Summary
protected  int bitsKey
          Number of bits for the Ids of Nodes.
protected  java.lang.reflect.Constructor networkConstructor
          The Constructor for Networks.
protected  int networkSize
          The default network size to use for build a network.
protected  NodeFactory nodeFactory
          The NodeFactory actually in use.
protected  java.lang.String serializedFile
          The default filename from where read a serialized state of a network.
protected  java.lang.String topology
          The default topology to use for build a network.
 
Constructor Summary
NetworkFactoryImpl(java.lang.Class networkClass, java.lang.Class nodeFactClass, java.lang.Class idFactory, java.lang.Class nodeClass, java.lang.Class idClass, java.lang.String topology, int networkSize)
          Builds a new instance of the NetworkFactory using all specified parameters.
NetworkFactoryImpl(java.lang.String propertiesFile)
          Builds a new instance of NetworkFactory reading all necessary properties from propertiesFile.
 
Method Summary
 Network buildNetwork()
          Builds a network with the actual specified properties.
 Network buildNetwork(int size)
          Builds a network with the actual specified properties, but overwriting the number of nodes to build within.
 Network buildNetwork(int size, NodeFactory nodeFactory)
          Builds a new network with the specified size and this concrete nodeFactory.
 Network buildNetwork(int size, NodeFactory nodeFactory, java.lang.String topology)
          Builds a new network with the specified size, this concrete nodeFactory and network topology.
 Network buildNetwork(int size, NodeFactory nodeFactory, java.lang.String topology, int k)
          Builds a new network with the specified size, this concrete nodeFactory, network topology and k bits to construct new Ids for the Nodes.
 Network buildNetwork(int size, java.lang.String topology)
          Builds a network with the specified size for the network, building it under this concrete topology.
 int getNetworkSize()
          Inform from the network size for the default building networks.
 NodeFactory getNodeFactory()
          Returns the NodeFactory actually in use.
 java.lang.String getSerializedFile()
          Gets the filename for the serialized state of some network.
 java.lang.String getTopology()
          Inform the topology actually in use to build networks.
 void setNetworkSize(int size)
          Sets a new size for the default building networks.
 void setNodeFactory(NodeFactory nodeFactory)
          Sets the NodeFactory to use in the future.
 void setSerializedFile(java.lang.String file)
          Sets the filename for capture a serialized state of some network.
 void setTopology(java.lang.String topology)
          Sets the topology for the networks to build in the future.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

networkConstructor

protected java.lang.reflect.Constructor networkConstructor
The Constructor for Networks.


nodeFactory

protected NodeFactory nodeFactory
The NodeFactory actually in use.


networkSize

protected int networkSize
The default network size to use for build a network.


bitsKey

protected int bitsKey
Number of bits for the Ids of Nodes.


topology

protected java.lang.String topology
The default topology to use for build a network.


serializedFile

protected java.lang.String serializedFile
The default filename from where read a serialized state of a network.

Constructor Detail

NetworkFactoryImpl

public NetworkFactoryImpl(java.lang.String propertiesFile)
                   throws InitializationException
Builds a new instance of NetworkFactory reading all necessary properties from propertiesFile.

Parameters:
propertiesFile - File of properties which contains all properties of factories.
Throws:
InitializationException - if occur any problem during initialization.

NetworkFactoryImpl

public NetworkFactoryImpl(java.lang.Class networkClass,
                          java.lang.Class nodeFactClass,
                          java.lang.Class idFactory,
                          java.lang.Class nodeClass,
                          java.lang.Class idClass,
                          java.lang.String topology,
                          int networkSize)
                   throws InitializationException
Builds a new instance of the NetworkFactory using all specified parameters. All ones are not nessary for NetworkFactory, but are necessary for build required Factories.

Parameters:
nodeFactClass - NodeFactory class to use to build new nodes.
idFactory - IdFactory class to use to build new Ids.
nodeClass - Node class to use to build new nodes.
idClass - Id class to use to build new Ids.
networkSize - Size of the target network to build.
topology - Topology of the target network to build.
Throws:
InitializationException - if occurs any problem during initialization.
Method Detail

buildNetwork

public Network buildNetwork()
                     throws InitializationException
Builds a network with the actual specified properties. It is, NodeFactory, size of network, number of bits and topology.

Specified by:
buildNetwork in interface NetworkFactory
Returns:
A network with the specified number of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork()

buildNetwork

public Network buildNetwork(int size)
                     throws InitializationException
Builds a network with the actual specified properties, but overwriting the number of nodes to build within.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int)

buildNetwork

public Network buildNetwork(int size,
                            java.lang.String topology)
                     throws InitializationException
Builds a network with the specified size for the network, building it under this concrete topology. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
topology - The network topology to constructs new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, java.lang.String)

buildNetwork

public Network buildNetwork(int size,
                            NodeFactory nodeFactory)
                     throws InitializationException
Builds a new network with the specified size and this concrete nodeFactory. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
nodeFactory - The NodeFactory to use to build Nodes for the new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, planet.commonapi.factory.NodeFactory)

buildNetwork

public Network buildNetwork(int size,
                            NodeFactory nodeFactory,
                            java.lang.String topology)
                     throws InitializationException
Builds a new network with the specified size, this concrete nodeFactory and network topology. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
nodeFactory - The NodeFactory to use to build Nodes for the new network.
topology - The network topology to constructs new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, planet.commonapi.factory.NodeFactory, java.lang.String)

buildNetwork

public Network buildNetwork(int size,
                            NodeFactory nodeFactory,
                            java.lang.String topology,
                            int k)
                     throws InitializationException
Builds a new network with the specified size, this concrete nodeFactory, network topology and k bits to construct new Ids for the Nodes. In this case, the default properties are not used.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
nodeFactory - The NodeFactory to use to build Nodes for the new network.
topology - The network topology to constructs new network.
k - The number of bits for the NodeImpl's Ids.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, planet.commonapi.factory.NodeFactory, java.lang.String, int)

getNodeFactory

public NodeFactory getNodeFactory()
Returns the NodeFactory actually in use.

Specified by:
getNodeFactory in interface NetworkFactory
Returns:
The NodeFactory actually in use.
See Also:
NetworkFactory.getNodeFactory()

setNodeFactory

public void setNodeFactory(NodeFactory nodeFactory)
Sets the NodeFactory to use in the future.

Specified by:
setNodeFactory in interface NetworkFactory
Parameters:
nodeFactory - NodeFactory to use in the future.
See Also:
NetworkFactory.setNodeFactory(planet.commonapi.factory.NodeFactory)

getNetworkSize

public int getNetworkSize()
Inform from the network size for the default building networks.

Specified by:
getNetworkSize in interface NetworkFactory
Returns:
The number of Nodes for the default building networks.
See Also:
NetworkFactory.getNetworkSize()

setNetworkSize

public void setNetworkSize(int size)
Sets a new size for the default building networks.

Specified by:
setNetworkSize in interface NetworkFactory
Parameters:
size - The new size for the default building networks.
See Also:
NetworkFactory.setNetworkSize(int)

getTopology

public java.lang.String getTopology()
Inform the topology actually in use to build networks.

Specified by:
getTopology in interface NetworkFactory
Returns:
The topology in use.
See Also:
NetworkFactory.getTopology()

setTopology

public void setTopology(java.lang.String topology)
                 throws InitializationException
Sets the topology for the networks to build in the future.

Specified by:
setTopology in interface NetworkFactory
Parameters:
topology - The new topology for the default building networks.
Throws:
InitializationException - if the topology is not suported.
See Also:
NetworkFactory.setTopology(java.lang.String)

getSerializedFile

public java.lang.String getSerializedFile()
Gets the filename for the serialized state of some network.

Specified by:
getSerializedFile in interface NetworkFactory
Returns:
The filename that contains a serialized state of some network.
See Also:
NetworkFactory.getSerializedFile()

setSerializedFile

public void setSerializedFile(java.lang.String file)
                       throws InitializationException
Sets the filename for capture a serialized state of some network.

Specified by:
setSerializedFile in interface NetworkFactory
Parameters:
file - Filename from where read the serialized state of a network.
Throws:
InitializationException - if occur some problem with that file
See Also:
NetworkFactory.setSerializedFile(java.lang.String)