se.js.jesdob.query
Class DobQuery

java.lang.Object
  extended by se.js.jesdob.query.DobQuery
All Implemented Interfaces:
IDobQuery

public class DobQuery
extends java.lang.Object
implements IDobQuery

A dob query contains one or more conditions, or requirements. These conditions can be used for testing one or several dobs - which dobs fullfils the conditions, and which dobs do not? It is possible to use dob queries for filtering dob collections, removing the dobs that doesn't fulfill the specified conditions/requirements.


Constructor Summary
DobQuery()
          Parameterless constructor.
 
Method Summary
 IDobQuery bigger(java.lang.String attribute, double value)
          Adds a bigger-than-condition to the query.
 IDobQuery bigger(java.lang.String attribute, int value)
          Adds a bigger-than-condition to the query.
 IDobQuery biggerOrEqual(java.lang.String attribute, double value)
          Adds a bigger-or-equal-to-condition to the query.
 IDobQuery biggerOrEqual(java.lang.String attribute, int value)
          Adds a bigger-or-equal-to-condition to the query.
 IDobQuery contains(java.lang.String attribute, java.lang.String value)
          Adds a contains-condition to the query.
 IDobQuery containsNot(java.lang.String attribute, java.lang.String value)
          Adds a contains-condition to the query.
 IDobQuery equals(java.lang.String attribute, float value)
          Adds a equals-condition to the query.
 IDobQuery equals(java.lang.String attribute, int value)
          Adds a equals-condition to the query.
 IDobQuery equals(java.lang.String attribute, java.lang.String value)
          Adds a equals-condition to the query.
 IDobCollection filter(IDobCollection dobCollection)
          Takes a IDobCollection as an argument, and returns a new IDobCollection with all IDobs that fullfilled the requirements specified in the query.
 IDobQuery hasAttr(java.lang.String attribute)
          Adds a has-attribute-condition to the query.
 IDobQuery hasNotAttr(java.lang.String attribute)
          Adds a has-not-attribute-condition to the query.
 IDobQuery is(java.lang.String attribute)
          Adds a is-condition to the query.
 IDobQuery isNot(java.lang.String attribute)
          Adds a is-not-condition to the query.
 IDobQuery isNotNumeric(java.lang.String attribute)
          Adds a is-not-attribute-numeric-condition to the query.
 IDobQuery isNumeric(java.lang.String attribute)
          Adds a is-attribute-numeric-condition to the query.
 boolean isTrue(IDob dob)
          Takes a specific IDob as an argument, and returns true if the IDob fullfills all requirements specified in the query.
 IDobQuery lesser(java.lang.String attribute, double value)
          Adds a lesser-than-condition to the query.
 IDobQuery lesser(java.lang.String attribute, int value)
          Adds a lesser-than-condition to the query.
 IDobQuery lesserOrEqual(java.lang.String attribute, double value)
          Adds a lesser-or-equal-to-condition to the query.
 IDobQuery lesserOrEqual(java.lang.String attribute, int value)
          Adds a lesser-or-equal-to-condition to the query.
 IDobQuery notEquals(java.lang.String attribute, float value)
          Adds a not-equals-condition to the query.
 IDobQuery notEquals(java.lang.String attribute, int value)
          Adds a not-equals-condition to the query.
 IDobQuery notEquals(java.lang.String attribute, java.lang.String value)
          Adds a not-equals-condition to the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DobQuery

public DobQuery()
Parameterless constructor.

Method Detail

is

public IDobQuery is(java.lang.String attribute)
Adds a is-condition to the query. This condition will check if a Dob contains a specific boolean attribute, and if this attribute is true. If the dob does not contain the attribute, the condition will return false. If the dob contains the attribute, but the attribute is not true, the condition will return false. If the dob contains the attribute, and the attribute is true, the condition will return true.

Specified by:
is in interface IDobQuery
Parameters:
attribute - The boolean attribute we want to check for.
Returns:
Self; the IDobQuery-object, to enable chaining.

isNot

public IDobQuery isNot(java.lang.String attribute)
Adds a is-not-condition to the query. This condition will check if a Dob contains a specific boolean attribute, and if this attribute is false. If the dob does not contain the attribute, the condition will return true. If the dob contains the attribute, but the attribute is not true, the condition will return true. If the dob contains the attribute, and the attribute is true, the condition will return false.

Specified by:
isNot in interface IDobQuery
Parameters:
attribute - The boolean attribute we want to check for.
Returns:
Self; the IDobQuery-object, to enable chaining.

hasAttr

public IDobQuery hasAttr(java.lang.String attribute)
Adds a has-attribute-condition to the query. This will check if a Dob has a specific attribute or not. If the dob has the attribute, the condition will return true. If the dob has not the attribute, the condition will return false.

Specified by:
hasAttr in interface IDobQuery
Parameters:
attribute - The attribute we want to check for.
Returns:
Self; the IDobQuery-object, to enable chaining.

hasNotAttr

public IDobQuery hasNotAttr(java.lang.String attribute)
Adds a has-not-attribute-condition to the query. This will check if a Dob lacks a specific attribute, or not. If the dob has the attribute, the condition will return false. If the dob has not the attribute, the condition will return true.

Specified by:
hasNotAttr in interface IDobQuery
Parameters:
attribute - The attribute we want to check for.
Returns:
Self; the IDobQuery-object, to enable chaining.

equals

public IDobQuery equals(java.lang.String attribute,
                        java.lang.String value)
Adds a equals-condition to the query. This will check if the dob has a specific attribute, and if this attribute has got a specific value or not. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true.

Specified by:
equals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to have.
Returns:
Self; the IDobQuery-object, to enable chaining.

equals

public IDobQuery equals(java.lang.String attribute,
                        int value)
Adds a equals-condition to the query. This will check if the dob has a specific attribute, and if this attribute has got a specific value or not. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true.

Specified by:
equals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to have.
Returns:
Self; the IDobQuery-object, to enable chaining.

equals

public IDobQuery equals(java.lang.String attribute,
                        float value)
Adds a equals-condition to the query. This will check if the dob has a specific attribute, and if this attribute has got a specific value or not. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true.

Specified by:
equals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to have.
Returns:
Self; the IDobQuery-object, to enable chaining.

notEquals

public IDobQuery notEquals(java.lang.String attribute,
                           int value)
Adds a not-equals-condition to the query. This will check if the dob if dob hasn't a specific value for a specific attribute. If the dob has not the attribute, the condition will return true. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false.

Specified by:
notEquals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to not have.
Returns:
Self; the IDobQuery-object, to enable chaining.

notEquals

public IDobQuery notEquals(java.lang.String attribute,
                           float value)
Adds a not-equals-condition to the query. This will check if the dob if dob hasn't a specific value for a specific attribute. If the dob has not the attribute, the condition will return true. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false.

Specified by:
notEquals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to not have.
Returns:
Self; the IDobQuery-object, to enable chaining.

notEquals

public IDobQuery notEquals(java.lang.String attribute,
                           java.lang.String value)
Adds a not-equals-condition to the query. This will check if the dob if dob hasn't a specific value for a specific attribute. If the dob has not the attribute, the condition will return true. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false.

Specified by:
notEquals in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to not have.
Returns:
Self; the IDobQuery-object, to enable chaining.

contains

public IDobQuery contains(java.lang.String attribute,
                          java.lang.String value)
Adds a contains-condition to the query. This will check if the dob has a specific attribute, and if this attribute contains a specific char sequence. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true. If the dob has the attribute, and the value contains the supplied value, the condition will return true. The dob-attribute-values doesn't have to equal the supplied value exactly, but can contain the value. Example: value = "def" "abcdefghijklm" - true, contains "def". "def" - true, contains "def". "abcde" - false, does not contain "def".

Specified by:
contains in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to have.
Returns:
Self; the IDobQuery-object, to enable chaining.

containsNot

public IDobQuery containsNot(java.lang.String attribute,
                             java.lang.String value)
Adds a contains-condition to the query. This will check if the dob has a specific attribute, and if this attribute doesn't contains a specific char sequence. If the dob has not the attribute, the condition will return true. If the dob has the attribute, but the value of the attribute is not the supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false. If the dob has the attribute, and the value contains the supplied value, the condition will return false. Example: value = "def" "abcdefghijklm" - false, contains "def". "def" - false, contains "def". "abcde" - true, does not contain "def".

Specified by:
containsNot in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we expect the attribute to not have.
Returns:
Self; the IDobQuery-object, to enable chaining.

bigger

public IDobQuery bigger(java.lang.String attribute,
                        int value)
Adds a bigger-than-condition to the query. This will check if a specific numerical attribute is bigger than a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return false. If the dob has the attribute, and the value is bigger the supplied value, the condition will return true.

Specified by:
bigger in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

lesser

public IDobQuery lesser(java.lang.String attribute,
                        int value)
Adds a lesser-than-condition to the query. This will check if a specific numerical attribute is lesser than a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false. If the dob has the attribute, and the value is bigger the supplied value, the condition will return false.

Specified by:
lesser in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

biggerOrEqual

public IDobQuery biggerOrEqual(java.lang.String attribute,
                               int value)
Adds a bigger-or-equal-to-condition to the query. This will check if a specific numerical attribute is bigger than, or equal to, specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true. If the dob has the attribute, and the value is bigger the supplied value, the condition will return true.

Specified by:
biggerOrEqual in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

lesserOrEqual

public IDobQuery lesserOrEqual(java.lang.String attribute,
                               int value)
Adds a lesser-or-equal-to-condition to the query. This will check if a specific numerical attribute is lesser than, or equal to, a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return true. If the dob has the attribute, and the value is bigger the supplied value, the condition will return false.

Specified by:
lesserOrEqual in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

bigger

public IDobQuery bigger(java.lang.String attribute,
                        double value)
Adds a bigger-than-condition to the query. This will check if a specific numerical attribute is bigger than a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return false. If the dob has the attribute, and the value is bigger the supplied value, the condition will return true.

Specified by:
bigger in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

lesser

public IDobQuery lesser(java.lang.String attribute,
                        double value)
Adds a lesser-than-condition to the query. This will check if a specific numerical attribute is lesser than a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return false. If the dob has the attribute, and the value is bigger the supplied value, the condition will return false.

Specified by:
lesser in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

biggerOrEqual

public IDobQuery biggerOrEqual(java.lang.String attribute,
                               double value)
Adds a bigger-or-equal-to-condition to the query. This will check if a specific numerical attribute is bigger than, or equal to, specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return false. If the dob has the attribute, and the value equals the supplied value, the condition will return true. If the dob has the attribute, and the value is bigger the supplied value, the condition will return true.

Specified by:
biggerOrEqual in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

lesserOrEqual

public IDobQuery lesserOrEqual(java.lang.String attribute,
                               double value)
Adds a lesser-or-equal-to-condition to the query. This will check if a specific numerical attribute is lesser than, or equal to, a specific value. If the dob has not the attribute, the condition will return false. If the dob has the attribute, and the value is lesser than supplied value, the condition will return true. If the dob has the attribute, and the value equals the supplied value, the condition will return true. If the dob has the attribute, and the value is bigger the supplied value, the condition will return false.

Specified by:
lesserOrEqual in interface IDobQuery
Parameters:
attribute - The attribute we want to examine.
value - The value we want to compare with.
Returns:
Self; the IDobQuery-object, to enable chaining.

isNumeric

public IDobQuery isNumeric(java.lang.String attribute)
Adds a is-attribute-numeric-condition to the query. This will check if a specific attribute is numeric or not. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the attribute is not numeric, the condition will return false. If the dob has the attribute and the attribute is numeric, the condition will return true.

Specified by:
isNumeric in interface IDobQuery
Parameters:
attribute - The attribute we want to check type for.
Returns:
Self; the IDobQuery-object, to enable chaining.

isNotNumeric

public IDobQuery isNotNumeric(java.lang.String attribute)
Adds a is-not-attribute-numeric-condition to the query. This will check if a specific attribute is not numeric or if it is. If the dob has not the attribute, the condition will return false. If the dob has the attribute, but the attribute is not numeric, the condition will return true. If the dob has the attribute and the attribute is numeric, the condition will return false.

Specified by:
isNotNumeric in interface IDobQuery
Parameters:
attribute - The attribute we want to check type for.
Returns:
Self; the IDobQuery-object, to enable chaining.

filter

public IDobCollection filter(IDobCollection dobCollection)
Takes a IDobCollection as an argument, and returns a new IDobCollection with all IDobs that fullfilled the requirements specified in the query.

Specified by:
filter in interface IDobQuery
Parameters:
dobCollection - The collection we want to filter, with the requirements/conditions specified in the query.
Returns:
The new filtered IDobCollection.

isTrue

public boolean isTrue(IDob dob)
Takes a specific IDob as an argument, and returns true if the IDob fullfills all requirements specified in the query.

Specified by:
isTrue in interface IDobQuery
Parameters:
dob - The Dob we want to test.
Returns:
True or false, depening of if the dob fullfills all requirements in the query, or not.