org.gitana.platform.support

## Class QueryBuilder

- java.lang.Object
- - org.gitana.platform.support.QueryBuilder

    public class QueryBuilder
    extends Object

Builder utility that helps in creating JSON queries mounted on top of Jackson ObjectNodes.

Author:
  uzi

### Constructor Summary

Constructors
Constructor and Description
`QueryBuilder()` Creates a builder with an empty query

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`QueryBuilder` `all(Object object)` All
`QueryBuilder` `and(String objId)` Used to create a compund expression around an AND clause.
`QueryBuilder` `exists(Object object)` Exists
`com.fasterxml.jackson.databind.node.ObjectNode` `get()` Creates an ObjectNode query for use in query methods by the driver.
`QueryBuilder` `greaterThan(Object object)` Greater than
`QueryBuilder` `greaterThanEquals(Object object)` Greater than or equal to
`QueryBuilder` `in(Object object)` In
`QueryBuilder` `is(Object object)` Is (equality)
`QueryBuilder` `lessThan(Object object)` Less than
`QueryBuilder` `lessThanEquals(Object object)` Less than or equals.
`QueryBuilder` `mod(Object object)` Modulus
`QueryBuilder` `near(double x, double y)` Near
`QueryBuilder` `near(double x, double y, double maxDistance)` Near
`QueryBuilder` `notEquals(Object object)` Not Equals
`QueryBuilder` `notIn(Object object)` Not In
`QueryBuilder` `or(com.fasterxml.jackson.databind.node.ObjectNode... ors)` Or
`QueryBuilder` `put(String key)` Adds a new key to the query if not present yet.
`QueryBuilder` `regex(Pattern regex)` Regular expression
`QueryBuilder` `size(Object object)` Size
`static QueryBuilder` `start()`
`static QueryBuilder` `start(String key)` Creates a new query for an object.
`QueryBuilder` `withinBox(double x1, double y1, double x2, double y2)` Within Calculates whether something is within a bounding box represented by two corners
`QueryBuilder` `withinCenter(double x, double y, double radius)` Within Used for geospatial operations.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### QueryBuilder

    public QueryBuilder()

Creates a builder with an empty query

### Method Detail

#### start

    public static QueryBuilder start()

Returns:
  new query builder

#### start

    public static QueryBuilder start(String key)

Creates a new query for an object.

Parameters:
  `key` - the key
Returns:
  new query builder

#### put

    public QueryBuilder put(String key)

Adds a new key to the query if not present yet. Sets this key as the current key.

Parameters:
  `key` - key
Returns:
  current QueryBuilder

#### and

    public QueryBuilder and(String objId)

Used to create a compund expression around an AND clause. Example: Example: QueryBuilder.start("a").greaterThan(1).and("b").lessThan(3)

Parameters:
  `objId` - object id
Returns:
  Returns the current QueryBuilder with an appended key operand

#### greaterThan

    public QueryBuilder greaterThan(Object object)

Greater than

Parameters:
  `object` - value
Returns:
  query builder

#### greaterThanEquals

    public QueryBuilder greaterThanEquals(Object object)

Greater than or equal to

Parameters:
  `object` - value
Returns:
  query builder

#### lessThan

    public QueryBuilder lessThan(Object object)

Less than

Parameters:
  `object` - value
Returns:
  query builder

#### lessThanEquals

    public QueryBuilder lessThanEquals(Object object)

Less than or equals.

Parameters:
  `object` - value
Returns:
  query builder

#### is

    public QueryBuilder is(Object object)

Is (equality)

Parameters:
  `object` - value
Returns:
  query builder

#### notEquals

    public QueryBuilder notEquals(Object object)

Not Equals

Parameters:
  `object` - value
Returns:
  query builder

#### in

    public QueryBuilder in(Object object)

In

Parameters:
  `object` - value
Returns:
  query builder

#### notIn

    public QueryBuilder notIn(Object object)

Not In

Parameters:
  `object` - value
Returns:
  query builder

#### mod

    public QueryBuilder mod(Object object)

Modulus

Parameters:
  `object` - value
Returns:
  query builder

#### all

    public QueryBuilder all(Object object)

All

Parameters:
  `object` - value
Returns:
  query builder

#### size

    public QueryBuilder size(Object object)

Size

Parameters:
  `object` - value
Returns:
  query builder

#### exists

    public QueryBuilder exists(Object object)

Exists

Parameters:
  `object` -
Returns:
  query builder

#### regex

    public QueryBuilder regex(Pattern regex)

Regular expression

Parameters:
  `regex` -
Returns:
  query builder

#### withinCenter

    public QueryBuilder withinCenter(double x,
                                     double y,
                                     double radius)

Within Used for geospatial operations.

Parameters:
  `x` - x coordinate
  `y` - y coordinate
  `radius` - radius
Returns:
  query builder

#### near

    public QueryBuilder near(double x,
                             double y)

Near

Parameters:
  `x` - x coordinate
  `y` - y coordinate
Returns:
  query builder

#### near

    public QueryBuilder near(double x,
                             double y,
                             double maxDistance)

Near

Parameters:
  `x` - x coordinate
  `y` - y coordinate
  `maxDistance` - max distance
Returns:
  query builder

#### withinBox

    public QueryBuilder withinBox(double x1,
                                  double y1,
                                  double x2,
                                  double y2)

Within Calculates whether something is within a bounding box represented by two corners

Parameters:
  `x1` - the x coordinate of the first box corner.
  `y1` - 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.
Returns:
  query builder

#### or

    public QueryBuilder or(com.fasterxml.jackson.databind.node.ObjectNode... ors)

Or

Parameters:
  `ors` -
Returns:
  query builder

#### get

    public com.fasterxml.jackson.databind.node.ObjectNode get()

Creates an ObjectNode query for use in query methods by the driver.

Returns:
  object node