|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jstatcom.util.UStringArray
public final class UStringArray
A collection of static methods that are related to arrays of strings.
All methods implemented do not modify the original input. Results are always newly created arrays. If the input is somehow wrong an appropriate exception is thrown. All methods require that the input arrays have the same number of elements in each row.
| Method Summary | |
|---|---|
static java.lang.String[][] |
appendStringCols(java.lang.String[][] orig,
java.lang.String[][] toAppend)
Appends toAppend to the columns of orig and
returns the new merged array. |
static java.lang.String[][] |
appendStringRows(java.lang.String[][] orig,
java.lang.String[][] toAppend)
Appends toAppend to the rows of orig and
returns the new merged array. |
static java.lang.String[][] |
appendSuffix(java.lang.String[][] orig,
java.lang.String suffix)
Appends suffix to the elements of orig and
returns the new string array. |
static java.lang.String[] |
appendSuffix(java.lang.String[] orig,
java.lang.String suffix)
Appends suffix to the elements of orig and
returns the new string array. |
static void |
checkRowLengths(java.lang.String[][] arg)
Checks whether all rows of arg have the same number of
columns. |
static java.lang.String[][] |
cloneStringArray(java.lang.String[][] x)
Gets an identical copy of x. |
static boolean |
compareStringArrays(java.lang.String[][] arg1,
java.lang.String[][] arg2)
Compares two string arrays and returns true. if the
dimensions are the same and all elements are equal. |
static java.lang.String[] |
createNamedIndex(java.lang.String name,
double[] idx)
Creates an index with its elements starting with name
followed by the integer part of the respective element of
idx. |
static java.lang.String[][] |
delCol(java.lang.String[][] arg,
int colIndex)
Deletes the column colIndex from arg. |
static java.lang.String[][] |
delif(java.lang.String[][] arg,
int[] index)
Deletes columns of arg that have been selected by
index and returns a new array with the remaining columns. |
static java.lang.String[][] |
delRow(java.lang.String[][] arg,
int rowIndex)
Deletes the row rowIndex from arg. |
static java.lang.String[][] |
delRowsIf(java.lang.String[][] arg,
int[] index)
Deletes rows of arg that have been selected by
index and returns a new array with the remaining rows. |
static java.lang.String[] |
delRowsIf(java.lang.String[] arg,
int[] rowIndex)
Deletes rows of arg that have been selected by
index and returns a new array with the remaining rows. |
static java.lang.String[] |
getStringCol(java.lang.String[][] arg,
int colIndex)
Gets the column of the array arg specified with
colIndex. |
static java.lang.String[] |
getStringDiff(java.lang.String[] arg1,
java.lang.String[] arg2)
Gets a new string array with only the rows of arg1 that do
not appear in arg2. |
static java.lang.String[][] |
getStringRows(java.lang.String[][] arg,
int startRow,
int endRow)
Gets all rows of the array arg defined by
startRow:endRow. |
static java.lang.String[][] |
selif(java.lang.String[][] arg,
int[] index)
Gets all columns of the array arg that have a nonzero
corresponding element in index. |
static java.lang.String[][] |
selRowsIf(java.lang.String[][] arg,
int[] index)
Gets all rows of the array arg that have a nonzero
corresponding element in index. |
static java.lang.String[] |
selRowsIf(java.lang.String[] arg,
int[] rowIndex)
Gets a new string array with all elements arg that have a
corresponding value in rowIndex that is ! |
static java.lang.String[][] |
toStringMatrix(java.lang.String[] arg)
Transforms a one-dimensional array into a K x 1 pseudo-two-dimensional array. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String[][] appendStringCols(java.lang.String[][] orig,
java.lang.String[][] toAppend)
toAppend to the columns of orig and
returns the new merged array. This only works, if orig and
toAppend have the same number of rows.
orig - the array to append the columns of toAppend totoAppend - the arrays to be appended to orig
java.lang.IllegalArgumentException - if (orig.length != toAppend.length) or
if (orig == null || toAppend == null) or if
rows of an argument have different lengths
public static java.lang.String[][] appendStringRows(java.lang.String[][] orig,
java.lang.String[][] toAppend)
toAppend to the rows of orig and
returns the new merged array. This only works, if orig and
toAppend have the same number of columns.
orig - the array to append the rows of toAppend totoAppend - the arrays to be appended to orig
java.lang.IllegalArgumentException - if (orig[0].length != toAppend[0].length) or
if (orig == null || toAppend == null) or if
rows of an argument have different lengths
public static java.lang.String[][] appendSuffix(java.lang.String[][] orig,
java.lang.String suffix)
suffix to the elements of orig and
returns the new string array.
orig - the original string arraysuffix - the suffix to be appended to all elements of orig
java.lang.IllegalArgumentException - if (orig == null || suffix == null) or if rows
of argument have different lengths
public static java.lang.String[] appendSuffix(java.lang.String[] orig,
java.lang.String suffix)
suffix to the elements of orig and
returns the new string array.
orig - the original string arraysuffix - the suffix to be appended to all elements of orig
java.lang.IllegalArgumentException - if (orig == null || suffix == null)public static void checkRowLengths(java.lang.String[][] arg)
arg have the same number of
columns. If the check fails, an exception is thrown.
arg - the String[][] to check
java.lang.IllegalArgumentException - if the rows of arg have different lengthspublic static java.lang.String[][] cloneStringArray(java.lang.String[][] x)
x.
null if (x == null)
new String[0][0] if (x.length == 0 || x[0].length == 0)
java.lang.IllegalArgumentException - if rows of argument have different lengths
public static boolean compareStringArrays(java.lang.String[][] arg1,
java.lang.String[][] arg2)
true. if the
dimensions are the same and all elements are equal. If two elements of
arg1 and arg2 are null,
they are considered to be equal. The comparison is case sensitive.
arg1 - string array to comparearg2 - string array to compare
true if dimensions and all elements are equal or
if arg1, arg2 have both at least one dimension of
zero, false otherwise
java.lang.IllegalArgumentException - if rows of an argument have different lengths
public static java.lang.String[] createNamedIndex(java.lang.String name,
double[] idx)
name
followed by the integer part of the respective element of
idx. The resulting string array has length
idx.length.
name - the string with the prefix for the indexidx - the array containing the indices to be appended to
name
idx.length string array
java.lang.IllegalArgumentException - if (name == null || idx == null)
public static java.lang.String[][] delCol(java.lang.String[][] arg,
int colIndex)
colIndex from arg.
arg - the string array to delete the column fromcolIndex - index of the column
java.lang.IllegalArgumentException - if (arg == null) or
if (colIndex < 0 || arg[0].length < colIndex)
or if (arg.length == 0 || arg[0].length == 0)
or if rows of argument have different lengths
public static java.lang.String[][] delif(java.lang.String[][] arg,
int[] index)
arg that have been selected by
index and returns a new array with the remaining columns.
A column is selected for deletion if the corresponding index entry is
nonzero.
arg - the array to delete columns fromindex - the arg[0].length x 1 int array
new String[0][0] if all columns where selected for
deletion or if arg.length == 0
java.lang.IllegalArgumentException - if (arg == null || index == null) or
if (arg[0].length != index.length) or
if ((arg.length == 0 || arg[0].length == 0) && index.length > 0)
or if rows of argument have different lengths
public static java.lang.String[][] delRow(java.lang.String[][] arg,
int rowIndex)
rowIndex from arg.
arg - the string array to delete the row fromrowIndex - index of the row
java.lang.IllegalArgumentException - if (arg == null) or
if (rowIndex < 0 || arg.length < rowIndex)
or if (arg.length == 0 || arg[0].length == 0)
or if rows of argument have different lengths
public static java.lang.String[][] delRowsIf(java.lang.String[][] arg,
int[] index)
arg that have been selected by
index and returns a new array with the remaining rows. A
row is selected for deletion if the corresponding index entry is nonzero.
arg - the array to delete rows fromindex - the arg[0].length x 1 int array
new String[0][0] if all rows where selected for
deletion or if arg.length == 0
java.lang.IllegalArgumentException - if (arg == null || index == null) or
if (arg.length != index.length) or
if ((arg.length == 0 || arg[0].length == 0) && index.length > 0)
or if rows of arg have different lengths
public static java.lang.String[] delRowsIf(java.lang.String[] arg,
int[] rowIndex)
arg that have been selected by
index and returns a new array with the remaining rows. A
row is selected for deletion if the corresponding index entry is set to 1
(or != 0).
arg - the array to delete rows fromrowIndex - the arg.length x 1 int array with 1's and 0's
(all values different from 0 select a row, but usually 1)
new String[0][0] if all rows where selected for
deletion or if arg.length == 0
java.lang.IllegalArgumentException - if (arg == null || index == null) or
if (arg.length != index.length)
public static java.lang.String[] getStringCol(java.lang.String[][] arg,
int colIndex)
arg specified with
colIndex. The index starts with 0 as usual.
arg - the array to extract a column fromcolIndex - the index of the column to extract (starting from 0)
java.lang.IllegalArgumentException - if (arg == null) or
if (arg.length == 0) or if the index is
outside the valid array bounds or if rows of argument have
different lengths
public static java.lang.String[] getStringDiff(java.lang.String[] arg1,
java.lang.String[] arg2)
arg1 that do
not appear in arg2.
arg1 - the string array to delete rows from that also appear in
arg2arg2 - contains strings that are deleted from arg1
java.lang.IllegalArgumentException - if (arg1 == null || arg2 == null)
public static java.lang.String[][] getStringRows(java.lang.String[][] arg,
int startRow,
int endRow)
arg defined by
startRow:endRow. The indices start with 0 as usual.
arg - the array to extract rows fromstartRow - the index of the first row to extract (starting from 0)endRow - the index of the last row to extract (starting from 0)
java.lang.IllegalArgumentException - if (arg == null) or
if (arg.length == 0) or
if (startRow > endRow) or if the indices
are outside the valid array bounds or if rows of argument
have different lengths
public static java.lang.String[][] selif(java.lang.String[][] arg,
int[] index)
arg that have a nonzero
corresponding element in index.
arg - the array to extract columns fromindex - arg[0].length x 1 vector selecting columns from
arg
new String[0][0] if index contains only 0's, a
copy of arg if index contains only
nonzero elements
java.lang.IllegalArgumentException - if (arg == null || index == null) or
if ((arg.length == 0 || arg[0].length == 0) && index.length > 0)
or if (arg[0].length != index.length) or if
rows of argument have different lengths
public static java.lang.String[][] selRowsIf(java.lang.String[][] arg,
int[] index)
arg that have a nonzero
corresponding element in index.
arg - the array to extract rows fromindex - arg[0].length x 1 vector selecting rows from
arg
new String[0][0]
if index contains only 0's, a copy of arg if
index contains only nonzero elements
java.lang.IllegalArgumentException - if (arg == null || index == null) or
if (arg.length == 0 || arg[0].length == 0) && index.length > 0)
or if (arg.length != index.length) or if rows
of argument have different lengths
public static java.lang.String[] selRowsIf(java.lang.String[] arg,
int[] rowIndex)
arg that have a
corresponding value in rowIndex that is != 0.
arg and rowIndex must have the same
dimension.
arg - the array to extract elements fromrowIndex - the index selecting elements from arg if
rowIndex[i] != 0
java.lang.IllegalArgumentException - if (arg == null || rowIndex == null) or
if (arg.length != rowIndex.length)public static java.lang.String[][] toStringMatrix(java.lang.String[] arg)
String[][] instead of String[].
arg - the vector-like array to transform
arg.length x 1
or
null if (arg == null)
new String[0][0] if (arg.length == 0)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||