net.javamud.core
Class MudObject

java.lang.Object
  |
  +--net.javamud.core.MudObject
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
NullMudObject

public abstract class MudObject
extends Object
implements Comparable

Base object for all objects in the MUD

Author:
Timothy Hinchcliffe
Created On:
10 May 2002

Field Summary
 ACL acl
          Access Control List.
protected  MudObject container
          Parent container.
protected  Set contains
          Set of MudObjects that this contains.
protected  String identity
          Unique identity for this
protected  long minLife
          Temporary object may not be expired before this time.
 Set referances
          MudObjects that refer to this MudObject
 
Constructor Summary
MudObject()
          Constructor for the MudObject object.
 
Method Summary
 boolean canExpire()
          Can this object be expired?.
 int compareTo(Object o)
          Implementation of Comparable.compareTo
 void deRef(MudObject o)
          Remove any referance to o.
 MudObject enter(MudObject entering)
          Called it indicate entering if moving in to this MudObject.
 boolean exit(MudObject exiting)
          Remove a MudObject from this one.
 boolean expire()
          Clean up object ready for dereferancing.
 String getIdentity()
          Gets the identity attribute of the MudObject object
 void load(Storage store)
          Reforms this MudObject from the given data store.
 void replace(MudObject o, MudObject n)
          Replace o with n
 PersistentObject save(Storage store)
          Saves this MudObject into a data store ready for serialization.
 void setIdentity(String identity)
          Unique Identity of this.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acl

public ACL acl
Access Control List.
Be carefull about this when replacing MudObjects as ACLs inherit via a seperate ACL hierarchy, not through the MudObject hierarchy.


referances

public Set referances
MudObjects that refer to this MudObject


container

protected MudObject container
Parent container.


contains

protected Set contains
Set of MudObjects that this contains.


identity

protected String identity
Unique identity for this


minLife

protected long minLife
Temporary object may not be expired before this time. Object it not temporary if this is 0.

Constructor Detail

MudObject

public MudObject()
Constructor for the MudObject object.

Method Detail

canExpire

public boolean canExpire()
Can this object be expired?. Will return true if minLife > 0 and Globals.globals.ticks > minLife and referances.size() <= 1.

Returns:
True if this object can be expired.

compareTo

public int compareTo(Object o)
              throws ClassCastException
Implementation of Comparable.compareTo

Specified by:
compareTo in interface Comparable
Parameters:
o - Object to compare to
Returns:
See java.lang.Comparable.compareTo
Throws:
ClassCastException - If o is not a MudObject

deRef

public void deRef(MudObject o)
Remove any referance to o.

Parameters:
o - a MudObject to dereferance.

enter

public MudObject enter(MudObject entering)
Called it indicate entering if moving in to this MudObject.
Returns the MudObject that it moved in to (to allow for redirections, such as doors leading to rooms.).

Parameters:
entering - Object that is entering this room.
Returns:
Final object that entering ended up in.

exit

public boolean exit(MudObject exiting)
Remove a MudObject from this one. Opposite of enter(MudObject).

Parameters:
exiting - MudObject that is leaving this container.
Returns:
False if exiting wasn't in this container.

expire

public boolean expire()
Clean up object ready for dereferancing.

Returns:
Return true if safe to dereferance.

getIdentity

public String getIdentity()
Gets the identity attribute of the MudObject object

Returns:
The identity value

load

public void load(Storage store)
Reforms this MudObject from the given data store.

Parameters:
store - Description of the Parameter

replace

public void replace(MudObject o,
                    MudObject n)
Replace o with n

Parameters:
o - Old MudObject
n - New MudObject

save

public PersistentObject save(Storage store)
Saves this MudObject into a data store ready for serialization.

Parameters:
store - Storage object
Returns:
data store for this object.

setIdentity

public void setIdentity(String identity)
                 throws DuplicateIdentityException
Unique Identity of this.

Parameters:
identity - The new identity value
Throws:
DuplicateIdentityException - Thrown by Globals.globals.linker.register(this).
See Also:
Linker.register(MudObject)