net.aerith.misao.util
Class StringArray

java.lang.Object
  |
  +--net.aerith.misao.util.SortableArray
        |
        +--net.aerith.misao.util.StringArray

public class StringArray
extends SortableArray

The StringArray represents an array of string data with a funciton to sort.


Field Summary
protected  java.lang.String[] array
          The buffer of data array.
protected  int size
          The size of buffer.
 
Fields inherited from class net.aerith.misao.util.SortableArray
COMPARE_EQUAL, COMPARE_LARGER, COMPARE_SMALLER, SORT_ASCENDANT, SORT_DESCENDANT, sort_index
 
Constructor Summary
StringArray(int buffer_size)
          Constructs a StringArray with a specified size of buffer.
 
Method Summary
protected  int compare(int index1, int index2)
          Compares the two data represented by the specified index and returns which is smaller.
 int getArraySize()
          Gets the size of this array.
 int getDataCount()
          Gets the number of data.
 java.lang.String getValueAt(int index)
          Gets the value of data at the specified location.
 void set(int index, java.lang.String value)
          Sets the value of data at the specified location.
protected  void sort()
          Sorts this array itself based on the sorted index.
 
Methods inherited from class net.aerith.misao.util.SortableArray
quick_sort, sortAscendant, sortDescendant
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

array

protected java.lang.String[] array
The buffer of data array.

size

protected int size
The size of buffer.
Constructor Detail

StringArray

public StringArray(int buffer_size)
Constructs a StringArray with a specified size of buffer. The each value of buffer is set as an empty string.
Parameters:
buffer_size - the size of buffer to create.
Method Detail

getArraySize

public int getArraySize()
Gets the size of this array.
Overrides:
getArraySize in class SortableArray
Returns:
the size of this array.

getDataCount

public int getDataCount()
Gets the number of data.
Returns:
the number of data.

getValueAt

public java.lang.String getValueAt(int index)
                            throws java.lang.IndexOutOfBoundsException
Gets the value of data at the specified location.
Parameters:
index - the location of the data.
Returns:
the value of data at the specified location.
Throws:
java.lang.IndexOutOfBoundsException - if specified location is out of the data buffer.

set

public void set(int index,
                java.lang.String value)
         throws java.lang.IndexOutOfBoundsException
Sets the value of data at the specified location.
Parameters:
index - the location to store the data.
value - the value of data.
Throws:
java.lang.IndexOutOfBoundsException - if specified location is out of the data buffer.

compare

protected int compare(int index1,
                      int index2)
Compares the two data represented by the specified index and returns which is smaller. If the first data is smaller, it returns COMPARE_SMALLER. If the first data is larger, it returns COMPARE_LARGER. If both the data are equal, it returns COMPARE_EQUAL.
Overrides:
compare in class SortableArray
Parameters:
index1 - the index to represent the first data to compare.
index2 - the index to represent the second data to compare.
Returns:
the number to represent the comparison result.

sort

protected void sort()
Sorts this array itself based on the sorted index. It is invoked in the sorting functions.
Overrides:
sort in class SortableArray