xbn.array
Class AOSLCreator

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.util.XBNLocked
              |
              +--xbn.array.AOSLCreator
All Implemented Interfaces:
LockOneWay

public class AOSLCreator
extends XBNLocked
implements LockOneWay

Convenience class for creating an AOSLookup. See AOSLookup.

Source code:  AOSLCreator.java.  Example code  See the source code for UtilArray.getAOSLFromPA.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
AOSLCreator()
          Create an AOSLCreator with default values.
AOSLCreator(boolean b_dupStrsOk)
          Create an AOSLCreator.
AOSLCreator(boolean b_dupStrsOk, boolean b_listStrsOnError)
          Create an AOSLCreator.
AOSLCreator(boolean b_dupStrsOk, int i_unqStrCount)
          Create an AOSLCreator.
AOSLCreator(boolean b_dupStrsOk, int i_unqStrCount, boolean b_listStrsOnError)
          Create an AOSLCreator.
AOSLCreator(int i_unqStrCount)
          Create an AOSLCreator.
AOSLCreator(int i_unqStrCount, boolean b_listStrsOnError)
          Create an AOSLCreator.
 
Method Summary
 void addString(String s_tr)
          Add a new string to the AOSLookup.
 boolean areDupStringsOk()
          Are duplicate strings okay?
 boolean doListStrsOnError()
          In the case of an error, should the list of strings be presented in the error message?
 AOSLookup getAOSLookup()
          Get the AOSLookup.
 int getCountAbs()
          How many total strings have been added?.
 int getCountUnq()
          How many unique strings have been added?.
 int getUnqStrCount()
          Is it known how many unique strings will be provided?
 boolean isLocked()
          Is the value locked?
 void lock()
          Lock the value, forbidding further sets.
 boolean wasLastStringUnique()
          Was the string-just-added unique?
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AOSLCreator

public AOSLCreator()

Create an AOSLCreator with default values.

Equal to AOSLCreator(true)


AOSLCreator

public AOSLCreator(boolean b_dupStrsOk)

Create an AOSLCreator.

Equal to AOSLCreator(b_dupStrsOk, -1)


AOSLCreator

public AOSLCreator(int i_unqStrCount)

Create an AOSLCreator.

Equal to AOSLCreator(true, -1)


AOSLCreator

public AOSLCreator(boolean b_dupStrsOk,
                   int i_unqStrCount)

Create an AOSLCreator.

Equal to AOSLCreator(b_dupStrsOk, i_unqStrCount, true)


AOSLCreator

public AOSLCreator(boolean b_dupStrsOk,
                   boolean b_listStrsOnError)

Create an AOSLCreator.

Equal to AOSLCreator(b_dupStrsOk, -1, b_listStrsOnError)


AOSLCreator

public AOSLCreator(int i_unqStrCount,
                   boolean b_listStrsOnError)

Create an AOSLCreator.

Equal to AOSLCreator(true, i_unqStrCount, b_listStrsOnError)


AOSLCreator

public AOSLCreator(boolean b_dupStrsOk,
                   int i_unqStrCount,
                   boolean b_listStrsOnError)

Create an AOSLCreator.

Parameters:
b_dupStrsOk - Are duplicate strings acceptable? If true, then yes. If false, no. See areDupStringsOk and addString.
i_unqStrCount - How many unique strings will exist in the AOSLookup (will be added via addString)? If -1, then the number of unique strings is not known. Otherwise, may not be less than one. See getUnqStrCount and addString.
b_listStrsOnError - Should the list of strings be printed in any error messages thrown? If true, then yes. If false, no. See doListStrsOnError.
Method Detail

areDupStringsOk

public final boolean areDupStringsOk()

Are duplicate strings okay?

Returns:
b_dupStrsOk Exactly as provided to the constructor.

getUnqStrCount

public final int getUnqStrCount()

Is it known how many unique strings will be provided?

Returns:
i_unqStrCount Exactly as provided to the constructor.

doListStrsOnError

public final boolean doListStrsOnError()

In the case of an error, should the list of strings be presented in the error message?

This setting, when getAOSLookup is called, is provided directly to the AOSLookup constructor.

Returns:
b_listStrsOnError Exactly as provided to the constructor.

addString

public final void addString(String s_tr)

Add a new string to the AOSLookup.

It is expected strings are added in the same order in which they originally existed. The first string exists at absolute array index zero, the second at array index one, and so on.

Parameters:
s_tr - The string
Throws:
LockedException - If isLocked equals true. This means all strings have been added.
AssertException - If...
  • ...areDupStringsOk equals false, and s_tr is equal to a string that was previously added.
  • ...getUnqStrCount does not equal -1, and the [value of getUnqStrCount]-th unique string is (attempted to be) added.

wasLastStringUnique

public final boolean wasLastStringUnique()

Was the string-just-added unique?

Returns:
true If the string just added is not equal to any string added before it (or is the first).
false If the string just added was a duplicate.
Throws:
AssertException - If no strings have been added (getCountUnq equals zero).

getCountUnq

public final int getCountUnq()

How many unique strings have been added?. See addString.


getCountAbs

public final int getCountAbs()

How many total strings have been added?. See addString.


getAOSLookup

public final AOSLookup getAOSLookup()

Get the AOSLookup.


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