Xj3D VRML/X3D Code API

org.web3d.util
Class StringArray

java.lang.Object
  extended byorg.web3d.util.StringArray

public class StringArray
extends java.lang.Object

Simple dynamic array structure that holds String primitives.

Version:
$Revision: 1.5 $
Author:
Justin Couch

Constructor Summary
StringArray()
          Create a new default array with size 512 items and increment size of 256.
StringArray(int initialSize)
          Create an array with the given initial size.
StringArray(int initialSize, int inc)
          Create an array with the given initial size and resize strategy.
 
Method Summary
 void add(java.lang.String newString)
          Add a new value to the array.
 void add(java.lang.String[] values)
          Add an array of values in bulk to the array.
 void clear()
          Clear the array so that it contains no values
 java.lang.String get(int index)
          Get the value at the given index.
 java.lang.String remove(int index)
          Remove the value at the given index.
 void set(int index, java.lang.String value)
          Set the value at the given index.
 int size()
          Get the count of the number of items in the array.
 java.lang.String[] toArray()
          Turn the values of this array into a real array.
 java.lang.String[] toArray(java.lang.String[] values)
          Turn the values of this array into a real array by copying them Stringo the given array if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringArray

public StringArray()
Create a new default array with size 512 items and increment size of 256.


StringArray

public StringArray(int initialSize)
Create an array with the given initial size.

Parameters:
initialSize - The size to start with

StringArray

public StringArray(int initialSize,
                   int inc)
Create an array with the given initial size and resize strategy.

Parameters:
initialSize - The size to start with
inc - The amount to increment each resize with
Method Detail

size

public int size()
Get the count of the number of items in the array.

Returns:
The number of items in the array

clear

public void clear()
Clear the array so that it contains no values


add

public void add(java.lang.String newString)
Add a new value to the array. Will resize the array if needed to accommodate new values.

Parameters:
newString - the value to be added

add

public void add(java.lang.String[] values)
Add an array of values in bulk to the array. The array should not be null.

Parameters:
values - The values to be added

get

public java.lang.String get(int index)
Get the value at the given index.

Parameters:
index - The position to get values from
Returns:
The value at that index
Throws:
java.lang.IndexOutOfBoundsException - The index was not legal

set

public void set(int index,
                java.lang.String value)
Set the value at the given index. If the index is out of the range of the current items, it will generate an index exception.

Parameters:
index - The position to get values from
value - The new value to set
Throws:
java.lang.IndexOutOfBoundsException - The index was not legal

remove

public java.lang.String remove(int index)
Remove the value at the given index.

Parameters:
index - The position to remove the value from
Returns:
The value at that index
Throws:
java.lang.IndexOutOfBoundsException - The index was not legal

toArray

public java.lang.String[] toArray()
Turn the values of this array into a real array. Returns an array with the exact number of items in it. This is a separate copy of the Stringernal array.

Returns:
The array of values

toArray

public java.lang.String[] toArray(java.lang.String[] values)
Turn the values of this array into a real array by copying them Stringo the given array if possible. If the array is big enough then it will copy the values straight in. If not, it will ignore that array and create it's own copy and return that. If the passed array is used, the return value will be a reference to the passed array, otherwise it will be the new copy.

Parameters:
values - The array to copy values to
Returns:
The array of values

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium