|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ascape.model.AscapeObject
public class AscapeObject
The cannonical class for most ascape model objects, including rules. Used to manage basic features, such as access to random stream. Every ascape object should 'belong' to some scape, but is not neccesarily a member of that scape.
Field Summary | |
---|---|
static int |
ARBITRARY_SEED
Symbol for random seed to be arbitrary (current time in milliseconds.) |
protected java.lang.String |
name
The name of this object |
protected Scape |
scape
The agent that this object belongs to. |
Constructor Summary | |
---|---|
AscapeObject()
Constructs an ascape object. |
|
AscapeObject(java.lang.String name)
Constructs an ascape object. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clones this object. |
java.util.ArrayList |
diffDeep(java.lang.Object o)
Does a deep comparison of this object with another, returning an array list containing a string description of the differences found. |
static java.util.ArrayList |
diffDeep(java.lang.Object o1,
java.lang.Object o2)
Does a deep comparison of two objects, returning an array list containing a string description of the differences found. |
static java.util.ArrayList |
diffDeepBFS(java.util.HashSet visitedObjects,
java.util.LinkedList queue)
Does a deep comparison of two objects, returning an array list containing a string description of the differences found. |
static java.util.ArrayList |
diffDeepDFS(java.lang.Object o1,
java.lang.Object o2)
Does a deep comparison of two objects, returning an array list containing a string description of the differences found. |
protected static java.lang.String |
diffDeepValidate(org.ascape.model.AscapeObject.SearchNode n)
Helper method for both diffDeep mothods. |
protected static java.lang.String |
diffDeepVisit(org.ascape.model.AscapeObject.SearchNode n)
Helper method for both diffDeep mothods. |
static boolean |
equalsDeep(java.util.HashSet visitedObjects,
org.ascape.model.AscapeObject.SearchNode currentNode)
Does a deep comparison of two objects, returning wether the two objects are deeply identical. |
boolean |
equalsDeep(java.lang.Object o)
Does a deep compare of the two objects. |
static boolean |
equalsDeep(java.lang.Object o1,
java.lang.Object o2)
Does a deep comparison of two objects, returning wether the two objects are deeply identical. |
static java.io.PrintStream |
getComparisonStream()
Return the stream used to capture the results of object deep comparison. |
java.lang.String |
getName()
A name this object may be referred to by. |
java.util.Random |
getRandom()
Gets the random number stream used by this object. |
long |
getRandomSeed()
Returns the seed for the default random number seed. |
Scape |
getScape()
Returns the scape that this object is primarily related to. |
double |
randomInRange(double low,
double high)
Generate a double uniformly distributed across some range. |
int |
randomInRange(int low,
int high)
Generate an integer uniformly distributed across some range. |
boolean |
randomIs()
Returns a random boolean value. |
int |
randomToLimit(int limit)
Generate an integer uniformly distributed across 0...limit - 1. |
void |
reseed()
Resets the random number generator. |
static void |
setComparisonStream(java.io.PrintStream comparisonStream)
Sets the stream used to capture the results of object deep comparison. |
void |
setName(java.lang.String name)
Sets a name this object may be referred to by. |
void |
setRandom(java.util.Random newRandom)
Sets the random number stream to be used by this object. |
void |
setRandomSeed(long seed)
Sets the seed for the default random number seed. |
void |
setScape(Scape scape)
Sets the scape that this object is primarily related to. |
java.lang.String |
toString()
A string representing this object. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ARBITRARY_SEED
protected Scape scape
protected java.lang.String name
Constructor Detail |
---|
public AscapeObject()
public AscapeObject(java.lang.String name)
name
- the name of this objectMethod Detail |
---|
public void setScape(Scape scape)
scape
- the scape this agent is belongs topublic Scape getScape()
public java.lang.String getName()
getName
in interface HasName
public void setName(java.lang.String name)
public void setRandom(java.util.Random newRandom)
random
that
is available to all objects. May be overriden to set an instance
random stream instead.
setRandom
in interface RandomFunctions
newRandom
- the new random number stream to usegetRandom()
public java.util.Random getRandom()
random
available to all objects.
If you want to provide scapes or agents with their own
randoms, override this method and be sure to use it instead of simply
accessing the random variable.
getRandom
in interface RandomFunctions
public long getRandomSeed()
public void setRandomSeed(long seed)
seed
- the random number seed to usepublic void reseed()
public int randomInRange(int low, int high)
randomInRange
in interface RandomFunctions
low
- the lowest number (inclusive) that the resulting int might behigh
- the hignest number (inclusive) that the resulting int might be
public double randomInRange(double low, double high)
randomInRange
in interface RandomFunctions
low
- the lowest number (inclusive) that the resulting double might behigh
- the hignest number (exclusive) that the resulting double might be
public int randomToLimit(int limit)
randomToLimit
in interface RandomFunctions
limit
- the maximum limit (exclusive) of the resulting int
public boolean randomIs()
randomIs
in interface RandomFunctions
protected static java.lang.String diffDeepVisit(org.ascape.model.AscapeObject.SearchNode n)
n
- the node in the object tree that is currently being explored
protected static java.lang.String diffDeepValidate(org.ascape.model.AscapeObject.SearchNode n)
n
- the node in the object tree that is currently being explored
public static java.util.ArrayList diffDeepDFS(java.lang.Object o1, java.lang.Object o2)
o1
- the first object to compareo2
- the second object to compare
public static java.util.ArrayList diffDeep(java.lang.Object o1, java.lang.Object o2)
o1
- the first object to compareo2
- the second object to compare
public static java.util.ArrayList diffDeepBFS(java.util.HashSet visitedObjects, java.util.LinkedList queue)
visitedObjects
- the set of objects that have allready been testedqueue
- the current search node queue
public java.util.ArrayList diffDeep(java.lang.Object o)
o
- the object to compare to
public static boolean equalsDeep(java.lang.Object o1, java.lang.Object o2)
o1
- the first object to compareo2
- the second object to compare
public static boolean equalsDeep(java.util.HashSet visitedObjects, org.ascape.model.AscapeObject.SearchNode currentNode)
visitedObjects
- a string describing the parent members of the objects (may be empty)currentNode
- the node in the object tree that is currently being explored
public boolean equalsDeep(java.lang.Object o)
public static java.io.PrintStream getComparisonStream()
public static void setComparisonStream(java.io.PrintStream comparisonStream)
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |