- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- LeaveAloneToken, ReferenceCookie
public class MagicCookie
extends java.lang.Object
implements java.io.Serializable
From the Hacker's Map/Jargon file: magic cookie [UNIX] n. 1. Something
passed between routines or programs that enables the receiver to perform some
operation; a capability ticket or opaque identifier. Especially used of small
data objects that contain data encoded in a strange or intrinsically
machine-dependent way. ... The phrase it hands you a magic cookie
means it returns a result whose contents are not defined but which can be
passed back to the same or some other program later.
I generally use MagicCookies as objects whose only property is their own
identity; this is useful when, for instance, traversing directed acyclic (or
hell, cyclic) digraphs when you need some mechanism of tracking whether this
traversal has already happened at a node without actually saving a list of
traversed nodes. Also use it when a data source/model is updated
asynchronously to its display/viewing, but you need a quick verification of
whether the source has changed.
Be sure to use the equals() function to check if two cookies match; it is
currently done based on object identity but that will change if I start
passing them across memory spaces for some reason.
- See Also:
- Serialized Form