|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.QueryBuilder
public class QueryBuilder
Utility for creating DBObject queries
Constructor Summary | |
---|---|
QueryBuilder()
Creates a builder with an empty query |
Method Summary | |
---|---|
QueryBuilder |
all(Object object)
Equivalent of the $all operand |
QueryBuilder |
and(DBObject... ands)
Equivalent to an $and operand |
QueryBuilder |
and(String key)
Equivalent to QueryBuilder.put(key) . |
QueryBuilder |
elemMatch(DBObject match)
Equivalent to the $elemMatch operand |
QueryBuilder |
exists(Object object)
Equivalent of the $exists operand |
DBObject |
get()
Creates a DBObject query to be used for the driver's find operations |
QueryBuilder |
greaterThan(Object object)
Equivalent to the $gt operator |
QueryBuilder |
greaterThanEquals(Object object)
Equivalent to the $gte operator |
QueryBuilder |
in(Object object)
Equivalent of the $in operand |
QueryBuilder |
is(Object object)
Equivalent of the find({key:value}) |
QueryBuilder |
lessThan(Object object)
Equivalent to the $lt operand |
QueryBuilder |
lessThanEquals(Object object)
Equivalent to the $lte operand |
QueryBuilder |
mod(Object object)
Equivalent of the $mod operand |
QueryBuilder |
near(double x,
double y)
Equivalent of the $near operand |
QueryBuilder |
near(double x,
double y,
double maxDistance)
Equivalent of the $near operand |
QueryBuilder |
nearSphere(double longitude,
double latitude)
Equivalent of the $nearSphere operand |
QueryBuilder |
nearSphere(double longitude,
double latitude,
double maxDistance)
Equivalent of the $nearSphere operand |
QueryBuilder |
not()
Equivalent to $not meta operator. |
QueryBuilder |
notEquals(Object object)
Equivalent of the $ne operand |
QueryBuilder |
notIn(Object object)
Equivalent of the $nin operand |
QueryBuilder |
or(DBObject... ors)
Equivalent to an $or operand |
QueryBuilder |
put(String key)
Adds a new key to the query if not present yet. |
QueryBuilder |
regex(Pattern regex)
Passes a regular expression for a query |
QueryBuilder |
size(Object object)
Equivalent of the $size operand |
static QueryBuilder |
start()
returns a new QueryBuilder |
static QueryBuilder |
start(String key)
Creates a new query with a document key |
QueryBuilder |
withinBox(double x,
double y,
double x2,
double y2)
Equivalent to a $within operand, based on a bounding box using represented by two corners |
QueryBuilder |
withinCenter(double x,
double y,
double radius)
Equivalent of the $within operand, used for geospatial operation |
QueryBuilder |
withinCenterSphere(double longitude,
double latitude,
double maxDistance)
Equivalent of the $centerSphere operand mostly intended for queries up to a few hundred miles or km. |
QueryBuilder |
withinPolygon(List<Double[]> points)
Equivalent to a $within operand, based on a bounding polygon represented by an array of points |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QueryBuilder()
Method Detail |
---|
public static QueryBuilder start()
public static QueryBuilder start(String key)
key
- MongoDB document key
public QueryBuilder put(String key)
key
- MongoDB document key
public QueryBuilder and(String key)
QueryBuilder.put(key)
. Intended for compound query chains to be more readable, e.g.
QueryBuilder.start("a").greaterThan(1).and("b").lessThan(3)
key
- MongoDB document key
public QueryBuilder greaterThan(Object object)
object
- Value to query
public QueryBuilder greaterThanEquals(Object object)
object
- Value to query
public QueryBuilder lessThan(Object object)
object
- Value to query
public QueryBuilder lessThanEquals(Object object)
object
- Value to query
public QueryBuilder is(Object object)
object
- Value to query
public QueryBuilder notEquals(Object object)
object
- Value to query
public QueryBuilder in(Object object)
object
- Value to query
public QueryBuilder notIn(Object object)
object
- Value to query
public QueryBuilder mod(Object object)
object
- Value to query
public QueryBuilder all(Object object)
object
- Value to query
public QueryBuilder size(Object object)
object
- Value to query
public QueryBuilder exists(Object object)
object
- Value to query
public QueryBuilder regex(Pattern regex)
regex
- Regex pattern object
public QueryBuilder elemMatch(DBObject match)
match
- the object to match
public QueryBuilder withinCenter(double x, double y, double radius)
x
- x coordinatey
- y coordinateradius
- radius
public QueryBuilder near(double x, double y)
x
- x coordinatey
- y coordinate
public QueryBuilder near(double x, double y, double maxDistance)
x
- x coordinatey
- y coordinatemaxDistance
- max distance
public QueryBuilder nearSphere(double longitude, double latitude)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degrees
public QueryBuilder nearSphere(double longitude, double latitude, double maxDistance)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degreesmaxDistance
- max spherical distance
public QueryBuilder withinCenterSphere(double longitude, double latitude, double maxDistance)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degreesmaxDistance
- max spherical distance
public QueryBuilder withinBox(double x, double y, double x2, double y2)
x
- the x coordinate of the first box corner.y
- the y coordinate of the first box corner.x2
- the x coordinate of the second box corner.y2
- the y coordinate of the second box corner.
public QueryBuilder withinPolygon(List<Double[]> points)
points
- an array of Double[] defining the vertices of the search area
public QueryBuilder not()
QueryBuilder.start("val").not().mod(Arrays.asList(10, 1))
public QueryBuilder or(DBObject... ors)
ors
- the list of conditions to or together
public QueryBuilder and(DBObject... ands)
ands
- the list of conditions to and together
public DBObject get()
DBObject
query to be used for the driver's find operations
RuntimeException
- if a key does not have a matching operand
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |