com.adobe.repository.query
Class Query

java.lang.Object
  extended by com.adobe.repository.query.Query
All Implemented Interfaces:
java.io.Serializable

public class Query
extends java.lang.Object
implements java.io.Serializable

The Query class represents a query against the Repository, which offers basic query capabilities.

Queries contain one or more statements, joined together with conditions (either Query.CONDITION_AND or Query.CONDITION_OR representing logical AND and OR, respectively). The default condition is AND. Statements consist of a left operand, an operator, and a right operand.

The left operand contains a metadata name (for example, "name"). The right operand contains the query value (for example, "foobar").

The operators are listed in Query.Statement.

The Query class does not support grouping of statements.


See Also:
Query.Statement, Serialized Form

Nested Class Summary
static class Query.Statement
          This is the query statement class.
 
Field Summary
static java.lang.Short CONDITION_AND
          A logical AND.
static java.lang.Short CONDITION_OR
          A logical OR.
 
Constructor Summary
Query()
           
 
Method Summary
 void addStatement(Query.Statement statement)
          Add a statement to the query.
 void addStatement(Query.Statement statement, java.lang.Short condition)
          Adds a statement to the query.
 java.lang.Object[] getQueryTokens()
          Returns an array of query tokens.
 java.util.List getStatements()
           
 void setStatements(java.util.List statements)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONDITION_AND

public static java.lang.Short CONDITION_AND
A logical AND.


CONDITION_OR

public static java.lang.Short CONDITION_OR
A logical OR.

Constructor Detail

Query

public Query()
Method Detail

setStatements

public void setStatements(java.util.List statements)

getStatements

public java.util.List getStatements()

addStatement

public void addStatement(Query.Statement statement)
Add a statement to the query. If this is not the first statement added to the query, the condition AND will be prepended to the query statement.

For example, given the query:

select * from Resources where name="foo"

and the addition of a new statement

version = "1.0"

the AND operator is prepended to the version statement; not to the query:

select * from Resources where name="foo" AND version = "1.0"

Parameters:
statement - The statement to add.

addStatement

public void addStatement(Query.Statement statement,
                         java.lang.Short condition)
Adds a statement to the query. If this is not the first statement added to the query, the supplied condition will be prepended to the query statement.

Parameters:
statement - The statement to add.
condition - The condition to use.

getQueryTokens

public java.lang.Object[] getQueryTokens()
Returns an array of query tokens. The array will appear as follows: [Statement,Short,Statement]. Read through the array using instanceof. Each token will either be a Query.Statement or a value representing a condition joining two statements.

Returns:
An array of Query.Statement objects as well as condition values.