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:
parent
ccb89fbfd9
commit
045210440e
1 changed files with 21 additions and 1 deletions
|
@ -134,6 +134,26 @@ public final class Prototype {
|
|||
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) {
|
||||
this.dbmap = dbmap;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue