DODS 7.1 API

org.enhydra.dods.cache
Class QueryCacheItemImpl

java.lang.Object
  extended by org.enhydra.dods.cache.QueryCacheItemImpl
All Implemented Interfaces:
QueryCacheItem

public class QueryCacheItemImpl
extends java.lang.Object
implements QueryCacheItem

This class stores one query and its necessary data, for query array.

Version:
2.0 15.06.2003.
Author:
Tanja Jovanovic, Nenad Vico

Field Summary
protected  boolean completeRes
          True if all query results are cached, otherwise false.
protected  java.util.ArrayList conds
          Array of conditions declared in WHERE part of the query (array of org.enhydra.dods.cache.Condition objects).
protected  org.enhydra.dods.cache.QueryCacheItemImpl.ListItem head
          Head of object ID list in which are query results.
protected  boolean modifiedQuery
          This attribute indicates whether there have been performed inserts, updates or deletes on results of this query.
protected  java.util.HashMap OIds
          HashMap of data (and DataStruct) object IDs which are results of the query.
protected  java.lang.String originDatabase
          Database of the query.
protected  java.lang.String queryId
          Query id: String "query_database_name.String_presentation_of_query".
protected  int resultNum
          Number of cached query results.
protected  org.enhydra.dods.cache.QueryCacheItemImpl.ListItem tail
          Tail of object ID list in which are query results.
protected  int time
          Time needed for query execution.
 
Constructor Summary
QueryCacheItemImpl(java.lang.String origDb)
          Constructor (String).
QueryCacheItemImpl(java.lang.String qId, java.util.HashMap OIds, int time, java.util.ArrayList conditions, java.lang.String origDb)
          Constructor (String, LinkedHashSet, int, ArrayList, String).
 
Method Summary
 void add(CoreDataStruct obj)
          Adds DataStruct object obj to array DOs.
 void add(GenericDO obj)
          Adds data object obj to array DOs.
 void addCond(Condition cond)
          Adds condition to query.
protected  void addHandle(java.lang.String handle)
           
 boolean checkConditions(CoreDataStruct obj)
          Checks whether DataStruct object obj satisfies conditions of this query.
 boolean checkConditions(GenericDO obj)
          Checks whether data object obj satisfies conditions of this query.
 void delete(CoreDataStruct obj)
          Removes DataStruct object obj from array DOs, if present.
 void delete(GenericDO obj)
          Removes data object obj from array DOs, if present.
 java.lang.String get_OriginDatabase()
          Returns query database.
 java.util.ArrayList getConds()
          Returns array of query conditions conds.
 java.util.Collection getOIds()
          Returns OIds (Collection of object IDs which are results of the query).
 java.lang.String getOriginDatabase()
          Deprecated. Use get_OriginDatabase()
 java.lang.String getQueryId()
          Returns query id (String it the form: query_database_name.String_presentation_of_query).
 int getResultNum()
          Returns number of cached query results.
 int getTime()
          Returns time needed for query execution.
 boolean isCompleteResult()
          Returns true if all query results are cached, otherwise false.
 boolean isModifiedQuery()
          Returns true if there have been performed inserts, updates or deletes concerning results of this query, otherwise false.
protected  void removeHandle(java.lang.String handle)
           
 void setCompleteResult(boolean newCompleteRes)
          Sets new boolean value about the cached query results (true if all query results are cached, otherwise false).
 void setConds(java.util.ArrayList conds)
          Sets array of query conditions.
 void setModifiedQuery(boolean mod)
          Sets modifiedQuery attribute.
 void setQueryId(java.lang.String queryId)
          Sets query id (String it the form: query_database_name.String_presentation_of_query).
 void setTime(int time)
          Sets time needed for query execution.
 java.lang.String toString()
          Shows content of this class.
 void update(CoreDataStruct obj)
          Inserts DataStruct object obj (or updates it if already exists) in array DOs, if it satisfies this query.
 void update(GenericDO obj)
          Inserts data object obj (or updates it if already exists) in array DOs, if it satisfies this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queryId

protected java.lang.String queryId
Query id: String "query_database_name.String_presentation_of_query".


OIds

protected java.util.HashMap OIds
HashMap of data (and DataStruct) object IDs which are results of the query.


resultNum

protected int resultNum
Number of cached query results.


completeRes

protected boolean completeRes
True if all query results are cached, otherwise false.


head

protected org.enhydra.dods.cache.QueryCacheItemImpl.ListItem head
Head of object ID list in which are query results.


tail

protected org.enhydra.dods.cache.QueryCacheItemImpl.ListItem tail
Tail of object ID list in which are query results.


modifiedQuery

protected boolean modifiedQuery
This attribute indicates whether there have been performed inserts, updates or deletes on results of this query.


time

protected int time
Time needed for query execution.


conds

protected java.util.ArrayList conds
Array of conditions declared in WHERE part of the query (array of org.enhydra.dods.cache.Condition objects).


originDatabase

protected java.lang.String originDatabase
Database of the query.

Constructor Detail

QueryCacheItemImpl

public QueryCacheItemImpl(java.lang.String origDb)
Constructor (String).

Parameters:
origDb - Query database.

QueryCacheItemImpl

public QueryCacheItemImpl(java.lang.String qId,
                          java.util.HashMap OIds,
                          int time,
                          java.util.ArrayList conditions,
                          java.lang.String origDb)
Constructor (String, LinkedHashSet, int, ArrayList, String).

