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
|
@ -25,7 +25,7 @@ public final class Prototype {
|
||||||
String name;
|
String name;
|
||||||
Application app;
|
Application app;
|
||||||
File directory;
|
File directory;
|
||||||
|
|
||||||
File [] files;
|
File [] files;
|
||||||
long lastDirectoryListing;
|
long lastDirectoryListing;
|
||||||
long checksum;
|
long checksum;
|
||||||
|
@ -133,6 +133,26 @@ public final class Prototype {
|
||||||
public Prototype getParentPrototype () {
|
public Prototype getParentPrototype () {
|
||||||
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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue