Filter Class

A Filter consists of one or more Filter.Items. Each Filter.Item consists of a field/column (e.g. "id"), an operator (e.g. "="), and a value constraint (e.g. "1"). Together, the Items can be joined to generate a "where" clause for a SQL query.

Constructors

There are no public constructors.

Public Methods

set( String col, Object val ) returns void
set( String col, String op, Object val ) returns void
Used to add, update, or remove an item in the filter. If an entry does not exist for a given col, a new item is created. If an entry does exist it is update or deleted, depending on whether val is null.
add( String col, String op, Object val ) returns void
Used to add an entry to the filter. Note that this may result in multiple entries for a given col. Use with caution.
get( String col ) returns javaxt.utils.Value
Returns a value for a given key in the filter. Always returns a javaxt.utils.Value object. Check the isNull() method to test for null values and the isArray() method to test if the javaxt.utils.Value object contains multiple values. Example:
            javaxt.utils.Value val = item.get("test");
            if (val.isNull()){
                console.log(val);
            }
            else{
                if (val.isArray()){
                    javaxt.utils.Value[] vals = (javaxt.utils.Value[]) val.toObject();
                    for (javaxt.utils.Value v : vals){
                        console.log(v);
                    }
                }
                else{
                    console.log(val);
                }
            }
        
remove( String col ) returns void
Used to remove an item from the filter
removeAll( ) returns void
Used to remove all the items from the filter
isEmpty( ) returns boolean
Returns true if the filter is empty
getItems( ) returns Item[]
Returns all the items in the filter
toJson( ) returns JSONArray
Returns a JSON representation of the filter

Public Classes