|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.genericdao.MatchArg
public abstract class MatchArg
A class to specify constraints when matching beans. Use with the GenericDAO.match() method, which generates a SQL SELECT call on the underlying table. The MatchArg parameters are converted into the WHERE clause for the SELECT so as to constrain which rows are returned.
For example, given a the following User bean:
public class User { private String userName; private String password; private String firstName; private String lastName; public String getUserName() { return userName; } public String getPassword() { return password; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setUserName(String s) { userName = s; } public void setPassword(String s) { password = s; } public void setFirstName(String s) { firstName = s; } public void setLastName(String s) { lastName = s; } }
this call would return all users with password equal to "testing".:
User[] array = dao.match(MatchArg.equals("password", "testing"));
Constructor Summary | |
---|---|
protected |
MatchArg()
|
Method Summary | |
---|---|
static MatchArg |
and(MatchArg... constraints)
Logical AND operator for use with the GenericDAO.match() method. |
static MatchArg |
contains(String fieldName,
String s)
String "contains" operator for use with the GenericDAO.match() method. |
static MatchArg |
containsIgnoreCase(String fieldName,
String s)
String "contains" operator for use with the GenericDAO.match() method. |
static MatchArg |
endsWith(String fieldName,
String ending)
String "ends with" operator for use with the GenericDAO.match() method. |
static MatchArg |
endsWithIgnoreCase(String fieldName,
String ending)
String "ends with" operator for use with the GenericDAO.match() method. |
static MatchArg |
equals(String fieldName,
Object matchValue)
Equals operator for use with the GenericDAO.match() method. |
static MatchArg |
equalsIgnoreCase(String keyName,
String matchValue)
|
protected abstract org.genericdao.impl.matcharg.MatchOp |
getOp()
|
static MatchArg |
greaterThan(String keyName,
Object matchValue)
|
static MatchArg |
greaterThanOrEqualTo(String keyName,
Object matchValue)
|
static MatchArg |
lessThan(String keyName,
Object matchValue)
|
static MatchArg |
lessThanOrEqualTo(String keyName,
Object matchValue)
|
static MatchArg |
max(String keyName)
|
static MatchArg |
min(String keyName)
|
static MatchArg |
notEquals(String fieldName,
Object matchValue)
Not equals operator for use with the GenericDAO.match() method. |
static MatchArg |
or(MatchArg... constraints)
Logical OR operator for use with the GenericDAO.match() method. |
static MatchArg |
startsWith(String keyName,
String beginning)
|
static MatchArg |
startsWithIgnoreCase(String keyName,
String beginning)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected MatchArg()
Method Detail |
---|
protected abstract org.genericdao.impl.matcharg.MatchOp getOp()
public static MatchArg and(MatchArg... constraints)
User[] array = dao.match( MatchArg.and( MatchArg.equals("firstName", "George"), MatchArg.equals("lastName", "Bush")));
constraints
- zero or more other MatchArg parameters
public static MatchArg contains(String fieldName, String s)
For example, using the User bean defined above, this match would return all users whose first name contains a lower case double "r":
User[] array = dao.match(MatchArg.contains("firstName", "rr"));
fieldName
- the name of the field in the table being matched. Field must contain string values.s
- the substring which must be present in the specified field for this MatchArg to evaluate to true.
public static MatchArg containsIgnoreCase(String fieldName, String s)
For example, using the User bean defined above, this match would return all users whose first name contains the substring "st", "sT", "St", or "ST":
User[] array = dao.match(MatchArg.containsIgnoreCase("firstName", "st"));
fieldName
- the name of the field in the table being matched. Field must contain string values.s
- the substring which must be present in the specified field, ignoring case, for this MatchArg to evaluate to true.
public static MatchArg endsWith(String fieldName, String ending)
For example, using the User bean defined above, this match would return all users whose first name ends with the lower case "st" characters:
User[] array = dao.match(MatchArg.endsWith("firstName", "st"));
fieldName
- the name of the field in the table being matched. Field must contain string values.ending
- the substring which must be present at the end of the specified field for this MatchArg to evaluate to true.
public static MatchArg endsWithIgnoreCase(String fieldName, String ending)
For example, using the User bean defined above, this match would return all users whose first name contains the "st", "sT", "St", or "ST":
User[] array = dao.match(MatchArg.endsWithIgnoreCase("firstName", "st"));
fieldName
- the name of the field in the table being matched. Field must contain string values.ending
- the substring which must be present at the end of the specified field, ignoring case, for this MatchArg to evaluate to true.
public static MatchArg equals(String fieldName, Object matchValue)
For example, using the User bean defined above, this match would return all users whose friend count is zero:
User[] array = dao.match(MatchArg.equals("friendCount", 0));
fieldName
- the name of the field being matched.matchValue
- the value which the specified field must equal for this MatchArg to evaluate to true.
public static MatchArg equalsIgnoreCase(String keyName, String matchValue)
public static MatchArg greaterThan(String keyName, Object matchValue)
public static MatchArg greaterThanOrEqualTo(String keyName, Object matchValue)
public static MatchArg lessThan(String keyName, Object matchValue)
public static MatchArg lessThanOrEqualTo(String keyName, Object matchValue)
public static MatchArg max(String keyName)
public static MatchArg min(String keyName)
public static MatchArg notEquals(String fieldName, Object matchValue)
For example, using the User bean defined above, this match would return all users whose friend count not zero:
User[] array = dao.match(MatchArg.notEquals("friendCount", 0));
fieldName
- the name of the field being matched.matchValue
- the value which the specified field must not equal for this MatchArg to evaluate to true.
public static MatchArg or(MatchArg... constraints)
User[] array = dao.match( MatchArg.or( MatchArg.equals("firstName", "William"), MatchArg.equals("firstName", "Bill"));
constraints
- zero or more other MatchArg parameters
public static MatchArg startsWith(String keyName, String beginning)
public static MatchArg startsWithIgnoreCase(String keyName, String beginning)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |