Package org.jibx.runtime.impl
Class GrowableStringArray
- java.lang.Object
-
- org.jibx.runtime.impl.GrowableStringArray
-
public class GrowableStringArray extends Object
GrowableStringarray 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.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_SIZEDefault initial array size.
-
Constructor Summary
Constructors Constructor Description GrowableStringArray()Default constructor.GrowableStringArray(int size)Constructor with initial size specified.GrowableStringArray(int size, int growth)Constructor with full specification.GrowableStringArray(GrowableStringArray base)Copy (clone) constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String value)Add a value at the end of the array.voidaddAll(String[] values)Add an array of values at the end of the array.voidclear()Set the array to the empty state.Objectclone()Duplicates the object with the generic call.voidensureCapacity(int min)Ensure that the array has the capacity for at least the specified number of values.Stringget(int index)Get a value from the array.booleanisEmpty()Check if array is empty.voidremove(int count)Remove some number of values from the end of the array.voidset(int index, String value)Overwrite an existing value in the array.intsize()Get the number of values currently present in the array.String[]toArray()Constructs and returns a simple array containing the same data as held in this array.
-
-
-
Field Detail
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE
Default initial array size.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GrowableStringArray
public GrowableStringArray(int size, int growth)Constructor with full specification.- Parameters:
size- number ofStringvalues initially allowed in arraygrowth- maximum size increment for growing array
-
GrowableStringArray
public GrowableStringArray(int size)
Constructor with initial size specified.- Parameters:
size- number ofStringvalues initially allowed in array
-
GrowableStringArray
public GrowableStringArray()
Default constructor.
-
GrowableStringArray
public GrowableStringArray(GrowableStringArray 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
-
set
public void set(int index, String value)Overwrite an existing value in the array.- Parameters:
index- position of value to be overwrittenvalue- value to be added
-
add
public void add(String value)
Add a value at the end of the array.- Parameters:
value- value to be added
-
addAll
public void addAll(String[] values)
Add an array of values at the end of the array.- Parameters:
values- values 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:
ArrayIndexOutOfBoundsException- on attempt to remove more than the count present
-
get
public String get(int index)
Get a value from the array.- Parameters:
index- index of value to be returned- Returns:
- value from stack
- Throws:
ArrayIndexOutOfBoundsException- on attempt to access outside valid range
-
toArray
public 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 Object clone()
Duplicates the object with the generic call.
-
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:
trueif array empty,falseif not
-
clear
public void clear()
Set the array to the empty state.
-
-