|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroup.util.Namespace
Lightweight pseudo-namespace management class. Designed as a replacement for static code with state.
TODO: more verbose explanation, discussion of usefulness and implementation pattern essential.
Field Summary | |
protected Namespace |
_child
child namespace |
protected Namespace |
_parent
parent namespace |
Constructor Summary | |
Namespace()
Constructs a Namespace with no root node. |
Method Summary | |
java.lang.Object |
getInstanceForClass(java.lang.Class klass)
Get the registered instance for a given class. |
static Namespace |
getNamespace()
Accessor method for gettting the namespace for the calling code. |
static void |
registerDefaultInstanceForClass(java.lang.Class klass,
java.lang.Object instance)
Register the default instance for a class. |
void |
registerInstanceForClass(java.lang.Class klass,
java.lang.Object instance)
Register an instance for a class. |
void |
registerNamespace(Namespace namespace)
Register a new Namespace instance. |
void |
setParentNamespace(Namespace parent)
Set the root Namespace. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected Namespace _parent
protected Namespace _child
Constructor Detail |
public Namespace()
Method Detail |
public static Namespace getNamespace()
public static void registerDefaultInstanceForClass(java.lang.Class klass, java.lang.Object instance)
class Foo {
static {
Namespace.getNamespace()
.registerDefaultInstanceForClass(Foo.class, new Foo());
}
}
public void registerNamespace(Namespace namespace)
namespace
- The new namespace to use.public void setParentNamespace(Namespace parent)
root
- The root namespace.public void registerInstanceForClass(java.lang.Class klass, java.lang.Object instance)
klass
- The class to register the instance for.instance
- The instance of that class (must be instanceof
the class).public java.lang.Object getInstanceForClass(java.lang.Class klass)
klass
- The class to get an instance of.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |