com.pow2.dao
Class Condition

java.lang.Object
  extended bycom.pow2.dao.Condition

public class Condition
extends Object

Utility class for build query conditions.

Version:
$Id: Condition.java,v 1.1.1.1 2004/08/31 20:22:46 foxat Exp $
Author:
Luca Fossato

Field Summary
static String AND
          and boolean operator
protected  org.apache.log4j.Category cat
          Log4J category
static String EMPTY
          empty string
static String EQUAL
          equal operator
static String LIKE
          like operator
static String NOT_EQUAL
          not equal operator
static String NOT_LIKE
          not like operator
static String NULL
          null
static String OR
          or boolean operator
 
Constructor Summary
Condition()
          Default constructor.
Condition(String attributeName, String op, String attributeValue, boolean encloseInBrackets)
          Constructor.
 
Method Summary
 Condition add(String booleanOp, Condition cnd, boolean encloseInBrackets)
          Add the input Condition object to the current condition.
 Condition add(String attributeName, String op, String attributeValue, boolean encloseInBrackets)
          Add a condition to the global WHERE clause.
 Condition add(String booleanOp, String attributeName, String op, String attributeValue, boolean encloseInBrackets)
          Add a condition to the global WHERE clause.
 void clear()
          Clear the internal condition string.
 Condition encloseInBrackets()
          Enclose the input condition in brackets
 boolean isEmpty()
          Test if the condition is empty
 String toString()
          Get the string representation of the current condition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cat

protected org.apache.log4j.Category cat
Log4J category


EQUAL

public static final String EQUAL
equal operator

See Also:
Constant Field Values

NOT_EQUAL

public static final String NOT_EQUAL
not equal operator

See Also:
Constant Field Values

LIKE

public static final String LIKE
like operator

See Also:
Constant Field Values

NOT_LIKE

public static final String NOT_LIKE
not like operator

See Also:
Constant Field Values

AND

public static final String AND
and boolean operator

See Also:
Constant Field Values

OR

public static final String OR
or boolean operator

See Also:
Constant Field Values

EMPTY

public static final String EMPTY
empty string

See Also:
Constant Field Values

NULL

public static final String NULL
null

See Also:
Constant Field Values
Constructor Detail

Condition

public Condition()
Default constructor.


Condition

public Condition(String attributeName,
                 String op,
                 String attributeValue,
                 boolean encloseInBrackets)
Constructor.
Add the condition builded usong the input attributeName, operator, attributeValue to the global WHERE clause.

Parameters:
attributeName - the name of the element used by the binary operator op
op - the binary operator that binds the attributeValue to the attributeName.
attributeValue - the value bond to the input attribute
encloseInBrackets - true if the resulting condition statements must be enclosed in brackets; false otherwise
Method Detail

add

public Condition add(String booleanOp,
                     Condition cnd,
                     boolean encloseInBrackets)
Add the input Condition object to the current condition.

Parameters:
booleanOp - the boolean operator used to bind the input condition object with the current condition
cnd - the input Condition object to add to the current condition
encloseInBrackets - true if the resulting condition statements must be enclosed in brackets; false otherwise
Returns:
the current Condition object

add

public Condition add(String attributeName,
                     String op,
                     String attributeValue,
                     boolean encloseInBrackets)
Add a condition to the global WHERE clause.

Parameters:
attributeName - the name of the element used by the binary operator op
op - the binary operator that binds the attributeValue to the attributeName.
Supported binary operators are:
  • EQUAL
  • NOT_EQUAL
  • LIKE
attributeValue - the value bond to the input attribute
encloseInBrackets - true if the resulting condition statements must be enclosed in brackets; false otherwise
Returns:
the current Condition object

add

public Condition add(String booleanOp,
                     String attributeName,
                     String op,
                     String attributeValue,
                     boolean encloseInBrackets)
Add a condition to the global WHERE clause.

Parameters:
booleanOp - the boolean operator that adds this condition statement to the previous condition statement (if any) of the the global WHERE clause
Supported boolean operators are:
  • AND
  • OR
attributeName - the name of the element used by the binary operator op
op - the binary operator that binds the attributeValue to the attributeName.
Supported binary operators are:
  • EQUAL
  • NOT_EQUAL
  • LIKE
attributeValue - the value bond to the input attribute
Returns:
the current Condition object

clear

public void clear()
Clear the internal condition string.


isEmpty

public boolean isEmpty()
Test if the condition is empty

Returns:
true if this condition is empty; false otherwise

toString

public String toString()
Get the string representation of the current condition.

Returns:
the string representation of the current condition

encloseInBrackets

public Condition encloseInBrackets()
Enclose the input condition in brackets

Returns:
Description of the Return Value


Copyright © 2002-2004 Power Of Two S.R.L. All Rights Reserved.