org.nuiton.wikitty.query
Class WikittyQueryMaker

java.lang.Object
  extended by org.nuiton.wikitty.query.WikittyQueryMaker

public class WikittyQueryMaker
extends Object

Cette objet sert a construire une condition a la facon d'un flux.

Condition c = new WikittyQueryMaker().and().eq("ext.field", "toto").eq("ext.field2", 10).getCondition();

On peut aussi vouloir continuer avec un WikittyQuery pour cela on peut faire.

WikittyQuery q = new WikittyQueryMaker().and().[other condition].end();

Si un WikittyQuery est passé en parametre du constructeur et que la method end() est appeler alors la condition creee est envoyee dans le WikittyQuery et le constructeur est fermer (on ne peut plus ajouter de condition)

Le WikittyQuery lie avec cet objet lorsqu'on le recupere via la method getQuery() a en interne comme condition la valuer courante de la condition en cours d'ecriture

Since:
3.3 Last update: $Date$ by : $Author$
Version:
$Revision$
Author:
poussin

Field Summary
protected  Condition condition
          query condition
protected  Deque<Condition> openStack
          stack des conditions non terminales ouvertes
protected  WikittyQuery query
          query where to send condition when end() method called
 
Constructor Summary
WikittyQueryMaker()
           
WikittyQueryMaker(WikittyQuery query)
           
 
Method Summary
protected  void addCondition(Condition c)
          Ajout une condition
protected  void addCondition(Condition c, boolean terminal)
          Ajout une condition.
 WikittyQueryMaker and()
          And (sub query).
 WikittyQueryMaker bw(Element element)
           
 WikittyQueryMaker bw(Element element, Object lowerValue, Object upperValue)
           
 WikittyQueryMaker bw(String fqfield, Object lowerValue, Object upperValue)
          Between.
 WikittyQueryMaker close()
          Close last non terminal condition (or, and, not, in).
protected  void closeIfNecessary()
           
 WikittyQueryMaker condition(Condition c)
          Ajoute une condition, cette condition est prise comme une condition terminal Si l'on veut continuer a construire la requete, il faut avoir ajouter avant une and(), or(), not(), #in()
 WikittyQueryMaker containsAll(Element element)
           
<E> WikittyQueryMaker
containsAll(Element element, Collection<E> values)
          Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()
 WikittyQueryMaker containsAll(String element)
           
<E> WikittyQueryMaker
containsAll(String fqfield, Collection<E> values)
          Contains.
<E> WikittyQueryMaker
containsAll(String fqfield, E value1, E... values)
          Search on lists (multivalued fields) that a field contains all the values given in parameter.
 WikittyQueryMaker containsOne(Element element)
           
<E> WikittyQueryMaker
containsOne(Element element, Collection<E> values)
          Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()
 WikittyQueryMaker containsOne(String element)
           
<E> WikittyQueryMaker
containsOne(String fqfield, Collection<E> values)
          Search if a field is contained in the list of values in parameter Ex : The field with value titi is in [titi,tutu] but not in [tutu,tata] Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()
<E> WikittyQueryMaker
containsOne(String fqfield, E value1, E... values)
          Search if a field is contained in the list of values in parameter Ex : The field with value titi is in [titi,tutu] but not in [tutu,tata] Ps : Use wildcards in the values if you search for substrings.
protected static ConditionValue convertToConditionValue(Object o)
           
 WikittyQuery end()
          Ferme la construction de la condition et la met en place dans la WikittyQuery qui sera retournee
 WikittyQueryMaker eq(Element element)
           
 WikittyQueryMaker eq(Element element, Object value)
           
 WikittyQueryMaker eq(String fqfield, Object value)
          Equals.
 WikittyQueryMaker ew(Element element, Object value)
           
 WikittyQueryMaker ew(String fqfield, Object value)
          Ends with.
 WikittyQueryMaker extContainsAll(Collection<String> extensionNames)
          Extension equals.
 WikittyQueryMaker extContainsAll(String ext1, String... exts)
           
 WikittyQueryMaker exteq(String extensionName)
          Extension equals.
 WikittyQueryMaker extne(String extensionName)
          Extension not equals.
 WikittyQueryMaker ge(Element element)
           
 WikittyQueryMaker ge(Element element, Object value)
           
 WikittyQueryMaker ge(String fqfield, Object value)
          Greater than or equals.
 Condition getCondition()
           
protected  Deque<Condition> getOpenStack()
          Retourne le stack courant des conditions, si le stack est null cela veut dire que le maker ne permet plus de modification
 WikittyQuery getQuery()
          La query passee dans le constructeur ou une nouvelle query si aucune query n'avait ete passee dans le constructeur
 WikittyQueryMaker gt(Element element)
           
 WikittyQueryMaker gt(Element element, Object value)
           
 WikittyQueryMaker gt(String fqfield, Object value)
          Greater than.
 WikittyQueryMaker ideq(Object idOrWikitty)
          Id equals.
 WikittyQueryMaker idne(Object idOrWikitty)
          Id not equals.
 WikittyQueryMaker isNotNull(Element element)
           
 WikittyQueryMaker isNotNull(String fqfield)
          Is not null.
 WikittyQueryMaker isNull(Element element)
           
 WikittyQueryMaker isNull(String fqfield)
          Is null.
 WikittyQueryMaker keyword()
          Keyword.
 WikittyQueryMaker keyword(Object value)
          Keyword.
 WikittyQueryMaker le(Element element)
           
 WikittyQueryMaker le(Element element, Object value)
           
 WikittyQueryMaker le(String fqfield, Object value)
          Less than or equals.
 WikittyQueryMaker like(Element element)
           
 WikittyQueryMaker like(Element element, Object value)
           
 WikittyQueryMaker like(String fqfield, Object value)
          Like.
 WikittyQueryMaker lt(Element element)
           
 WikittyQueryMaker lt(Element element, Object value)
           
 WikittyQueryMaker lt(String fqfield, Object value)
          Less than.
 WikittyQueryMaker ne(Element element)
           
 WikittyQueryMaker ne(Element element, Object value)
           
 WikittyQueryMaker ne(String fqfield, Object value)
          Not equals.
 WikittyQueryMaker not()
          Not (sub query).
 WikittyQueryMaker notew(Element element, Object value)
           
 WikittyQueryMaker notew(String fqfield, Object value)
          Not ends with.
 WikittyQueryMaker notsw(Element element, String value)
           
 WikittyQueryMaker notsw(String fqfield, String value)
          Not starts with.
 WikittyQueryMaker or()
          Or (sub query).
 WikittyQueryMaker rFalse()
          False.
 WikittyQueryMaker rTrue()
          True.
 WikittyQueryMaker select(Element element)
           
 WikittyQueryMaker select(Element element, Aggregate aggregate)
           
 WikittyQueryMaker select(String element)
          Add Select, this condition must be first or
 WikittyQueryMaker select(String element, Aggregate aggregate)
          Add Select, this condition must be first or
 WikittyQueryMaker sw(Element element, String value)
           
 WikittyQueryMaker sw(String fqfield, String value)
          Starts with.
 WikittyQueryMaker unlike(Element element)
           
 WikittyQueryMaker unlike(Element element, Object value)
           
 WikittyQueryMaker unlike(String fqfield, Object value)
          Unlike.
 WikittyQueryMaker value(Object value)
           
 WikittyQueryMaker wikitty(BusinessEntityImpl e)
          Ajoute une contrainte qui cree les conditions en prenant comme exemple l'objet passer en parametre.
 WikittyQueryMaker wikitty(Wikitty w)
          Ajoute une contrainte qui cree les conditions en prenant comme exemple l'objet passer en parametre.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

protected WikittyQuery query
query where to send condition when end() method called


condition

protected Condition condition
query condition


openStack

protected Deque<Condition> openStack
stack des conditions non terminales ouvertes

Constructor Detail

WikittyQueryMaker

public WikittyQueryMaker()

WikittyQueryMaker

public WikittyQueryMaker(WikittyQuery query)
Method Detail

getCondition

public Condition getCondition()

getQuery

public WikittyQuery getQuery()
La query passee dans le constructeur ou une nouvelle query si aucune query n'avait ete passee dans le constructeur

Returns:

getOpenStack

protected Deque<Condition> getOpenStack()
Retourne le stack courant des conditions, si le stack est null cela veut dire que le maker ne permet plus de modification

Returns:

addCondition

protected void addCondition(Condition c)
Ajout une condition


addCondition

protected void addCondition(Condition c,
                            boolean terminal)
Ajout une condition. Si terminal est true, alors quelque soit le type de cette condition la stack restera inchange apres l'ajout. Cela permet d'ajouter des conditions non terminale comme des terminales


closeIfNecessary

protected void closeIfNecessary()

convertToConditionValue

protected static ConditionValue convertToConditionValue(Object o)

value

public WikittyQueryMaker value(Object value)

condition

public WikittyQueryMaker condition(Condition c)
Ajoute une condition, cette condition est prise comme une condition terminal Si l'on veut continuer a construire la requete, il faut avoir ajouter avant une and(), or(), not(), #in()

Parameters:
c - la condition a ajouter
Returns:
this with the c restriction added.

wikitty

public WikittyQueryMaker wikitty(Wikitty w)
Ajoute une contrainte qui cree les conditions en prenant comme exemple l'objet passer en parametre. Seuls les champs non null sont utilises ainsi que la liste des extensions de l'objet

Parameters:
w - le wikitty a prendre comme exemple
Returns:
this with the w restriction added.

wikitty

public WikittyQueryMaker wikitty(BusinessEntityImpl e)
Ajoute une contrainte qui cree les conditions en prenant comme exemple l'objet passer en parametre. Seuls les champs non null sont utilises ainsi que la liste des extensions de l'objet

Parameters:
e - l'objet a prendre comme exemple
Returns:
this with the e restriction added.

containsAll

public WikittyQueryMaker containsAll(Element element)
See Also:
ContainsAll}

containsAll

public WikittyQueryMaker containsAll(String element)
See Also:
ContainsAll}

containsAll

public <E> WikittyQueryMaker containsAll(String fqfield,
                                         Collection<E> values)
Contains. Search on lists (multivalued fields) that a field contains all the values of the list given in parameter. Ex : The field with value [toto,titi,tutu] contains [titi,tutu] but not [titi,tutu,tata] Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

Parameters:
element - the element on which the restriction is put
values - the values to search in the element
Returns:
this with the contains restriction added.
See Also:
ContainsAll}

containsAll

public <E> WikittyQueryMaker containsAll(Element element,
                                         Collection<E> values)
Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

See Also:
ContainsAll}

containsAll

public <E> WikittyQueryMaker containsAll(String fqfield,
                                         E value1,
                                         E... values)
Search on lists (multivalued fields) that a field contains all the values given in parameter. Ex : The field with value [toto,titi,tutu] contains [titi,tutu] but not [titi,tutu,tata] Ps : Use wildcards if you search for substrings. Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

Parameters:
element - the element on which the restriction is put
value1 - first value to search in the field
values - list of values to search in the field
Returns:
this with the contains restriction added.
See Also:
ContainsAll}

containsOne

public WikittyQueryMaker containsOne(Element element)
See Also:
ContainsOne}

containsOne

public WikittyQueryMaker containsOne(String element)
See Also:
ContainsOne}

containsOne

public <E> WikittyQueryMaker containsOne(String fqfield,
                                         Collection<E> values)
