|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.fdsapi.arrays.ArraySQL
This class does for arrays what a SQL select statement for a database table. For example in a select statement you can display or not display columns by including them in the select column list. Example: select col1,col1,col2,col5 from array. In the SQL select statement you can also limit/filter rows by using where conditions. For example: select col1,col1,col2,col5 from array where col1='A' && (col2<=100 || col5 in ('jim',john')). Ordering is also possible as it is with a SQL select: select * from array where fname='steve' order by lname desc, salary asc
ArraySQL is backed by the ArrayFilter and ArrayComparator objects
To see sample code click on view code below. The classes main method has plenty of examples. Note where clauses must be of the format where col0='souza' as opposed to 'souza'=col0 (i.e. the column must come first)
Notes: Exceptions: 1) no query 2) colname that isn't in header 3) not asc or desc. Also note string checks for equality are case sensitive. like is not case senstive.
| Constructor Summary | |
ArraySQL(java.lang.String query)
Creates a new instance of ArraySQL |
|
ArraySQL(java.lang.String[] header,
java.lang.String query)
|
|
| Method Summary | |
java.lang.Object[][] |
convert(java.lang.Object[][] data)
This method executes the query against the data and convers the data with the ArrayConverter. |
static java.lang.Object[][] |
copy(java.lang.Object[][] data)
Performs a shallow copy of the passed in array |
java.lang.String |
debugString()
Get a debug String. |
java.lang.Object[][] |
execute(java.lang.Object[][] data)
This method executes the query against the data. |
ArrayComparator |
getArrayComparator()
Get the underlying ArrayComparator that backs the ArraySQL object. |
ArrayConverter |
getArrayConverter()
Get the underlying ArrayConverter that backs the ArraySQL object |
ArrayFilter |
getArrayFilter()
Get the underlying ArrayFilter that backs the ArraySQL object. |
boolean |
getCopyData()
Get the copy status for any array that will be passed to the execute(...) method. |
static void |
main(java.lang.String[] args)
Test code for the ArraySQL class. |
void |
setArrayConverter(ArrayConverter arrayConverter)
|
void |
setCopyData(boolean copyData)
Copy the array passed to the execute(...) method. |
java.lang.String |
toString()
The passed in query |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ArraySQL(java.lang.String query)
public ArraySQL(java.lang.String[] header,
java.lang.String query)
| Method Detail |
public static java.lang.Object[][] copy(java.lang.Object[][] data)
public java.lang.Object[][] execute(java.lang.Object[][] data)
This method executes the query against the data. A side effect is that the original data is sorted. If you wish not to sort the original data then you should call setCopyData(false). Note execute can be called as many times as needed against the same or different arrays. :
Sample Code:
ArraySQL asql=new ArraySQL("select * from array");
asql.setCopyData(false);
asql.execute(ArraySQL.copy(data));
public java.lang.Object[][] convert(java.lang.Object[][] data)
This method executes the query against the data and convers the data with the ArrayConverter. This method first calls execute(...).:
Sample Code:
ArraySQL asql=new ArraySQL("select * from array");
asql.convert(data);
public java.lang.String toString()
toString in class java.lang.Objectpublic ArrayFilter getArrayFilter()
public ArrayComparator getArrayComparator()
public ArrayConverter getArrayConverter()
public void setArrayConverter(ArrayConverter arrayConverter)
public java.lang.String debugString()
public void setCopyData(boolean copyData)
public boolean getCopyData()
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||