Package com.aoindustries.aoserv.client
Class CachedTable<K,V extends CachedObject<K,V>>
java.lang.Object
com.aoindustries.aoserv.client.AoservTable<K,V>
com.aoindustries.aoserv.client.CachedTable<K,V>
- Direct Known Subclasses:
CachedTableAccountNameKey
,CachedTableGroupNameKey
,CachedTableIntegerKey
,CachedTableLongKey
,CachedTableStringKey
,CachedTableUserNameKey
,CachedTableUserNameKey
,CachedTableUserNameKey
,CachedTableUserNameKey
A
CachedTable
stores all of the
available CachedObject
s and performs
all subsequent data access locally. The server
notifies the client when a table is updated, and
the caches are then invalidated. Once invalidated,
the data is reloaded upon next use.- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.aoindustries.aoserv.client.AoservTable
AoservTable.OrderBy
-
Field Summary
Fields inherited from class com.aoindustries.aoserv.client.AoservTable
ASCENDING, connector, DESCENDING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the cache, freeing up memory.getIndexedRows
(int col, Object value) Gets the rows in a more efficient, indexed manner.getRows()
Gets the complete list of objects in the table.Gets a modifiable copy of the rows, which may then be manipulated, such as for sorting.protected final V
getUniqueRowImpl
(int col, Object value) Gets a row given a unique column value.final boolean
isLoaded()
Checks if the table is loaded.Methods inherited from class com.aoindustries.aoserv.client.AoservTable
addProgressListener, addTableListener, addTableListener, addTableLoadListener, get, getCachedRowCount, getConnector, getDefaultOrderBy, getDefaultOrderBySqlExpressions, getIndexedRows, getMap, getNewObject, getObject, getObjects, getObjects, getObjects, getObjectsNoProgress, getObjectsNoProgress, getSize, getSortAlgorithm, getTableId, getTableName, getTableSchema, getUniqueRow, getUniqueRow, getUniqueRow, getUniqueRow, handleCommand, hasAnyTableListener, hasTableListener, isEmpty, iterator, printTable, removeProgressListener, removeTableListener, removeTableLoadListener, size, sortIfNeeded, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CachedTable
-
-
Method Details
-
getIndexedRows
Description copied from class:AoservTable
Gets the rows in a more efficient, indexed manner.Implementation Note:
This default implementation simply throws UnsupportedOperationException.- Overrides:
getIndexedRows
in classAoservTable<K,
V extends CachedObject<K, V>> - Throws:
IOException
SQLException
-
getUniqueRowImpl
Description copied from class:AoservTable
Gets a row given a unique column value.- Specified by:
getUniqueRowImpl
in classAoservTable<K,
V extends CachedObject<K, V>> - Parameters:
col
- the column index to searchvalue
- whennull
, no row is matched, even if there is a single row with a uniquelynull
value- Throws:
IOException
SQLException
-
getRows
Gets the complete list of objects in the table.- Specified by:
getRows
in interfaceTable<K>
- Overrides:
getRows
in classAoservTable<K,
V extends CachedObject<K, V>> - Returns:
- a
List
containing all of the rows - Throws:
IOException
- if unable to access the serverSQLException
- if unable to access the database- See Also:
-
getRowsCopy
Description copied from class:AoservTable
Gets a modifiable copy of the rows, which may then be manipulated, such as for sorting.This gives the table implementation a way to create a defensive copy most efficient to its underlying storage mechanism.
Note: It is best to use
AoservTable.getSortAlgorithm()
when sorting rows, as the choice of sorting can be very important when objects are pulled from non-heap source like filesystem-based objects. It is very easy for the sort itself to end up pulling all objects into heap.- Specified by:
getRowsCopy
in classAoservTable<K,
V extends CachedObject<K, V>> - Throws:
IOException
SQLException
- See Also:
-
isLoaded
public final boolean isLoaded()Description copied from class:AoservTable
Checks if the table is loaded. A table is considered loaded when accessing any part of it will be done entirely locally, avoiding any network traffic.- Overrides:
isLoaded
in classAoservTable<K,
V extends CachedObject<K, V>>
-
clearCache
public void clearCache()Clears the cache, freeing up memory. The data will be reloaded upon next use.- Overrides:
clearCache
in classAoservTable<K,
V extends CachedObject<K, V>>
-