unsw.cse.mica.data
Interface TypeManager

All Known Implementing Classes:
LocalTypeManager, RemoteTypeManager

public interface TypeManager

A interface defining a structural representation of the type hierarchy for mob types. The type hierarchy is a directed acyclic graph with type "mob" at the top. Each type inherits from one or more parents.

Type heirarchies also provide default persistence modes for mobs. When a mob with unspecified persistence is written to the blackboard the blackboard checks whether the mob's type has a default persistence mode. If so, the mob is given the default persistence for its type.

Default persistence modes are inherited and can be over-ridden. A type that has no persistence mode specified will take on the type of the first of its parents that has a default persistence. For example, consider given the following (XML) type specification: <typedesc> <mobdecl name="type1" persistence="connected" > </mobdecl> <mobdecl name="type2" persistence="transient" > </mobdecl> <mobdecl name="type3" > </mobdecl> <mobdecl name="type4" > <parent name="type1" /> <parent name="type2" /> </mobdecl> <mobdecl name="type5" > <parent name="type2" /> <parent name="type1" /> </mobdecl> <mobdecl name="type6" > <parent name="type3" /> <parent name="type1" /> </mobdecl> <mobdecl name="type7" > <parent name="type6" /> </mobdecl> </typedesc> Type persistence for each type is as follows:

Author:
jhw

Field Summary
static java.lang.String TYPE_MOB
          All type heirarchies have the type named "mob" at the top - every mob type inherits either directly or indirectly from this type
 
Method Summary
 java.util.Set getAllTypeNames()
          Get a set containing the names of all the known types in this type manager
 java.util.Set getAncestors(java.lang.String typeName)
          Get a set containing the names of all ancestors of the given type.
 java.util.Set getChildren(java.lang.String typeName)
          Get a set containing the names of all children (immediate descendants) of the given type.
 java.util.Set getDescendants(java.lang.String typeName)
          Get a set containing the names of all descendants of the given type.
 java.util.Set getParents(java.lang.String typeName)
          Get a set containing the names of all parents (immediate ancestors) of the given type.
 java.lang.String getPersistence(java.lang.String typeName)
          Get the default persistence mode for this type.
 boolean hasType(java.lang.String typeName)
          Does the type manager know about the given type?
 boolean isATypeOf(Mob mob, java.lang.String typeName)
          Is the mob an instance of typeName? This is true if isATypeOf(mob.getType(), typeName) is true.
 boolean isATypeOf(java.lang.String typeName, java.lang.String parentName)
          Is one type a subtype of another? A type is a subtype of another if the types are the same or if is a descendant of it
 java.lang.String toXML(java.lang.String initIndent, java.lang.String otherIndent)
          Create an XML representation of the type manager
 

Field Detail

TYPE_MOB

static final java.lang.String TYPE_MOB
All type heirarchies have the type named "mob" at the top - every mob type inherits either directly or indirectly from this type

See Also:
Constant Field Values
Method Detail

hasType

boolean hasType(java.lang.String typeName)
Does the type manager know about the given type?

Returns:
true if the type is known, false otherwise

isATypeOf

boolean isATypeOf(java.lang.String typeName,
                  java.lang.String parentName)
Is one type a subtype of another? A type is a subtype of another if the types are the same or if is a descendant of it

Returns:
true if typeName is a subtype of parentName, false otherwise

isATypeOf

boolean isATypeOf(Mob mob,
                  java.lang.String typeName)
Is the mob an instance of typeName? This is true if isATypeOf(mob.getType(), typeName) is true.

Returns:
true if the mob is an instance of the given type, false otherwise

getPersistence

java.lang.String getPersistence(java.lang.String typeName)
Get the default persistence mode for this type.

Returns:
the default persistence mode for this type, or null if no default persistence is specified.

getAllTypeNames

java.util.Set getAllTypeNames()
Get a set containing the names of all the known types in this type manager

Returns:
a set containing all the known type names for this type manager

getParents

java.util.Set getParents(java.lang.String typeName)
Get a set containing the names of all parents (immediate ancestors) of the given type.

Parameters:
typeName - the type for which the parents are requested
Returns:
a set containing the names of all the parents of the given type

getChildren

java.util.Set getChildren(java.lang.String typeName)
Get a set containing the names of all children (immediate descendants) of the given type.

Parameters:
typeName - the type for which the children are requested
Returns:
a set containing the names of all the children of the given type

getAncestors

java.util.Set getAncestors(java.lang.String typeName)
Get a set containing the names of all ancestors of the given type.

Parameters:
typeName - the type for which the ancestors are requested
Returns:
a set containing the names of all the ancestors of the given type

getDescendants

java.util.Set getDescendants(java.lang.String typeName)
Get a set containing the names of all descendants of the given type.

Parameters:
typeName - the type for which the descendants are requested
Returns:
a set containing the names of all the descendants of the given type

toXML

java.lang.String toXML(java.lang.String initIndent,
                       java.lang.String otherIndent)
Create an XML representation of the type manager

Parameters:
initIndent - the per-line indent for the entire XML string (which may be multi-line)
otherIndent - additioanl indentation for nested elements
Returns:
a string that is an XML representation of the current state of the type manager