xbn.array
Class VectorWrapper

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.array.VectorWrapper
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
VWChar, VWDouble, VWInt, VWNamed, VWObject, VWString

public abstract class VectorWrapper
extends XBNObject
implements Cloneable

Wraps around a Vector, to aid and enhance the process of creating arrays of unknown length. See java.util.Vector.

Source code:  VectorWrapper.java.  Example code  See the example code for VWInt.

This convenience class manages a Vector internally: creates it, validates added objects, and is ultimately converted to an array of the desired type. The order in which objects are added is preserved in the resulting array.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
VectorWrapper()
          Create a VectorWrapper with default settings.
VectorWrapper(boolean b_orderDirAscDesc)
          Create a VectorWrapper.
VectorWrapper(boolean b_addInOrder, boolean b_orderDirAscDesc)
          Create a VectorWrapper.
VectorWrapper(Vector v_ector)
          Create a VectorWrapper.
VectorWrapper(Vector v_ector, boolean b_orderDirAscDesc)
          Create a VectorWrapper.
VectorWrapper(Vector v_ector, boolean b_addInOrder, boolean b_orderDirAscDesc)
          Create a VectorWrapper.
 
Method Summary
 boolean doAddInOrder()
          When elements are added, should they be added in order of something?
 Object elementAt(int i_dx)
          Get the requested element.
 String getList(String s_divider)
          Get a list of all elements.
 boolean getOrderDirAscDesc()
          When elements are added and definitely ordered, in which direction should ordering occur?
abstract  String getString(int i_dx)
          Get the element at the requested index, as a string.
 Vector getVector()
          Get the vector for direct manipulation.
 void initializeVector()
          Initialize the vector.
abstract  boolean isNull(int i_dx)
          Is the element at the requested index null?.
 int size()
          How many elements are in the internal Vector?
 
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

VectorWrapper

public VectorWrapper()

Create a VectorWrapper with default settings.

Equal to VectorWrapper(new Vector())


VectorWrapper

public VectorWrapper(Vector v_ector)

Create a VectorWrapper.

Equal to VectorWrapper(v_ector, false, false)


VectorWrapper

public VectorWrapper(boolean b_orderDirAscDesc)

Create a VectorWrapper.

Equal to VectorWrapper((new Vector()), b_orderDirAscDesc)


VectorWrapper

public VectorWrapper(Vector v_ector,
                     boolean b_orderDirAscDesc)

Create a VectorWrapper.

Equal to VectorWrapper(v_ector, true, b_orderDirAscDesc)


VectorWrapper

public VectorWrapper(boolean b_addInOrder,
                     boolean b_orderDirAscDesc)

Create a VectorWrapper.

Equal to VectorWrapper((new Vector()), b_addInOrder, b_orderDirAscDesc)


VectorWrapper

public VectorWrapper(Vector v_ector,
                     boolean b_addInOrder,
                     boolean b_orderDirAscDesc)

Create a VectorWrapper.

Parameters:
v_ector - The vector to add elements to. May not be null. It is assumed that this is appropriate for this VectorWrapper (for example, ordered in the proper way, as dictated by b_addInOrder and b orderDirAscDesc). If not, this class may behave unpredictably. See getVector().
b_addInOrder - If true, when a [thing] is added, then add it so that the resulting (internally-held) Vector is ordered by [whatever is appropriate in the sub-class], in the direction defined by b_orderDirAscDesc. See doAddInOrder
bOrderDirAscDesc - If b_addInOrder is true, then this defines the direction in which ordering should occur. If true, then ordering is by ascending name (1, 2, 3). If false, then descending (3, 2, 1). See getOrderDirAscDesc.
Method Detail

getVector

public Vector getVector()

Get the vector for direct manipulation.


doAddInOrder

public final boolean doAddInOrder()

When elements are added, should they be added in order of something?

Returns:
b_addInOrder Exactly as provided in the constructor.

getOrderDirAscDesc

public final boolean getOrderDirAscDesc()

When elements are added and definitely ordered, in which direction should ordering occur?

Returns:
b_orderDirAscDesc Exactly as provided in the constructor.

elementAt

public Object elementAt(int i_dx)

Get the requested element.

Parameters:
i_dx - The Vector index. Must range 0..[size() - 1], inclusive.

initializeVector

public void initializeVector()

Initialize the vector.

Use this when you want to start from scratch, with zero elements.


size

public int size()

How many elements are in the internal Vector?

Returns:
getVector().size()

getString

public abstract String getString(int i_dx)

Get the element at the requested index, as a string.

Parameters:
i_dx - The Vector index to retrieve. Must range 0..[size() - 1], inclusive.

isNull

public abstract boolean isNull(int i_dx)

Is the element at the requested index null?.

Parameters:
i_dx - The Vector index to analyze. Must range 0..[size() - 1], inclusive.
true - If the requested Vector element is null.
false If non-null.

getList

public String getList(String s_divider)

Get a list of all elements. This is not the most efficient, because it always calls getString. It's good for debugging, though.




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