xbn.named
Class NamedArray

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.named.NamedArray
All Implemented Interfaces:
Named
Direct Known Subclasses:
JDCArray, PTArray, TDOSArray, TemplateArray

public class NamedArray
extends XBNObject
implements Named

Manage an array of any object implementing the Named interface. Using a AOSLookup, this class provides quick access to the array, with error protection.

Source code:  NamedArray.java.

This object holds both the array of Named objects, as well as the AOSLookup. NamedArray also implements Named, therefore having a name itself. Because of this, you could have a NamedArray of NamedArrays. Pretty cool, eh? :' )


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
NamedArray(Named[] a_named)
          Create a NamedArray.
NamedArray(Named[] a_named, boolean b_listNames)
          Create a NamedArray.
NamedArray(NamedArray named_array)
          Create an as-deep-as-possible copy of the provided NamedArray.
NamedArray(String s_name, APNamed ap_named, AOSLookup aos_lookup, boolean b_validate)
          Create a NamedArray manually.
NamedArray(String s_name, Named[] a_named)
          Create a NamedArray.
NamedArray(String s_name, Named[] a_named, AOSLookup aos_lookup)
           
NamedArray(String s_name, Named[] a_named, AOSLookup aos_lookup, boolean b_validate)
          Create a NamedArray manually.
NamedArray(String s_name, Named[] a_named, boolean b_listNames)
          Create a NamedArray.
 
Method Summary
 boolean doesExist(String s_name)
          Does the provided name represent an actually-existing Named object?
 AOSLHashtable getAOSLHashtable()
          Return the AOSLHashtable for direct manipulation.
 AOSLookup getAOSLookup()
          Return the AOSLookup for direct manipulation.
 APNamed getAPNamed()
          Get the APNamed for direct manipulation.
 int getArrIdx(String s_name)
          Get the Named object at the requested array index.
 int getLength()
          How many Named objects exist in this NamedArray?
 String getName()
          What is the name of this object?.
 String getName(int i_dx)
          Get the name of the Named object at the requested array index.
 Named getNamed(int i_dx)
          Get the Named object at the requested array index.
 Named getNamed(String s_name)
          Get the Named object at the requested array index.
 String getNameList()
          Get a listing of every name.
 String getNameList(String s_divider)
          Get a listing of every name.
 String getNameList(String s_prefix, String s_postfix)
          Get a listing of every name.
 String getNameList(String s_prefix, String s_divider, String s_postfix)
          Get a listing of every name.
protected  void throwAXWithName(String s_callingFunc, String s_errorMsg)
          Throw an exception with getName() as part of the message.
 String toString()
          Get some information about this NamedArray.
 String toString(boolean b_subTS)
          Get some information about this NVArray object, and optionally about the Atomic levels herein.
 
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, wait, wait, wait
 

Constructor Detail

NamedArray

public NamedArray(Named[] a_named)

Create a NamedArray.

Equal to NamedArray(a_named, true)


NamedArray

public NamedArray(Named[] a_named,
                  boolean b_listNames)

Create a NamedArray.

Equal to NamedArray(null, a_named, true)


NamedArray

public NamedArray(String s_name,
                  Named[] a_named)

Create a NamedArray.

Equal to NamedArray(s_name, a_named, true)


NamedArray

public NamedArray(String s_name,
                  Named[] a_named,
                  boolean b_listNames)

Create a NamedArray.

Parameters:
s_name - The name of this NamedArray. See getName.
a_named - The array of Named objects. Must be non-null, at least one element in length, no elements may be null, and every element's name must be unique. Note that the array is cloned, but all Named elements are unaltered (in other words, the Named elements are not altered, but the array they are contained in, is). See UtilNamed.getShallowClone.
b_listNames - Passed directly to the UtilArray.getAOSLFromPA, which creates the internal AOSLookup for this class.

NamedArray

public NamedArray(String s_name,
                  Named[] a_named,
                  AOSLookup aos_lookup)

NamedArray

public NamedArray(String s_name,
                  Named[] a_named,
                  AOSLookup aos_lookup,
                  boolean b_validate)

Create a NamedArray manually.


NamedArray

public NamedArray(String s_name,
                  APNamed ap_named,
                  AOSLookup aos_lookup,
                  boolean b_validate)

Create a NamedArray manually.

Parameters:
s_name - The name of this NamedArray.
a_named - The array of Named objects. Must be non-null, and the names of these Named objects must map one-to-one with those existing in aos_lookup.
aos_lookup - The AOSLookup for a_named. Must be non-null, and the names contained in it must map one-to-one with those existing in a_named. This is only enforced when b_validate is true.
b_validate - If true, then verify that aos_lookup and a_named are legal for a NamedArray. If false, then you're on your own, as far as this object behaving as documented. If you are absolutely certain that things are okay, it will give you somewhat of a speed increase to make this false.

NamedArray

public NamedArray(NamedArray named_array)

Create an as-deep-as-possible copy of the provided NamedArray. Everything down-to-but-not-including the Named objects are deeply cloned.

If you need a deep copy, you must manually do the copying yourself, and use the manual constructor. Since Named is just an interface, it is not possible to clone it here.

Parameters:
named_array - The NamedArray to copy. May not be null.
Method Detail

getAOSLookup

public final AOSLookup getAOSLookup()

Return the AOSLookup for direct manipulation.


getAOSLHashtable

public final AOSLHashtable getAOSLHashtable()

Return the AOSLHashtable for direct manipulation.


getAPNamed

public final APNamed getAPNamed()

Get the APNamed for direct manipulation.

Returns:
ap_named Exactly as provided to the constructor.

getNameList

public final String getNameList()

Get a listing of every name.

Returns:
(new ListPA()).get(getAPNamed().getPASNamed())

getNameList

public final String getNameList(String s_divider)

Get a listing of every name.

Returns:
(new ListPA(s_divider)).get(getAPNamed().getPASNamed())

getNameList

public final String getNameList(String s_prefix,
                                String s_postfix)

Get a listing of every name.

Returns:
(new ListPA(s_prefix, s_postfix)).get(getAPNamed().getPASNamed())

getNameList

public final String getNameList(String s_prefix,
                                String s_divider,
                                String s_postfix)

Get a listing of every name.

Returns:
(new ListPA(s_prefix, s_divider, s_postfix)).get(getAPNamed().getPASNamed())

getLength

public final int getLength()

How many Named objects exist in this NamedArray?

Returns:
getAPNamed().getLength()

doesExist

public final boolean doesExist(String s_name)

Does the provided name represent an actually-existing Named object?

Returns:
getAOSLHashtable().containsKey(s_name)

getArrIdx

public final int getArrIdx(String s_name)

Get the Named object at the requested array index.

Parameters:
i_dx - Must be between 0 and (getCount - 1), inclusive.

getNamed

public final Named getNamed(String s_name)

Get the Named object at the requested array index.

Parameters:
i_dx - Must be between 0 and (getCount - 1), inclusive.

getNamed

public final Named getNamed(int i_dx)

Get the Named object at the requested array index.

Parameters:
i_dx - Must be between 0 and (getCount - 1), inclusive.

getName

public String getName(int i_dx)

Get the name of the Named object at the requested array index.

Parameters:
i_dx - Must be valid.

getName

public 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

toString

public String toString()

Get some information about this NamedArray.

Overrides:
toString in class Object
Returns:
toString(true)

throwAXWithName

protected void throwAXWithName(String s_callingFunc,
                               String s_errorMsg)

Throw an exception with getName() as part of the message.

Equal to throwAX(s_callingFunc +
         [UtilString].getConditional(" [getName()=", getName(), "]") +
         ":  " + s_errorMsg)


toString

public String toString(boolean b_subTS)

Get some information about this NVArray object, and optionally about the Atomic levels herein.

Parameters:
b_subTS - If true, then display all toStrings for the sub-Named objects. If false, then display the names of all internal Named objects.



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