|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.argouml.cognitive.ItemUID
An instances of this class is supposed to be attached to an instance of another class to uniquely identify it. 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 | |
private String |
id
This actual ID of this instance. |
private static Logger |
LOG
The logger. |
private static Class |
MYCLASS
Keeps a reference to the Class object of this class. |
Constructor Summary | |
ItemUID()
Constructs a new ItemUID and creates a new ID for it. |
|
ItemUID(String param)
Constructs a new ItemUID and uses the String param as the ID. |
Method Summary | |
protected static String |
createObjectID(Object obj)
Tries to create a new ID for the object. |
static String |
generateID()
Generates a new unique ID and returns it as a String. |
static String |
getIDOfObject(Object obj,
boolean canCreate)
Obtains the ID of an object and returns it as a String. |
protected static String |
readObjectID(Object obj)
Tries to read the ID of the object. |
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 |
private static final Logger LOG
private static final Class MYCLASS
private String id
Constructor Detail |
public ItemUID()
public ItemUID(String param)
param
- The ID to used for the new instance.toString()
Method Detail |
public String toString()
ItemUID(String)
public static String generateID()
public static String getIDOfObject(Object obj, boolean canCreate)
obj
- the Object to get the ID of.canCreate
- If an ID can be created, should object not have one.
protected static String readObjectID(Object obj)
obj
- The object whose ID to read.
protected static String createObjectID(Object obj)
obj
- The object to assign a new ID.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20050222) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |