iicm.vrml.pwutils
Class StringArray

java.lang.Object
  extended by iicm.vrml.pwutils.StringArray

public class StringArray
extends java.lang.Object

StringArray - dynamic array of String type values better time and memory efficiency than Vector, String[] accessible in native code Copyright (c) 1996 IICM

Version:
0.1, latest change: 1 Okt 96
Author:
Michael Pichler, Karin Roschker, (based on Field macro by Gerald Pani)

Field Summary
private  int count_
           
private  java.lang.String[] data_
           
 
Constructor Summary
StringArray()
          create with default length
StringArray(int len)
          create with initial buffer length
StringArray(java.lang.String[] dat)
          copy initial data from another String[].
StringArray(StringArray dat)
          copy initial data from another StringArray (non-null).
 
Method Summary
 void append(java.lang.String d)
          append one String element
 boolean clearData()
          clear the array
private  void enlarge(int newsize)
          enlarge the data array to its new size; does not change count_
 int getCount()
          get count of used array members.
 java.lang.String[] getData()
          get data array.
 void setData(java.lang.String[] dat)
          copy data from a String[]
 void setData(java.lang.String[] dat, int n)
          copy first n elements of a String[]
 void setData(StringArray dat)
          copy data from another StringArray
 void setSize(int n)
          set number of used array elements (ensures there is enough storage)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data_

private java.lang.String[] data_

count_

private int count_
Constructor Detail

StringArray

public StringArray()
create with default length


StringArray

public StringArray(int len)
create with initial buffer length


StringArray

public StringArray(java.lang.String[] dat)
copy initial data from another String[]. To say it again: values in String[] are *copied* and not just referenced by this class


StringArray

public StringArray(StringArray dat)
copy initial data from another StringArray (non-null). do not use the above constructor in this case, as it would use all values, not just the used length (count); again: values are *copied*

Method Detail

setData

public void setData(StringArray dat)
copy data from another StringArray


setData

public void setData(java.lang.String[] dat)
copy data from a String[]


setData

public void setData(java.lang.String[] dat,
                    int n)
copy first n elements of a String[]


getCount

public final int getCount()
get count of used array members. Note: may be smaller than data_.length


getData

public final java.lang.String[] getData()
get data array. Only elements 0 to (getCount () - 1) were set by user. Subsequent calls (after enlargement) may return a different array object


append

public void append(java.lang.String d)
append one String element


setSize

public void setSize(int n)
set number of used array elements (ensures there is enough storage)


clearData

public boolean clearData()
clear the array

Returns:
true if the array was previously non-empty

enlarge

private void enlarge(int newsize)
enlarge the data array to its new size; does not change count_