This class provides a cannonical mapping between fields in TextAttribute
and instances of itself. It is used by AttributeMap to serialize
and deserialize TextAttribute to preserve uniqueness of TextAttribute
instances (ie so that TextAttribute instances remain singletons),
and to provide compatability between 1.1 and 1.2 versions of
TextAttribute.
Example use - instead of doing this:
out.writeObject(anAttribute);
do this:
out.writeObject(AttributeKey.mapAttributeToKey(anAttribute));
Similarly, instead of this:
anAttribute = in.readObject();
do this:
anAttribute = AttributeKey.mapKeyToAttribute(in.readObject());
If anAttribute is not a known TextAttribute, then mapAttributeToKey
will just return its argument. Similarly, mapKeyToAttribute will
return its argument if the argument is not a known AttributeKey.
|