xbn.array
Class UniqueString

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.util.XBNLocked
              |
              +--xbn.array.UniqueString
All Implemented Interfaces:
Cloneable, LockOneWay, Named

public class UniqueString
extends XBNLocked
implements Named, LockOneWay, Cloneable

Metadata for a unique string contained in an array. This object populates the "value" side of the AOSLookup's (internal) Hashtable. Also see AOSLCreator.

Source code:  UniqueString.java


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
UniqueString(String s_tr, int i_unqArrIdx)
          Create a UniqueString.
 
Method Summary
protected  Object clone()
          Get a full (deep) copy of this UniqueString as an Object.
 int getInstanceCount()
          How many absolute instances (duplicates) of this unique string exist in the array?
 String getName()
          What is the name of this object?.
 String getString()
          Get the unique string.
 int getUnqArrIdx()
          Get the unique array index of the string.
 UniqueString getUSClone()
          Get a full (deep) copy of this UniqueString.
 void incInstanceCount()
          Declare that another copy of this unique string was found in the array.
 boolean isLocked()
          Is the value locked?
 boolean isMultiple()
          Are there more than one instance of this unique string?
 boolean isSingular()
          Is there exactly one instance of this unique string?
 void lock()
          Lock the value, forbidding further sets.
 
Methods inherited from class xbn.util.XBNLocked
throwLX, throwLX, throwLXIfLocked, throwLXIfLocked, throwLXIfLocked, throwLXIfUnlocked
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniqueString

public UniqueString(String s_tr,
                    int i_unqArrIdx)

Create a UniqueString.

Parameters:
s_tr - The unique string. May not be null.
i_unqArrIdx - The unique array index of the s_tr. May not be less than zero.
Method Detail

getString

public final String getString()

Get the unique string.

Returns:
s_tr Exactly as provided to the constructor.

getUnqArrIdx

public final int getUnqArrIdx()

Get the unique array index of the string.

Returns:
i unqArrIdx Exactly as provided to the constructor.

getInstanceCount

public final int getInstanceCount()

How many absolute instances (duplicates) of this unique string exist in the array?

Returns:
[1 + the number of times incInstanceCount() was called]

isSingular

public boolean isSingular()

Is there exactly one instance of this unique string?

Returns:
(getInstanceCount() == 1)

isMultiple

public boolean isMultiple()

Are there more than one instance of this unique string?

Returns:
!isSingular()

incInstanceCount

public final void incInstanceCount()

Declare that another copy of this unique string was found in the array.

After this class is created, but before this function is called, the instance count is set to one. The first call to this function sets the instance count to two.

Throws:
LockedException - If isLocked equals true.

getUSClone

public final UniqueString getUSClone()

Get a full (deep) copy of this UniqueString.


clone

protected final Object clone()
                      throws CloneNotSupportedException

Get a full (deep) copy of this UniqueString as an Object.

Overrides:
clone in class Object

getName

public final String getName()
Description copied from interface: Named

What is the name of this object?. This identifier is used throughout the xbn.named package, particularly in NamedArray.

Specified by:
getName in interface Named

lock

public final void lock()
Description copied from interface: LockOneWay

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.

Specified by:
lock in interface LockOneWay
Following copied from interface: xbn.util.LockOneWay
Throws:
AssertException - If isLocked is true.

isLocked

public final boolean isLocked()
Description copied from interface: LockOneWay

Is the value locked?

Specified by:
isLocked in interface LockOneWay
Following copied from interface: xbn.util.LockOneWay
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