Search if a field is contained in the list of values in parameter Ex : The field with value titi is in [titi,tutu] but not in [tutu,tata] Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

Parameters:
element - the element on which the restriction is put
values - list of values the field must be in
Returns:
this with the in restriction added.
See Also:
ContainsOne}

containsOne

public <E> WikittyQueryMaker containsOne(Element element,
                                         Collection<E> values)
Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

See Also:
ContainsOne}

containsOne

public <E> WikittyQueryMaker containsOne(String fqfield,
                                         E value1,
                                         E... values)
Search if a field is contained in the list of values in parameter Ex : The field with value titi is in [titi,tutu] but not in [tutu,tata] Ps : Use wildcards in the values if you search for substrings. Force l'ajout du containsAll en terminal (il n'y a pas besoin de faire de close()

Parameters:
element - the element on which the restriction is put
value1 - first value the field must be in
values - list of values the field must be in
Returns:
this with the in restriction added.
See Also:
ContainsOne}

eq

public WikittyQueryMaker eq(Element element)
See Also:
Equals}

eq

public WikittyQueryMaker eq(String fqfield,
                            Object value)
Equals. Restrict search so that the field value equals the parameter. You might use patterns in your equality.

Parameters:
element - the field on which the search is made
value - the value the element must be equals to
Returns:
this
See Also:
Equals}

eq

public WikittyQueryMaker eq(Element element,
                            Object value)
See Also:
Equals}

exteq

public WikittyQueryMaker exteq(String extensionName)
Extension equals. Restrict search to wikitties that got the extension in parameter.

Parameters:
s - the extension to restrict the results to
Returns:
this with the exteq restriction added.
See Also:
Equals}

ideq

public WikittyQueryMaker ideq(Object idOrWikitty)
Id equals. Restrict search to wikitties that got the id in parameter.

Parameters:
value - the id or wikitty to restrict the results to
Returns:
this with the ideq restriction added.
See Also:
Equals}

extContainsAll

public WikittyQueryMaker extContainsAll(Collection<String> extensionNames)
Extension equals. Restrict search to wikitties that got all the extensions in parameter.

Parameters:
extensionNames - list of the extension to restrict the results to
Returns:
this with the exteq restriction added.
See Also:
ContainsAll}

extContainsAll

public WikittyQueryMaker extContainsAll(String ext1,
                                        String... exts)
See Also:
ContainsAll}

ne

public WikittyQueryMaker ne(Element element)
See Also:
NotEquals}

ne

public WikittyQueryMaker ne(String fqfield,
                            Object value)
Not equals. Restrict search to elements that are not equals to the value given in parameter.

Parameters:
fqfield - the element on which the restriction is put
value - the value the element must not be equals to.
Returns:
this with the neq restriction added.
See Also:
NotEquals}

ne

public WikittyQueryMaker ne(Element element,
                            Object value)
See Also:
NotEquals}

extne

public WikittyQueryMaker extne(String extensionName)
Extension not equals. Restrict search to wikitties that do not get the extension given in parameter.

Parameters:
extensionName - the extension that the wikitties must not have.
Returns:
this with the extneq restriction added.
See Also:
NotEquals}

idne

public WikittyQueryMaker idne(Object idOrWikitty)
Id not equals. Restrict search to wikitties that do not have the id given in parameter.

Parameters:
idOrWikitty - the id the wikitties must not have.
Returns:
this with the idne restriction added.
See Also:
NotEquals}

gt

public WikittyQueryMaker gt(Element element)
See Also:
Greater}

gt

public WikittyQueryMaker gt(String fqfield,
                            Object value)
Greater than. Search if an element value is greater than the parameter.

Parameters:
fqfield - the element on which the restriction is put
value - the value to be compared to
Returns:
this with the gt restriction added.
See Also:
Greater}

gt

public WikittyQueryMaker gt(Element element,
                            Object value)
See Also:
Greater}

ge

public WikittyQueryMaker ge(Element element)
See Also:
GreaterOrEquals}

ge

public WikittyQueryMaker ge(String fqfield,
                            Object value)
Greater than or equals. Search if an element value is greater than or equals to the parameter.

Parameters:
fqfield - the field on which the search is made
value - the value to be compared to
Returns:
this with the ge restriction added.
See Also:
GreaterOrEquals}

ge

public WikittyQueryMaker ge(Element element,
                            Object value)
See Also:
GreaterOrEquals}

lt

public WikittyQueryMaker lt(Element element)
See Also:
Less}

lt

public WikittyQueryMaker lt(String fqfield,
                            Object value)
Less than. Search if an element value is less than the parameter.

Parameters:
fqfield - the element on which the restriction is put
value - the value to be compared to
Returns:
this with the lt restriction added.
See Also:
Less}

lt

public WikittyQueryMaker lt(Element element,
                            Object value)
See Also:
Less}

le

public WikittyQueryMaker le(Element element)
See Also:
LessOrEquals}

le

public WikittyQueryMaker le(String fqfield,
                            Object value)
Less than or equals. Search if an element value is less than or equals to the parameter.

Parameters:
fqfield - the element on which the restriction is put.
value - the value to be compared to.
Returns:
this with the le restriction added.
See Also:
LessOrEquals}

le

public WikittyQueryMaker le(Element element,
                            Object value)
See Also:
LessOrEquals}

bw

public WikittyQueryMaker bw(Element element)
See Also:
Between}

bw

public WikittyQueryMaker bw(String fqfield,
                            Object lowerValue,
                            Object upperValue)
Between. Restrict search so that the element value is between the lower and upper values (it can also be equals).

Parameters:
fqfield - the element on which the restriction is put.
lowerValue - the lower bound.
upperValue - the upper bound.
Returns:
this with the le restriction added.
See Also:
Between}

bw

public WikittyQueryMaker bw(Element element,
                            Object lowerValue,
                            Object upperValue)
See Also:
Between}

sw

public WikittyQueryMaker sw(String fqfield,
                            String value)
Starts with. Search if an element starts with the value in parameter.

Parameters:
fqfield - the element on which the restriction is put.
value - the value the element must start with.
Returns:
this with the sw restriction added.
See Also:
Equals}

sw

public WikittyQueryMaker sw(Element element,
                            String value)
See Also:
Equals}

notsw

public WikittyQueryMaker notsw(String fqfield,
                               String value)
Not starts with. Search if an element does not starts with the value in parameter.

Parameters:
fqfield - the element on which the restriction is put.
value - the value the element must not start with.
Returns:
this with the nsw restriction added.
See Also:
NotEquals}

notsw

public WikittyQueryMaker notsw(Element element,
                               String value)
See Also:
NotEquals}

ew

public WikittyQueryMaker ew(String fqfield,
                            Object value)
Ends with. Search if an element ends with the value in parameter.

Parameters:
fqfield - the element on which the restriction is put
value - the value the element must ends with.
Returns:
this with the ew restriction added.
See Also:
Equals}

ew

public WikittyQueryMaker ew(Element element,
                            Object value)
See Also:
Equals}

notew

public WikittyQueryMaker notew(String fqfield,
                               Object value)
Not ends with. Search if an element does not ends with the value in parameter.

Parameters:
fqfield - the element on which the restriction is put
value - the value the element must not ends with.
Returns:
this with the notew restriction added.
See Also:
NotEquals}

notew

public WikittyQueryMaker notew(Element element,
                               Object value)
See Also:
NotEquals}

keyword

public WikittyQueryMaker keyword()
Keyword. Search if the value in parameter is present in any field of any extension.

Parameters:
value - the value to find.
Returns:
this with the keyword restriction added.
See Also:
Keyword}

keyword