Parameters:
qId - Query id.
OIds - Array of object IDs which are results of the Query.
time - Query execution time.
conditions - Conditions (WHERE part of the query).
origDb - Query database.
Method Detail

getQueryId

public java.lang.String getQueryId()
Returns query id (String it the form: query_database_name.String_presentation_of_query).

Specified by:
getQueryId in interface QueryCacheItem
Returns:
Query id.

setQueryId

public void setQueryId(java.lang.String queryId)
Sets query id (String it the form: query_database_name.String_presentation_of_query).

Specified by:
setQueryId in interface QueryCacheItem
Parameters:
queryId - Query id.

getOIds

public java.util.Collection getOIds()
Returns OIds (Collection of object IDs which are results of the query).

Specified by:
getOIds in interface QueryCacheItem
Returns:
Collection of object IDs which are results of the query.

getResultNum

public int getResultNum()
Returns number of cached query results.

Specified by:
getResultNum in interface QueryCacheItem
Returns:
Number of cached query results.

isCompleteResult

public boolean isCompleteResult()
Returns true if all query results are cached, otherwise false.

Specified by:
isCompleteResult in interface QueryCacheItem
Returns:
true if all query results are cached, otherwise false.

setCompleteResult

public void setCompleteResult(boolean newCompleteRes)
Sets new boolean value about the cached query results (true if all query results are cached, otherwise false).

Specified by:
setCompleteResult in interface QueryCacheItem
Parameters:
newCompleteRes - true if all query results are cached, otherwise false.

isModifiedQuery

public boolean isModifiedQuery()
Returns true if there have been performed inserts, updates or deletes concerning results of this query, otherwise false.

Specified by:
isModifiedQuery in interface QueryCacheItem
Returns:
true if there have been performed inserts, updates or deletes concerning results of this query, otherwise false.

setModifiedQuery

public void setModifiedQuery(boolean mod)
Sets modifiedQuery attribute.

Specified by:
setModifiedQuery in interface QueryCacheItem
Parameters:
mod - New value of attribute modifiedQuery. concerning results of this query, otherwise false.

getTime

public int getTime()
Returns time needed for query execution.

Specified by:
getTime in interface QueryCacheItem
Returns:
Time needed for query execution.

setTime

public void setTime(int time)
Sets time needed for query execution.

Specified by:
setTime in interface QueryCacheItem
Parameters:
time - Time needed for query execution.

getConds

public java.util.ArrayList getConds()
Returns array of query conditions conds.

Specified by:
getConds in interface QueryCacheItem
Returns:
Array of query conditions.

setConds

public void setConds(java.util.ArrayList conds)
Sets array of query conditions.

Specified by:
setConds in interface QueryCacheItem
Parameters:
conds - Array of query conditions.

addCond

public void addCond(Condition cond)
Adds condition to query.

Specified by:
addCond in interface QueryCacheItem
Parameters:
cond - Condition that will be added to query.

getOriginDatabase

public java.lang.String getOriginDatabase()
Deprecated. Use get_OriginDatabase()

Returns query database.

Specified by:
getOriginDatabase in interface QueryCacheItem
Returns:
Query database.

get_OriginDatabase

public java.lang.String get_OriginDatabase()
Returns query database.

Specified by:
get_OriginDatabase in interface QueryCacheItem
Returns:
Query database.

checkConditions

public boolean checkConditions(GenericDO obj)
Checks whether data object obj satisfies conditions of this query.

Specified by:
checkConditions in interface QueryCacheItem
Parameters:
obj - Data object for which are checked conditions of this query.
Returns:
true if data object obj satisfies conditions of this query, otherwise false.

checkConditions

public boolean checkConditions(CoreDataStruct obj)
Checks whether DataStruct object obj satisfies conditions of this query.

Specified by:
checkConditions in interface QueryCacheItem
Parameters:
obj - DataStruct object for which are checked conditions of this query.
Returns:
true if DataStruct object obj satisfies conditions of this query, otherwise false.

update

public void update(GenericDO obj)
Inserts data object obj (or updates it if already exists) in array DOs, if it satisfies this query.

Specified by:
update in interface QueryCacheItem
Parameters:
obj - Data object which may be inserted (or updated) in array DOs.

update

public void update(CoreDataStruct obj)
Inserts DataStruct object obj (or updates it if already exists) in array DOs, if it satisfies this query.

Specified by:
update in interface QueryCacheItem
Parameters:
obj - DataStruct object which may be inserted (or updated) in array DOs.

delete

public void delete(GenericDO obj)
Removes data object obj from array DOs, if present.

Specified by:
delete in interface QueryCacheItem
Parameters:
obj - Data object which will be removed from array DOs.

delete

public void delete(CoreDataStruct obj)
Removes DataStruct object obj from array DOs, if present.

Specified by:
delete in interface QueryCacheItem
Parameters:
obj - DataStruct object which will be removed from array DOs.

add

public void add(GenericDO obj)
Adds data object obj to array DOs.

Specified by:
add in interface QueryCacheItem
Parameters:
obj - Data object which will be added to array DOs.

add

public void add(CoreDataStruct obj)
Adds DataStruct object obj to array DOs.

Specified by:
add in interface QueryCacheItem
Parameters:
obj - DataStruct object which will be added to array DOs.

toString

public java.lang.String toString()
Shows content of this class. Can be used for debugging.

Overrides:
toString in class java.lang.Object

addHandle

protected void addHandle(java.lang.String handle)

removeHandle

protected void removeHandle(java.lang.String handle)

DODS 7.1 API