org.umber.bellows.query
Class QueryCache

java.lang.Object
  extended byorg.umber.bellows.query.QueryCache

public class QueryCache
extends java.lang.Object

Cache for queries against a single Datum tree.

Author:
jsheets

Constructor Summary
QueryCache(Datum root)
          Creates a new instance of QueryCache.
 
Method Summary
 void emptyCache()
          Empties the query cache.
 Datum getRoot()
          Retrieves the root in use for all cached queries.
 Datum[] runQuery(java.lang.String query)
          Executes the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryCache

public QueryCache(Datum root)
Creates a new instance of QueryCache.

Parameters:
root - the root node for all cached queries
Method Detail

getRoot

public Datum getRoot()
Retrieves the root in use for all cached queries.

Returns:
root query node

runQuery

public Datum[] runQuery(java.lang.String query)
Executes the query. Will cache results for improved performance. If the Datum tree has been modified, call emptyCache() to delete previous runs and start a fresh query.

Parameters:
query - the XPath-like query string
Returns:
an array of found Datum objects, or a zero-length array if the query failed to match anything or if the query syntax is invalid

emptyCache

public void emptyCache()
Empties the query cache. Run this if the Datum tree changes; otherwise the browser will return stale results that may not match the latest state of the data.