public class Query
extends java.lang.Object
implements java.io.Serializable
The Query class is used to submit query requests to the GANYMEDE server, both for complex database searches and for simple object listings. A Query class can fully specify a boolean search expression on any field of any object type in the GANYMEDE database. Each Query, however, can only search one object type at a time.
While providing support for arbitrarily complex queries, the Query class also includes constructors for the simple "list object" case.
| Modifier and Type | Field and Description |
|---|---|
(package private) QueryDescriber |
describer
If we are on the server, we'll have a generic reference to a
GanymedeSession so that we can look up the description of the
object type.
|
boolean |
editableOnly
If true, this query will only be matched against objects in the
database that the user has permission to edit.
|
boolean |
filtered
If true, this query will only be matched against the subset of
objects in the database that the user has requested via
the Session filter mechanism.
|
java.lang.String |
objectName
The name of the object type that the queryNodes are looking
to match on.
|
short |
objectType
The id of the object type that the queryNodes are looking
to match on.
|
private java.util.Set<java.lang.Short> |
permitSet
A Set of field id's in Short form that the server will take into
account when returning a data dump.
|
QueryNode |
root
The root of a graph of QueryNodes that encodes the desired
search criteria.
|
java.lang.String |
saveName
We want to be able to save a query on the server and re-issue it
on behalf of the user.
|
(package private) static long |
serialVersionUID |
| Constructor and Description |
|---|
Query(short objectType)
Constructor for a query to list all editable objects of the specified type.
|
Query(short objectType,
QueryNode root)
Constructor to create a query returning only editable objects (base by id)
|
Query(short objectType,
QueryNode root,
boolean editableOnly)
Constructor for fully specified query (base by id)
|
Query(java.lang.String objectName)
Constructor for a query to list all editable objects of the specified type.
|
Query(java.lang.String objectName,
QueryNode root)
Constructor to create a query returning only editable objects (base by name)
|
Query(java.lang.String objectName,
QueryNode root,
boolean editableOnly)
Constructor for fully specified query (base by name)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addField(short id)
This method adds a field identifier to the list of fields that
may be returned.
|
java.lang.String |
describeField(short fieldId) |
java.util.Set<java.lang.Short> |
getFieldSet()
Returns a copy of the restricted list of fields that this Query
wants to have returned.
|
boolean |
hasPermitSet()
This method returns true if this Query is requesting a restricted
set of fields.
|
void |
removeField(short id)
This method adds a field identifier to the list of fields that
may be returned.
|
void |
resetPermitSet()
This method resets the permitSet, allowing
all fields to be returned by default.
|
boolean |
returnField(short id)
This method returns true if the field with the given id number
should be returned.
|
boolean |
returnField(java.lang.Short value)
This method returns true if the field with the given id number
should be returned.
|
void |
setDescriber(QueryDescriber describer)
Sets a reference to a GanymedeSession on the server only, for
use in providing more descriptive toString() results.
|
void |
setFiltered(boolean filtered)
This method determines whether the query engine will filter
the query according to the current list of visible owner groups.
|
java.lang.String |
toString() |
static final long serialVersionUID
public short objectType
The id of the object type that the queryNodes are looking to match on.
If this value is left at -1, objectName will be consulted instead.
public java.lang.String objectName
The name of the object type that the queryNodes are looking to match on.
This value is consulted only if objectType is left at -1.
public java.lang.String saveName
We want to be able to save a query on the server and re-issue it on behalf of the user. If we are saved, the name to save under will be here. We may or may not want it here.
I don't believe anything in the server actually uses this yet.
public QueryNode root
The root of a graph of QueryNodes that encodes the desired search criteria.
public boolean editableOnly
If true, this query will only be matched against objects in the database that the user has permission to edit.
public boolean filtered
If true, this query will only be matched against the subset of objects in the database that the user has requested via the Session filter mechanism.
private java.util.Set<java.lang.Short> permitSet
A Set of field id's in Short form that the server will take into account when returning a data dump. If null, all default fields should be returned.
transient QueryDescriber describer
If we are on the server, we'll have a generic reference to a GanymedeSession so that we can look up the description of the object type.
public Query(short objectType,
QueryNode root,
boolean editableOnly)
Constructor for fully specified query (base by id)
objectType - numeric object type code to search overroot - root node of a boolean logic tree to be processed in an in-order traversaleditableOnly - if true, the server will only return objects that the user's session
currently has permission to editpublic Query(java.lang.String objectName,
QueryNode root,
boolean editableOnly)
Constructor for fully specified query (base by name)
objectName - name of object type to queryroot - root node of a boolean logic tree to be processed in an in-order traversaleditableOnly - if true, the server will only return objects that
the user's session currently has permission to editpublic Query(short objectType,
QueryNode root)
Constructor to create a query returning only editable objects (base by id)
objectType - numeric object type code to search overroot - root node of a boolean logic tree to be processed in an in-order traversalpublic Query(java.lang.String objectName,
QueryNode root)
Constructor to create a query returning only editable objects (base by name)
objectName - name of object type to queryroot - root node of a boolean logic tree to be processed in an in-order traversalpublic Query(short objectType)
Constructor for a query to list all editable objects of the specified type.
objectType - numeric object type code to search overpublic Query(java.lang.String objectName)
Constructor for a query to list all editable objects of the specified type.
objectName - name of object type to querypublic void setDescriber(QueryDescriber describer)
Sets a reference to a GanymedeSession on the server only, for use in providing more descriptive toString() results.
public void setFiltered(boolean filtered)
This method determines whether the query engine will filter the query according to the current list of visible owner groups. Queries by default are filtered.
filtered - If true, the query will be masked by ownershipSession.filterQueries(java.util.Vector)public void resetPermitSet()
This method resets the permitSet, allowing all fields to be returned by default.
public boolean hasPermitSet()
This method returns true if this Query is requesting a restricted set of fields.
public void addField(short id)
This method adds a field identifier to the list of fields that may be returned. Once this method is called with a field identifier, the query will only return fields that have been explicitly added.
resetPermitSet() may be called to reset the list to the initial allow-all state.
public void removeField(short id)
This method adds a field identifier to the list of fields that may be returned. Once this method is called with a field identifier, the query will only return fields that have been explicitly added.
resetPermitSet() may be called to reset the list to the initial allow-all state.
public boolean returnField(short id)
This method returns true if the field with the given id number should be returned.
public boolean returnField(java.lang.Short value)
This method returns true if the field with the given id number should be returned.
public java.util.Set<java.lang.Short> getFieldSet()
Returns a copy of the restricted list of fields that this Query wants to have returned.
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String describeField(short fieldId)