anthill.antsim.impl
Class RandomResourceSet

java.lang.Object
  |
  +--anthill.antsim.impl.RandomResourceSet
All Implemented Interfaces:
Clearable, ResourceSet

public class RandomResourceSet
extends java.lang.Object
implements ResourceSet, Clearable

RandomResourceSet is a simple implementation of ResourceSet which generates RandomResources. Each random resource has a generic name, which is the string representing a random long value. Requests are obtained by selecting randomly one of the resources stored in this ResourceSet and by returning the string containing the resource name.

Version:
$Revision$
Author:
Alberto Montresor

Field Summary
protected  Factory factory
          Factory used to instantiate objects
static java.lang.String RANDOM_RESOURCESET_SIZE
          Random generator
protected  Resource[] resources
          Resources contained in this resource set
protected  int size
          Number of resources contained in this resource set
 
Constructor Summary
RandomResourceSet(Factory factory)
          Initializes this RandomResourceSet by creating size resources.
 
Method Summary
 void clear()
          Restores the object to its initial state.
 java.lang.Object getRequest()
          Generate a random request.
 Resource[] getResources()
          Return an array containing the resources generated and stored in this ResourceSet.
 int size()
          Return the number of resources generated and stored in this ResourceSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RANDOM_RESOURCESET_SIZE

public static final java.lang.String RANDOM_RESOURCESET_SIZE
Random generator

factory

protected Factory factory
Factory used to instantiate objects

size

protected int size
Number of resources contained in this resource set

resources

protected Resource[] resources
Resources contained in this resource set
Constructor Detail

RandomResourceSet

public RandomResourceSet(Factory factory)
Initializes this RandomResourceSet by creating size resources.
Method Detail

clear

public void clear()
Restores the object to its initial state. If the number of resources to be stored in this object is changed, adapt the resource array.
Specified by:
clear in interface Clearable

size

public int size()
Return the number of resources generated and stored in this ResourceSet.
Specified by:
size in interface ResourceSet

getResources

public Resource[] getResources()
Return an array containing the resources generated and stored in this ResourceSet.
Specified by:
getResources in interface ResourceSet

getRequest

public java.lang.Object getRequest()
Generate a random request. Depending on the implementation of this class, the request could be the identifier of the one of the resources contained in this ResourceSet, or a more specific request (for example, a free query based on keywords, or an insert request).
Specified by:
getRequest in interface ResourceSet