xbn.array
Class APString

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.array.ArrayProtector
              |
              +--xbn.array.APString
All Implemented Interfaces:
Cloneable

public class APString
extends ArrayProtector

An ArrayProtector for an array of strings.

Source code:  APString.java


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
APString(String[] a_string)
          Create an APString.
APString(String[] a_string, boolean b_shallowCloneAOS)
          Create an APString.
 
Method Summary
 void addToVWString(VWString ac_string)
          Add the string-array-being-protected to the provided VWString.
protected  Object clone()
          Get a full (deep) copy of this APString as an Object.
 String[] getAOSShallowClone()
          Get a copy of the string-array-being-wrapped, with references to the original string elements.
 APString getAPSClone()
          Get a full (deep) copy of this APString.
 int getLength()
          How many elements exist in the array-being-protected?
 PASString getPASString()
          Get a new PASString wrapping around the string-array-being-protected.
 PASString getPASString(PARString par_string)
          Get a new PASString wrapping around the string-array-being-protected.
 String getString(int i_dx)
          Get the string at the requested array index.
 boolean isNull()
          As a whole, is the array-being-protected null?
 boolean isNull(int i_dx)
          Is the string at the provided array index null?
 String toString()
          Get some information about this ArrayProtector.
 
Methods inherited from class xbn.array.ArrayProtector
getList, getList, getList, getList, getPASArrayProtector
 
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, wait, wait, wait
 

Constructor Detail

APString

public APString(String[] a_string)

Create an APString.

Equal to APString(a_string, false)


APString

public APString(String[] a_string,
                boolean b_shallowCloneAOS)

Create an APString.

Parameters:
a_string - The array of strings to protect.
b_shallowCloneAOS - Should a_string be (shallow-ly) cloned to start off--here in this constructor? This recreates a_string as a shallow clone of itself, to prevent external code from altering it.
Method Detail

isNull

public final boolean isNull()
Description copied from class: ArrayProtector

As a whole, is the array-being-protected null?

Overrides:
isNull in class ArrayProtector
Returns:
(a_string == null) Where a_string is exactly as provided to the constructor.

isNull

public final boolean isNull(int i_dx)

Is the string at the provided array index null?

Overrides:
isNull in class ArrayProtector
Returns:
(as[i_dx] == null)

getLength

public final int getLength()
Description copied from class: ArrayProtector

How many elements exist in the array-being-protected?

Overrides:
getLength in class ArrayProtector
Returns:
a_string.length Where a_string is exactly as provided to the constructor.
Throws:
AssertException - If isNull is true.

getString

public final String getString(int i_dx)

Get the string at the requested array index.

Overrides:
getString in class ArrayProtector
Parameters:
i_dx - The array index. Must range 0..[getLength() - 1], inclusive.
Returns:
a_string[i_dx] Where a_string is exactly as provided to the constructor.
Throws:
AssertException - If isNull is true.

addToVWString

public final void addToVWString(VWString ac_string)

Add the string-array-being-protected to the provided VWString.

If isNull equals true, nothing is done. If false, then ac_string.addArray([INTERNAL STRING ARRAY]) is called.

Parameters:
ac_string - The VWString to add to. May not be null.

getAOSShallowClone

public final String[] getAOSShallowClone()

Get a copy of the string-array-being-wrapped, with references to the original string elements.

Returns:
(new UtilArray()).getAOOShallowClone(a_string) Where a_string is exactly as provided to the constructor. Note that this function only creates the clone once. Once created, the copy is then internally stored, and returned for all subsequent calls.

getPASString

public final PASString getPASString()

Get a new PASString wrapping around the string-array-being-protected.

Returns:
getPASString(new PARString())

getPASString

public final PASString getPASString(PARString par_string)

Get a new PASString wrapping around the string-array-being-protected.

Returns:
(new PASString(getAOSShallowClone(), par_string, true))

toString

public String toString()
Description copied from class: ArrayProtector

Get some information about this ArrayProtector.

Overrides:
toString in class ArrayProtector

getAPSClone

public final APString getAPSClone()

Get a full (deep) copy of this APString.

Returns:
(APString)clone()

clone

protected final Object clone()
                      throws CloneNotSupportedException

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

I know this uses a "shallow" clone of the string array. Does it matter? Is it no different than manually creating new string copies?

Overrides:
clone in class Object
Returns:
(new APString(getAOSShallowClone()))



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