|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.argouml.cognitive.ItemUID
Instances of this class is supposed to be attached to other instances of other classes to uniquely identify them. It is intended that such a tagging should be persistent over saving and loading, if applicable.
The class also harbors the
getIDOfObject(Object, boolean)
which provides
a way to get the ItemUID of any object with a method
ItemUID getItemUID()
and creating new ItemUIDs for any object with a method
setItemUID(ItemUID)
using reflection in java.
A class intended to be tagged must at least provide a
ItemUID getItemUID()
method. It may also provide a
void setItemUID(ItemUID id)
such that getItemUID() will return id if a call returns successfully,
and which is stored persistently should the tagged object be stored.
This allows this class to automatically tag an object when necessary,
but it is allowed to tag classes by other means and only provide the
getItemUID() call.
A critical requirement for this class is that the cognitive component
is supposed to work with general objects. This class is a wrapper around
places where the component needs persistent identities of objects, since
I have said that some features cannot be implemented without that, such as
ResolvedCritic, and so far noone has shown me wrong (though I wouldn't
mind). It is for this reason that some perhaps ugly looking exceptions in
this code must be considered perfectly normal conditions. Failure of some
object to work with tagging must be handled by the cognitive component
programmer and it is (see eg ResolvedCritic).
A possible future change would be to allow tag handlers to be registered
with this class to handle other preexisting tagging mechanisms, which
could be used to remove the dependancy to the model component here, which
I find a bit unaesthetic. So far, not enough to write it (though it is not
much work).
Field Summary | |
protected java.lang.String |
_id
This actual ID of this instance. |
protected static java.lang.Class |
_myclass
Keeps a reference to the Class object of this class |
protected static org.apache.log4j.Logger |
cat
|
Constructor Summary | |
ItemUID()
Constructs a new ItemUID and creates a new ID for it. |
|
ItemUID(java.lang.String param)
Constructs a new ItemUID and uses the String param as the ID. |
Method Summary | |
protected static java.lang.String |
createObjectID(java.lang.Object obj)
Tries to create a new ID for the object. |
static java.lang.String |
generateID()
Generates a new unique ID and returns it as a String. |
static java.lang.String |
getIDOfObject(java.lang.Object obj,
boolean canCreate)
Obtains the ID of an object and returns it as a String. |
protected static java.lang.String |
readObjectID(java.lang.Object obj)
Tries to read the ID of the object. |
java.lang.String |
toString()
Returns the ID of this ItemUID as a String. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger cat
protected static final java.lang.Class _myclass
protected java.lang.String _id
Constructor Detail |
public ItemUID()
public ItemUID(java.lang.String param)
param
- The ID to used for the new instance.toString()
Method Detail |
public java.lang.String toString()
ItemUID(String)
public static java.lang.String generateID()
public static java.lang.String getIDOfObject(java.lang.Object obj, boolean canCreate)
protected static java.lang.String readObjectID(java.lang.Object obj)
protected static java.lang.String createObjectID(java.lang.Object obj)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20040316) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |