public class QueryBuilder
extends java.lang.Object
Constructor and Description |
---|
QueryBuilder()
Creates a builder with an empty query
|
Modifier and Type | Method and Description |
---|---|
QueryBuilder |
all(java.lang.Object object)
Equivalent of the $all operand
|
QueryBuilder |
and(DBObject... ands)
Equivalent to an $and operand
|
QueryBuilder |
and(java.lang.String key)
Equivalent to
QueryBuilder.put(key) . |
QueryBuilder |
elemMatch(DBObject match)
Equivalent to the $elemMatch operand
|
QueryBuilder |
exists(java.lang.Object object)
Equivalent of the $exists operand
|
DBObject |
get()
Creates a
DBObject query to be used for the driver's find operations |
QueryBuilder |
greaterThan(java.lang.Object object)
Equivalent to the $gt operator
|
QueryBuilder |
greaterThanEquals(java.lang.Object object)
Equivalent to the $gte operator
|
QueryBuilder |
in(java.lang.Object object)
Equivalent of the $in operand
|
QueryBuilder |
is(java.lang.Object object)
Equivalent of the find({key:value})
|
QueryBuilder |
lessThan(java.lang.Object object)
Equivalent to the $lt operand
|
QueryBuilder |
lessThanEquals(java.lang.Object object)
Equivalent to the $lte operand
|
QueryBuilder |
mod(java.lang.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(java.lang.Object object)
Equivalent of the $ne operand
|
QueryBuilder |
notIn(java.lang.Object object)
Equivalent of the $nin operand
|
QueryBuilder |
or(DBObject... ors)
Equivalent to an $or operand
|
QueryBuilder |
put(java.lang.String key)
Adds a new key to the query if not present yet.
|
QueryBuilder |
regex(java.util.regex.Pattern regex)
Passes a regular expression for a query
|
QueryBuilder |
size(java.lang.Object object)
Equivalent of the $size operand
|
static QueryBuilder |
start()
Returns a new QueryBuilder.
|
static QueryBuilder |
start(java.lang.String key)
Creates a new query with a document key
|
QueryBuilder |
text(java.lang.String search)
Equivalent to a $text operand.
|
QueryBuilder |
text(java.lang.String search,
java.lang.String language)
Equivalent to a $text operand.
|
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(java.util.List<java.lang.Double[]> points)
Equivalent to a $within operand, based on a bounding polygon represented by an array of points
|
public static QueryBuilder start()
public static QueryBuilder start(java.lang.String key)
key
- MongoDB document keythis
public QueryBuilder put(java.lang.String key)
key
- MongoDB document keythis
public QueryBuilder and(java.lang.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 keythis
public QueryBuilder greaterThan(java.lang.Object object)
object
- Value to querythis
public QueryBuilder greaterThanEquals(java.lang.Object object)
object
- Value to querythis
public QueryBuilder lessThan(java.lang.Object object)
object
- Value to querythis
public QueryBuilder lessThanEquals(java.lang.Object object)
object
- Value to querythis
public QueryBuilder is(java.lang.Object object)
object
- Value to querythis
public QueryBuilder notEquals(java.lang.Object object)
object
- Value to querythis
public QueryBuilder in(java.lang.Object object)
object
- Value to querythis
public QueryBuilder notIn(java.lang.Object object)
object
- Value to querythis
public QueryBuilder mod(java.lang.Object object)
object
- Value to querythis
public QueryBuilder all(java.lang.Object object)
object
- Value to querythis
public QueryBuilder size(java.lang.Object object)
object
- Value to querythis
public QueryBuilder exists(java.lang.Object object)
object
- Value to querythis
public QueryBuilder regex(java.util.regex.Pattern regex)
regex
- Regex pattern objectthis
public QueryBuilder elemMatch(DBObject match)
match
- the object to matchthis
public QueryBuilder withinCenter(double x, double y, double radius)
x
- x coordinatey
- y coordinateradius
- radiusthis
public QueryBuilder near(double x, double y)
x
- x coordinatey
- y coordinatethis
public QueryBuilder near(double x, double y, double maxDistance)
x
- x coordinatey
- y coordinatemaxDistance
- max distancethis
public QueryBuilder nearSphere(double longitude, double latitude)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degreesthis
public QueryBuilder nearSphere(double longitude, double latitude, double maxDistance)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degreesmaxDistance
- max spherical distancethis
public QueryBuilder withinCenterSphere(double longitude, double latitude, double maxDistance)
longitude
- coordinate in decimal degreeslatitude
- coordinate in decimal degreesmaxDistance
- max spherical distancethis
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.this
public QueryBuilder withinPolygon(java.util.List<java.lang.Double[]> points)
points
- an array of Double[] defining the vertices of the search areathis
public QueryBuilder text(java.lang.String search)
search
- the search terms to apply to the text index.this
public QueryBuilder text(java.lang.String search, java.lang.String language)
search
- the search terms to apply to the text index.language
- the language to use.this
public QueryBuilder not()
QueryBuilder.start("val").not().mod(Arrays.asList(10, 1))
this
public QueryBuilder or(DBObject... ors)
ors
- the list of conditions to or togetherthis
public QueryBuilder and(DBObject... ands)
ands
- the list of conditions to and togetherthis
public DBObject get()
DBObject
query to be used for the driver's find operationsthis
java.lang.RuntimeException
- if a key does not have a matching operand