xbn.util
Interface LockOneWay

All Known Implementing Classes:
AOSLCreator, PACChar, PAIInt, PASAOObject, PASInt, UniqueString

public interface LockOneWay

Classes implementing LockOneWay indicate their values may be locked.

Source code:  LockOneWay.java.

After the value is locked, it may not be altered again. A value may be locked at any time, but may not be unlocked.

If you allow lcking to occur in the constructor of your LockOneWay object, remember to set any values *before* locking. Also, consider nullifying any obects no longer needed, such as "rule" objects used to validate potential sets. Since sets are no longer allowed once locked, there's no need for the rule objects anymore. Possible exception is if the rule object would be needed for cloning, unless the cloned object would also be locked.

   //REQUIRED BY xbn.util.LockOneWay...START
      public void lock()  {
         bLocked = true;
      }
      public boolean isLocked()  {
         return bLocked;
      }
   //REQUIRED BY xbn.util.LockOneWay...END


Method Summary
 boolean isLocked()
          Is the value locked?
 void lock()
          Lock the value, forbidding further sets.
 

Method Detail

lock

public void lock()

Lock the value, forbidding further sets. There is no way to unlock the value, so consider this function a "one way ticket".

It is recommended to crash if the value is already locked (isLocked is true). You must crash in your class' "set" functions when isLocked is true.

Throws:
AssertException - If isLocked is true.

isLocked

public boolean isLocked()

Is the value locked?

Returns:
true If lock has been called at some moment before now. This indicates that the value is locked and may no longer be altered.
false If lock has not yet been called. This indicates that the value may still be altered.



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo