au.com.zip.cs
Interface Entity

All Superinterfaces:
Comparable, HasID, TreeNode
All Known Subinterfaces:
User
All Known Implementing Classes:
EntityAdaptor, Group, Record, RelatedEntity, UserEntity, WrappedEntity

public interface Entity
extends TreeNode, HasID

A representation of a named entity. An Entity has an unique numeric id, a short name (eg a user's login name), a long name (eg a user's full name) and an enclosing EntityTable which accesses other Entities of this type.

Author:
Cameron Simpson <cs@zip.com.au> 8jul2002

Field Summary
static String DEFAULT_ID_ATTRIBUTENAME
          The default attribute name for the identity field: ID.
static long ID_NULL
          A sentinel value indicating no id value: -1.
 
Method Summary
 Object getAttribute(String name)
          Return the named attribute value from this entity.
 Map getAttributes()
          Return the named attributes and values of this Entity.
 long getDatedAttribute(String name)
          Return the milliseconds value corresponding to the named attribute value from this entity.
 EntityTable getEntityTable()
          Return this entity's enclosing EntityTable.
 long getID()
          Return the unique id for this Entity.
 int getIndex()
          Return the index of this Entity in the enclosing EntityTable.
 String getLongName()
          Return the long (descriptive) name for this entity.
 long getNumericAttribute(String name)
          Return the numeric value of the named attribute value from this entity, which must be a Number.
 String getShortName()
          Return the short name for this entity.
 void setAttribute(String name, Object value)
          Set the named attribute value from this entity.
 void setLongName(String newname)
          Set the Entity's long name.
 void setShortName(String newname)
          Set the Entity's short name.
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

ID_NULL

static final long ID_NULL
A sentinel value indicating no id value: -1.

See Also:
Constant Field Values

DEFAULT_ID_ATTRIBUTENAME

static final String DEFAULT_ID_ATTRIBUTENAME
The default attribute name for the identity field: ID.

See Also:
Constant Field Values
Method Detail

getEntityTable

EntityTable getEntityTable()
Return this entity's enclosing EntityTable.

Returns:
the table

getID

long getID()
Return the unique id for this Entity.

Specified by:
getID in interface HasID
Returns:
the id

getIndex

int getIndex()
Return the index of this Entity in the enclosing EntityTable.

Returns:
the Entity index

getShortName

String getShortName()
Return the short name for this entity.

Returns:
the short name

setShortName

void setShortName(String newname)
Set the Entity's short name. Normally it will be forbidden to set this to a name already in use. In many EntityTables this may be unimplemented.

Parameters:
newname - the new short name

getLongName

String getLongName()
Return the long (descriptive) name for this entity.

Returns:
the long name

setLongName

void setLongName(String newname)
Set the Entity's long name.

Parameters:
newname - the new long name

getAttributes

Map getAttributes()
Return the named attributes and values of this Entity. For example, these would be database table column names and values for a database record. Note that these are values associated with the Entity. The set of defined attributes (if such a thing even exists) is obtained from the Entity's enclosing EntityTable.
Note that this may be cached data or a snapshot of the values at the time of call. The caller should not expect the returned Map to track subsequent changes to the Entity.

Returns:
the attributes
See Also:
getEntityTable()

getAttribute

Object getAttribute(String name)
Return the named attribute value from this entity.

Parameters:
name - the attribute name
Returns:
the value

getNumericAttribute

long getNumericAttribute(String name)
Return the numeric value of the named attribute value from this entity, which must be a Number.

Parameters:
name - the attribute name
Returns:
the value

getDatedAttribute

long getDatedAttribute(String name)
Return the milliseconds value corresponding to the named attribute value from this entity. The attribute value must be a Number (if the date is stored as milliseconds) or a Date.

Parameters:
name - the attribute name
Returns:
the value

setAttribute

void setAttribute(String name,
                  Object value)
Set the named attribute value from this entity.

Parameters:
name - the attribute name
value - the new value