public WikittyQueryMaker keyword(Object value)
Keyword. Search if the value in parameter is present in any field of any extension.

Parameters:
value - the value to find.
Returns:
this with the keyword restriction added.
See Also:
Keyword}

isNull

public WikittyQueryMaker isNull(String fqfield)
Is null. Check that a field is null.

Parameters:
fqfield - the field that must be null.
Returns:
this with the isNull restriction added.
See Also:
Null}

isNull

public WikittyQueryMaker isNull(Element element)
See Also:
Null}

isNotNull

public WikittyQueryMaker isNotNull(String fqfield)
Is not null. Check that a field is not null.

Parameters:
fqfield - the field that must not be null.
Returns:
this with the isNotNull restriction added.
See Also:
NotNull}

isNotNull

public WikittyQueryMaker isNotNull(Element element)
See Also:
NotNull}

rFalse

public WikittyQueryMaker rFalse()
False. Add a restriction that always return false.

Returns:
this with the rFalse restriction added.
See Also:
False}

rTrue

public WikittyQueryMaker rTrue()
True. Add a restriction that always return true.

Returns:
this with the rTrue restriction added.
See Also:
True}

like

public WikittyQueryMaker like(Element element)
See Also:
Like}

like

public WikittyQueryMaker like(String fqfield,
                              Object value)
Like. Check that a string is present in a field. For example "tric" is present in "Restriction".

Parameters:
fqfield - the element on which the restriction is put
value -
Returns:
this
See Also:
Like}

like

public WikittyQueryMaker like(Element element,
                              Object value)
See Also:
Like}

unlike

public WikittyQueryMaker unlike(Element element)
See Also:
Unlike}

unlike

public WikittyQueryMaker unlike(String fqfield,
                                Object value)
Unlike.

Parameters:
fqfield - the element on which the restriction is put
value -
searchAs -
Returns:
this
See Also:
Unlike}

unlike

public WikittyQueryMaker unlike(Element element,
                                Object value)
See Also:
Unlike}

not

public WikittyQueryMaker not()
Not (sub query). To close this sub query you must used close()
  • ex: WikittyQueryMaker().not().rTrue().close().and().rTrue().rFalse().close().or().rTrue().rFalse().close();

    See Also:
    Not}

  • or

    public WikittyQueryMaker or()
    Or (sub query). To close this sub query you must used close()
  • ex: WikittyQueryMaker().not().rTrue().close().and().rTrue().rFalse().close().or().rTrue().rFalse().close();

    See Also:
    Or}

  • and

    public WikittyQueryMaker and()
    And (sub query). To close this sub query you must used close()
  • ex: WikittyQueryMaker().not().rTrue().close().and().rTrue().rFalse().close().or().rTrue().rFalse().close();

    See Also:
    And}

  • select

    public WikittyQueryMaker select(String element)
    Add Select, this condition must be first or

    Parameters:
    element - le champs dont il faut extraire les donnees
    Returns:
    this
    See Also:
    Select}

    select

    public WikittyQueryMaker select(String element,
                                    Aggregate aggregate)
    Add Select, this condition must be first or

    Parameters:
    element - le champs dont il faut extraire les donnees
    Returns:
    this
    See Also:
    Select}

    select

    public WikittyQueryMaker select(Element element)

    select

    public WikittyQueryMaker select(Element element,
                                    Aggregate aggregate)

    close

    public WikittyQueryMaker close()
    Close last non terminal condition (or, and, not, in).
  • ex: WikittyQueryMaker().not().rTrue().close().and().rTrue().rFalse().close().or().rTrue().rFalse().close();

    Returns:

  • end

    public WikittyQuery end()
    Ferme la construction de la condition et la met en place dans la WikittyQuery qui sera retournee

    Returns:
    un objet WikittyQuery soit un nouveau soit celui passe dans le constructeur


    Copyright © 2009-2012 CodeLutin. All Rights Reserved.