Search in sources :

Example 26 with QueryToken

use of com.dailystudio.dataobject.query.QueryToken in project devbricks by dailystudio.

the class ExpressionTokenTest method testComparisonOperations.

public void testComparisonOperations() {
    ExpressionToken token1 = null;
    ExpressionToken token2 = null;
    ExpressionToken token = null;
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(1);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(123456789l);
    token = token1.eq(token2);
    assertEquals(new QueryToken("( abc ) == ( 123456789 )"), token);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(3.5f);
    token = token1.neq(token2);
    assertEquals(new QueryToken("( abc ) != ( 3.5 )"), token);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken("'hello world'");
    token = token1.lt(token2);
    assertEquals(new QueryToken("( abc ) < ( 'hello world' )"), token);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(1);
    token = token1.lte(token2);
    assertEquals(new QueryToken("( abc ) <= ( 1 )"), token);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(1);
    token = token1.gt(token2);
    assertEquals(new QueryToken("( abc ) > ( 1 )"), token);
    token1 = new ExpressionToken("abc");
    token2 = new ExpressionToken(1);
    token = token1.gte(token2);
    assertEquals(new QueryToken("( abc ) >= ( 1 )"), token);
}
Also used : QueryToken(com.dailystudio.dataobject.query.QueryToken)

Example 27 with QueryToken

use of com.dailystudio.dataobject.query.QueryToken in project devbricks by dailystudio.

the class ExpressionTokenTest method testSamples.

public void testSamples() {
    Template templ = new Template();
    assertNotNull(templ);
    templ.addColumn(new IntegerColumn("_id", false, true));
    templ.addColumn(new IntegerColumn("intValue"));
    templ.addColumn(new DoubleColumn("doubleValue"));
    templ.addColumn(new TextColumn("textValue"));
    assertEquals(new QueryToken("( intValue > 1000 ) AND ( intValue < 2000 )"), templ.getColumn("intValue").gt(1000).and(templ.getColumn("intValue").lt(2000)));
}
Also used : IntegerColumn(com.dailystudio.dataobject.IntegerColumn) DoubleColumn(com.dailystudio.dataobject.DoubleColumn) Template(com.dailystudio.dataobject.Template) TextColumn(com.dailystudio.dataobject.TextColumn) QueryToken(com.dailystudio.dataobject.query.QueryToken)

Example 28 with QueryToken

use of com.dailystudio.dataobject.query.QueryToken in project devbricks by dailystudio.

the class ColumnTest method testMULTIPLEOperator.

public void testMULTIPLEOperator() {
    Column column1 = null;
    Column column2 = null;
    column1 = new IntegerColumn("intVal1");
    assertNotNull(column1);
    column2 = new IntegerColumn("intVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( intVal1 ) * ( intVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( intVal2 ) * ( intVal1 ) )"), column2.multiple(column1));
    column1 = new LongColumn("longVal1");
    assertNotNull(column1);
    column2 = new LongColumn("longVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( longVal1 ) * ( longVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( longVal2 ) * ( longVal1 ) )"), column2.multiple(column1));
    column1 = new DoubleColumn("dbVal1");
    assertNotNull(column1);
    column2 = new DoubleColumn("dbVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( dbVal1 ) * ( dbVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( dbVal2 ) * ( dbVal1 ) )"), column2.multiple(column1));
    column1 = new TextColumn("textVal1");
    assertNotNull(column1);
    column2 = new TextColumn("textVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( textVal1 ) * ( textVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( textVal2 ) * ( textVal1 ) )"), column2.multiple(column1));
    column1 = new TimeColumn("timeVal1");
    assertNotNull(column1);
    column2 = new TimeColumn("timeVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( timeVal1 ) * ( timeVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( timeVal2 ) * ( timeVal1 ) )"), column2.multiple(column1));
    column1 = new TextColumn("textVal1");
    assertNotNull(column1);
    column2 = new DoubleColumn("dbVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( textVal1 ) * ( dbVal2 ) )"), column1.multiple(column2));
    assertEquals(new QueryToken("( ( dbVal2 ) * ( textVal1 ) )"), column2.multiple(column1));
}
Also used : QueryToken(com.dailystudio.dataobject.query.QueryToken)

