org.ascape.model.rule
Class SearchRule

java.lang.Object
  extended by org.ascape.model.AscapeObject
      extended by org.ascape.model.rule.Rule
          extended by org.ascape.model.rule.SearchRule
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HasName, RandomFunctions

public class SearchRule
extends Rule

A rule that can be used to search through a collection of agents.

Since:
2.0
Version:
2.0
Author:
Miles Parker
See Also:
Serialized Form

Field Summary
static int SEARCH_EQUAL
          The symbol for an 'equals' search.
static int SEARCH_MAX
          The symbol for a 'maximum' search.
static int SEARCH_MIN
          The symbol for a 'minimum' search.
 
Fields inherited from class org.ascape.model.AscapeObject
ARBITRARY_SEED, name, scape
 
Constructor Summary
SearchRule(java.lang.String name)
          Constructs a search rule with the providied name.
 
Method Summary
 void clear()
          Clears the found result.
 void execute(Agent agent)
          Perform the search rule for the specified agent.
 java.util.Comparator getComparator()
          Returns the comparator used for this search.
 Agent getFoundAgent()
          Gets the found agent.
 java.lang.Object getKey()
          Returns the key used for this search.
 int getType()
          Returns the search type used in any searches using this rule.
 boolean isRandom()
          In geneeral, the search in general does not need to be random.
 void setComparator(java.util.Comparator comparator)
          Sets the comparator for the search.
 void setKey(java.lang.Object key)
          Sets the key for the search.
 void setSearchType(int type)
          Sets the search type to be used for this search.
 
Methods inherited from class org.ascape.model.rule.Rule
getScape, isCauseRemoval, isIterateAll, isRandomExecution, setScape
 
Methods inherited from class org.ascape.model.AscapeObject
clone, diffDeep, diffDeep, diffDeepBFS, diffDeepDFS, diffDeepValidate, diffDeepVisit, equalsDeep, equalsDeep, equalsDeep, getComparisonStream, getName, getRandom, getRandomSeed, randomInRange, randomInRange, randomIs, randomToLimit, reseed, setComparisonStream, setName, setRandom, setRandomSeed, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEARCH_EQUAL

public static final int SEARCH_EQUAL
The symbol for an 'equals' search.

See Also:
Constant Field Values

SEARCH_MIN

public static final int SEARCH_MIN
The symbol for a 'minimum' search.

See Also:
Constant Field Values

SEARCH_MAX

public static final int SEARCH_MAX
The symbol for a 'maximum' search.

See Also:
Constant Field Values
Constructor Detail

SearchRule

public SearchRule(java.lang.String name)
Constructs a search rule with the providied name. It is strongly encouraged to provide a name for all rules. This name will be used for run time rule selection and provides important information fopr analyzing and debugging models.

Parameters:
name - the name of this object
Method Detail

execute

public void execute(Agent agent)
Perform the search rule for the specified agent.

Specified by:
execute in class Rule
Parameters:
agent - the target agent.

clear

public void clear()
Clears the found result. Must be called before executing the rule.


isRandom

public boolean isRandom()
In geneeral, the search in general does not need to be random.

Returns:
true, if is random

getComparator

public java.util.Comparator getComparator()
Returns the comparator used for this search.

Returns:
the comparator

setComparator

public void setComparator(java.util.Comparator comparator)
Sets the comparator for the search.

Parameters:
comparator - the compartor to use for the search.

getKey

public java.lang.Object getKey()
Returns the key used for this search.

Returns:
the key

setKey

public void setKey(java.lang.Object key)
Sets the key for the search.

Parameters:
key - the compartor to use for the search.

getFoundAgent

public Agent getFoundAgent()
Gets the found agent.

Returns:
the found agent

setSearchType

public void setSearchType(int type)
Sets the search type to be used for this search. Default is SEARCH_EQUALS.

Parameters:
type - one of the "SEARCH" symbols specified above.

getType

public int getType()
Returns the search type used in any searches using this rule.

Returns:
the type


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.