Added two methods:

* isInstanceOf(str) checks if this prototype is an instance (equals or inherits) the
  prototype with the given name.

* addToHandlerMap(map, obj)  adds the given object as macro handler for this
prototype and all its parent prototypes.
This commit is contained in:
hns 2003-03-04 18:15:15 +00:00
parent ccb89fbfd9
commit 045210440e

View file

@ -134,6 +134,26 @@ public final class Prototype {
return parent; return parent;
} }
/**
* Check if the given prototype is within this prototype's parent chain.
*/
public final boolean isInstanceOf (String pname) {
if (name.equals (pname))
return true;
if (parent != null)
return parent.isInstanceOf (pname);
return false;
}
/**
* Register an object as handler for this prototype and all our parent prototypes.
*/
public final void addToHandlerMap (Map handlers, Object obj) {
if (parent != null && !"hopobject".equalsIgnoreCase (parent.getName()))
parent.addToHandlerMap (handlers, obj);
handlers.put (name, obj);
}
public void setDbMapping (DbMapping dbmap) { public void setDbMapping (DbMapping dbmap) {
this.dbmap = dbmap; this.dbmap = dbmap;
} }