Example 29 with QueryToken

use of com.dailystudio.dataobject.query.QueryToken in project devbricks by dailystudio.

the class ColumnTest method testGTEOperator.

public void testGTEOperator() {
    Column column = null;
    column = new IntegerColumn("intVal");
    assertNotNull(column);
    assertEquals(new QueryToken("intVal >= 1000"), column.gte(1000));
    column = new LongColumn("longVal");
    assertNotNull(column);
    assertEquals(new QueryToken("longVal >= 987654321012345678"), column.gte(987654321012345678l));
    column = new DoubleColumn("doubleVal");
    assertNotNull(column);
    assertEquals(new QueryToken("doubleVal >= 3.141592653"), column.gte(3.141592653));
    column = new TextColumn("textVal");
    assertNotNull(column);
    assertEquals(new QueryToken("textVal >= \'this is \"string\" gte. 123?\'"), column.gte("this is \"string\" gte. 123?"));
    column = new TextColumn("textVal");
    assertNotNull(column);
    assertEquals(new QueryToken(), column.gte(1000));
}
Also used : QueryToken(com.dailystudio.dataobject.query.QueryToken)

Example 30 with QueryToken

use of com.dailystudio.dataobject.query.QueryToken in project devbricks by dailystudio.

the class ColumnTest method testMODULOperator.

public void testMODULOperator() {
    Column column1 = null;
    Column column2 = null;
    column1 = new IntegerColumn("intVal1");
    assertNotNull(column1);
    column2 = new IntegerColumn("intVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( intVal1 ) % ( intVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( intVal2 ) % ( intVal1 ) )"), column2.modulo(column1));
    column1 = new LongColumn("longVal1");
    assertNotNull(column1);
    column2 = new LongColumn("longVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( longVal1 ) % ( longVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( longVal2 ) % ( longVal1 ) )"), column2.modulo(column1));
    column1 = new DoubleColumn("dbVal1");
    assertNotNull(column1);
    column2 = new DoubleColumn("dbVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( dbVal1 ) % ( dbVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( dbVal2 ) % ( dbVal1 ) )"), column2.modulo(column1));
    column1 = new TextColumn("textVal1");
    assertNotNull(column1);
    column2 = new TextColumn("textVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( textVal1 ) % ( textVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( textVal2 ) % ( textVal1 ) )"), column2.modulo(column1));
    column1 = new TimeColumn("timeVal1");
    assertNotNull(column1);
    column2 = new TimeColumn("timeVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( timeVal1 ) % ( timeVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( timeVal2 ) % ( timeVal1 ) )"), column2.modulo(column1));
    column1 = new TextColumn("textVal1");
    assertNotNull(column1);
    column2 = new DoubleColumn("dbVal2");
    assertNotNull(column2);
    assertEquals(new QueryToken("( ( textVal1 ) % ( dbVal2 ) )"), column1.modulo(column2));
    assertEquals(new QueryToken("( ( dbVal2 ) % ( textVal1 ) )"), column2.modulo(column1));
}
Also used : QueryToken(com.dailystudio.dataobject.query.QueryToken)

Aggregations

QueryToken (com.dailystudio.dataobject.query.QueryToken)36 IntegerColumn (com.dailystudio.dataobject.IntegerColumn)5 DoubleColumn (com.dailystudio.dataobject.DoubleColumn)4 TextColumn (com.dailystudio.dataobject.TextColumn)4 SQLException (android.database.SQLException)3 Uri (android.net.Uri)3 Column (com.dailystudio.dataobject.Column)3 Template (com.dailystudio.dataobject.Template)3 ContentValues (android.content.ContentValues)2 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 AbstractWindowedCursor (android.database.AbstractWindowedCursor)1 LongColumn (com.dailystudio.dataobject.LongColumn)1