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 RandomResource
s. 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.
Field Summary |
protected Resource[] |
resources
Resources contained in this resource set |
protected int |
size
Number of resources contained in this resource set |
Constructor Summary |
RandomResourceSet(int size)
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 |
size
protected int size
- Number of resources contained in this resource set
resources
protected Resource[] resources
- Resources contained in this resource set
RandomResourceSet
public RandomResourceSet(int size)
- Initializes this
RandomResourceSet
by creating
size
resources.
clear
public void clear()
- Restores the object to its initial state.
In this implementation, do nothing, as the resource set is
immutable.
- 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