com.fdsapi.arrays
Class OrderByParser

java.lang.Object
  |
  +--com.fdsapi.arrays.OrderByParser

public class OrderByParser
extends java.lang.Object

Class that parses the Order by clause passed to ArraySQL and translates the String to calls to the ArrayComparator. It takes the following formats: col0, col1 desc, col2 asc, col3 ascending, mycolname descending



View Code


Constructor Summary
OrderByParser(java.lang.String orderByClause)
          The constructor takes an order by clause not including the keywords 'order by'.
OrderByParser(java.lang.String orderByClause, ArrayComparator arrayComp)
           
 
Method Summary
 void addSortCol(java.lang.String orderByCol)
           
 void addSortCols()
          This method parses the order by string passed to the constructor and adds the clauses to the backing ArrayComparator object
 ArrayComparator getArrayComparator()
          Returns the ArrayComparator object that backs this OrderByParser
static java.lang.String getOrderByClause(java.lang.String query)
          Method that gets an order by clause from a select statement.
static void main(java.lang.String[] args)
          Code used to test this class.
 java.lang.String[] parse()
           
static java.lang.String prependOrderBy(java.lang.String query, java.lang.String sortCol, java.lang.String sortOrder)
          Incomplete function that will eventually be used to improve the HTML sorting template
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderByParser

public OrderByParser(java.lang.String orderByClause,
                     ArrayComparator arrayComp)

OrderByParser

public OrderByParser(java.lang.String orderByClause)
The constructor takes an order by clause not including the keywords 'order by'. For example: new OrderByParser("col1 desc, col0 asc, col3"); A null is also acceptable and has the effect of not having a sort order: For example: new OrderByParser(null);

Method Detail

getArrayComparator

public ArrayComparator getArrayComparator()
Returns the ArrayComparator object that backs this OrderByParser


addSortCols

public void addSortCols()
This method parses the order by string passed to the constructor and adds the clauses to the backing ArrayComparator object


parse

public java.lang.String[] parse()

addSortCol

public void addSortCol(java.lang.String orderByCol)

prependOrderBy

public static java.lang.String prependOrderBy(java.lang.String query,
                                              java.lang.String sortCol,
                                              java.lang.String sortOrder)
Incomplete function that will eventually be used to improve the HTML sorting template


getOrderByClause

public static java.lang.String getOrderByClause(java.lang.String query)
Method that gets an order by clause from a select statement. The following would return 'col1 desc': select * from array order by col1 desc'


main

public static void main(java.lang.String[] args)
Code used to test this class. To view select the 'View Code' link above.