com.novell.sentinel.client.tinyq
Class TinyQBuilder

java.lang.Object
  extended by com.novell.sentinel.client.tinyq.TinyQBuilder

public class TinyQBuilder
extends Object

A helper class to allow easy programmatic construction of TinyQ expressions.

Example usage:
TinyQBuilder builder = new TinyQBuilder(); String queryExpression = builder.equal("name","fred").or().equal("name","george").and().lessThan("count", 10);


Nested Class Summary
static class TinyQBuilder.BuilderException
          Base class of exceptions thrown when errors occur while building a TinyQ query expression.
static class TinyQBuilder.InvalidExpressionTypeException
          Exception thrown if an operator is appended in an invalid position.
static class TinyQBuilder.InvalidOperandException
          Exception thrown if an invalid operand is supplied to a TinyQ operator.
 
Constructor Summary
TinyQBuilder()
          Construct an instance.
 
Method Summary
 TinyQBuilder and()
          Add the TinyQ equivalent of the "AND" operator to the expression.
 String build()
          Return the TinyQ language expression.
 TinyQBuilder equal(String lhs, Object rhs)
          Add the TinyQ equivalent of the "==" operator to the expression.
 TinyQBuilder greater(String lhs, Object rhs)
          Add the TinyQ equivalent of the ">" operator to the expression.
 TinyQBuilder greaterOrEqual(String lhs, Object rhs)
          Add the TinyQ equivalent of the "<=" operator to the expression.
 TinyQBuilder less(String lhs, Object rhs)
          Add the TinyQ equivalent of the "<" operator to the expression.
 TinyQBuilder lessOrEqual(String lhs, Object rhs)
          Add the TinyQ equivalent of the "<=" operator to the expression.
 TinyQBuilder like(String lhs, Object rhs)
          Add the TinyQ equivalent of the "LIKE" operator to the expression.
 TinyQBuilder lparen()
          Append the equivalent of a left parenthesis (the left grouping operator);
 TinyQBuilder not()
          Add the TinyQ equivalent of the "NOT" operator to the expression.
 TinyQBuilder notEqual(String lhs, Object rhs)
          Add the TinyQ equivalent of the "!=" operator to the expression.
 TinyQBuilder or()
          Add the TinyQ equivalent of the "OR" operator to the expression.
 void reset()
          Reset the instance so another expression can be built.
 TinyQBuilder rparen()
          Append the equivalent of a right parenthesis (the right grouping operator);
 String toString()
          Return a human readable String representing the expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TinyQBuilder

public TinyQBuilder()
Construct an instance.

Method Detail

reset

public void reset()
Reset the instance so another expression can be built.


toString

public String toString()
Return a human readable String representing the expression.

Overrides:
toString in class Object

build

public String build()
Return the TinyQ language expression.


lparen

public TinyQBuilder lparen()
                    throws TinyQBuilder.InvalidExpressionTypeException
Append the equivalent of a left parenthesis (the left grouping operator);

Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.

rparen

public TinyQBuilder rparen()
                    throws TinyQBuilder.InvalidExpressionTypeException
Append the equivalent of a right parenthesis (the right grouping operator);

Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.

like

public TinyQBuilder like(String lhs,
                         Object rhs)
                  throws TinyQBuilder.InvalidOperandException,
                         TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "LIKE" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

equal

public TinyQBuilder equal(String lhs,
                          Object rhs)
                   throws TinyQBuilder.InvalidOperandException,
                          TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "==" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

notEqual

public TinyQBuilder notEqual(String lhs,
                             Object rhs)
                      throws TinyQBuilder.InvalidOperandException,
                             TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "!=" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

less

public TinyQBuilder less(String lhs,
                         Object rhs)
                  throws TinyQBuilder.InvalidOperandException,
                         TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "<" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

lessOrEqual

public TinyQBuilder lessOrEqual(String lhs,
                                Object rhs)
                         throws TinyQBuilder.InvalidOperandException,
                                TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "<=" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

greater

public TinyQBuilder greater(String lhs,
                            Object rhs)
                     throws TinyQBuilder.InvalidOperandException,
                            TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the ">" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

greaterOrEqual

public TinyQBuilder greaterOrEqual(String lhs,
                                   Object rhs)
                            throws TinyQBuilder.InvalidOperandException,
                                   TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "<=" operator to the expression.

Parameters:
lhs - The left hand operand.
rhs - The right hand operand.
Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.
TinyQBuilder.InvalidOperandException - If an operand is invalid.

and

public TinyQBuilder and()
                 throws TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "AND" operator to the expression.

Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.

or

public TinyQBuilder or()
                throws TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "OR" operator to the expression.

Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.

not

public TinyQBuilder not()
                 throws TinyQBuilder.InvalidExpressionTypeException
Add the TinyQ equivalent of the "NOT" operator to the expression.

Returns:
The TinyQBuilder instance.
Throws:
TinyQBuilder.InvalidExpressionTypeException - If the operator is invalid in the current expression position.