org.jibx.runtime.impl
Class StringArray

java.lang.Object
  extended by org.jibx.runtime.impl.StringArray

public class StringArray
extends java.lang.Object

Growable String array with type specific access methods. This implementation is unsynchronized in order to provide the best possible performance for typical usage scenarios, so explicit synchronization must be implemented by a wrapper class or directly by the application in cases where instances are modified in a multithreaded environment.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
static int DEFAULT_SIZE
          Default initial array size.
 
Constructor Summary
StringArray()
          Default constructor.
StringArray(int size)
          Constructor with initial size specified.
StringArray(int size, int growth)
          Constructor with full specification.
StringArray(StringArray base)
          Copy (clone) constructor.
 
Method Summary
 void add(java.lang.String value)
          Add a value at the end of the array.
 void clear()
          Set the array to the empty state.
 java.lang.Object clone()
          Duplicates the object with the generic call.
 void ensureCapacity(int min)
          Ensure that the array has the capacity for at least the specified number of values.
 java.lang.String get(int index)
          Get a value from the array.
 boolean isEmpty()
          Check if array is empty.
 void remove(int count)
          Remove some number of values from the end of the array.
 int size()
          Get the number of values currently present in the array.
 java.lang.String[] toArray()
          Constructs and returns a simple array containing the same data as held in this array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default initial array size.

See Also:
Constant Field Values
Constructor Detail

StringArray

public StringArray(int size,
                   int growth)
Constructor with full specification.

Parameters:
size - number of String values initially allowed in array
growth - maximum size increment for growing array

StringArray

public StringArray(int size)
Constructor with initial size specified.

Parameters:
size - number of String values initially allowed in array

StringArray

public StringArray()
Default constructor.


StringArray

public StringArray(StringArray base)
Copy (clone) constructor.

Parameters:
base - instance being copied
Method Detail

ensureCapacity

public final void ensureCapacity(int min)
Ensure that the array has the capacity for at least the specified number of values.

Parameters:
min - minimum capacity to be guaranteed

add

public void add(java.lang.String value)
Add a value at the end of the array.

Parameters:
value - value to be added

remove

public void remove(int count)
Remove some number of values from the end of the array.

Parameters:
count - number of values to be removed
Throws:
java.lang.ArrayIndexOutOfBoundsException - on attempt to remove more than the count present

get

public java.lang.String get(int index)
Get a value from the array.

Parameters:
index - index of value to be returned
Returns:
value from stack
Throws:
java.lang.ArrayIndexOutOfBoundsException - on attempt to access outside valid range

toArray

public java.lang.String[] toArray()
Constructs and returns a simple array containing the same data as held in this array.

Returns:
array containing a copy of the data

clone

public java.lang.Object clone()
Duplicates the object with the generic call.

Overrides:
clone in class java.lang.Object
Returns:
a copy of the object

size

public int size()
Get the number of values currently present in the array.

Returns:
count of values present

isEmpty

public boolean isEmpty()
Check if array is empty.

Returns:
true if array empty, false if not

clear

public void clear()
Set the array to the empty state.



Project Web Site