|
Nodenet Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nodenet.registrar.UniqueNodeNamePolicy
This class is designed to be plugged into NodeNameRegistry
via the setPolicy(NodeNameRegistrar)
method. It enforces
the uniqueness of node names, and provides access to a node via its
textual name.
Constructor Summary | |
UniqueNodeNamePolicy()
Creates a new instance of UniqueNodeNamePolicy |
Method Summary | |
java.lang.String |
getLegalName()
Provides a name that is currently legal. |
Node |
getNode(java.lang.String aName)
Provides access to nodes via their registred name. |
java.lang.String[] |
getRegisteredNames()
Provides a list of currently registered node names. |
boolean |
isLegalName(java.lang.String aName)
Tests a name to see if it is currently legal. |
boolean |
isRegistered(Node aNode)
Tests to see if a node has been registered. |
boolean |
isRegistered(java.lang.String aName)
Tests to see if a name belongs to a registered node. |
void |
nameAndRegister(Node aNode)
Gives the node a legal name and registers the node in one step. |
void |
register(Node aNode)
Attempt to register a node. |
void |
unregister(Node aNode)
Ensures that the specified node is nolonger registered. |
void |
vetoableChange(java.beans.PropertyChangeEvent pce)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UniqueNodeNamePolicy()
Method Detail |
public java.lang.String getLegalName()
NodeNameRegistrar
Registrar
requires names
to be unique. The implementation of this method should make a reasonable
attempt not to give out names that will become illegal quickly, either
due to temporal relevance of the name, or due to copetition between
names given out to the clients. For example, this method should not
give out the same node name on consecutive invocations if uniqueness is
a qualification for legality.
getLegalName
in interface NodeNameRegistrar
public Node getNode(java.lang.String aName) throws java.lang.UnsupportedOperationException
NodeNameRegistrar
UnsupportedOperationException
rather than returning
a bogus node or null.
getNode
in interface NodeNameRegistrar
aName
- The name of the node to look for.
java.lang.UnsupportedOperationException
public java.lang.String[] getRegisteredNames() throws java.lang.UnsupportedOperationException
NodeNameRegistrar
UnsupportedOperationException
rather than returning
a bogus list or null.
getRegisteredNames
in interface NodeNameRegistrar
java.lang.UnsupportedOperationException
public boolean isLegalName(java.lang.String aName)
NodeNameRegistrar
Registrar
requires
names to be unique.
isLegalName
in interface NodeNameRegistrar
aName
- The node name to be tested.
true
if the name is legal, false
otherwise.public boolean isRegistered(java.lang.String aName)
NodeNameRegistrar
isRegistered
in interface NodeNameRegistrar
aName
- The node name to test
true
if the name is registered false
otherwise.public boolean isRegistered(Node aNode)
NodeNameRegistrar
isRegistered
in interface NodeNameRegistrar
aNode
- The node to test
true
if the node is registered false
otherwise.public void nameAndRegister(Node aNode)
NodeNameRegistrar
nameAndRegister
in interface NodeNameRegistrar
public void register(Node aNode) throws java.lang.IllegalArgumentException
NodeNameRegistrar
NodeNameRegistrar.isLegalName(String)
. If the name contained in the node
is rejected, The node is not registered or tracked in any way and an
IllegalArgumentException
will be thrown.
register
in interface NodeNameRegistrar
aNode
- The node that wishes to register itself.
java.lang.IllegalArgumentException
public void unregister(Node aNode)
NodeNameRegistrar
unregister
in interface NodeNameRegistrar
aNode
- the node to unregisterpublic void vetoableChange(java.beans.PropertyChangeEvent pce) throws java.beans.PropertyVetoException
vetoableChange
in interface java.beans.VetoableChangeListener
java.beans.PropertyVetoException
|
Nodenet Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |