org.csstudio.platform.utility.rdb
Class CachingStringIDHelper

java.lang.Object
  extended by org.csstudio.platform.utility.rdb.StringIDHelper
      extended by org.csstudio.platform.utility.rdb.CachingStringIDHelper

public class CachingStringIDHelper
extends StringIDHelper

A StringIDHelper that caches entries so that subsequent lookups for the same item by ID are faster.

Author:
Kay Kasemir

Constructor Summary
CachingStringIDHelper(RDBUtil rdb, java.lang.String table, java.lang.String id_column, java.lang.String name_column)
          Construct helper
 
Method Summary
 StringID add(java.lang.String name)
          Add new name, unless it's already in the RDB.
 void dispose()
          Must be called for cleanup when no longer needed
 StringID find(int id)
          Locate StringID by ID
 StringID find(java.lang.String name)
          Locate StringID by name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingStringIDHelper

public CachingStringIDHelper(RDBUtil rdb,
                             java.lang.String table,
                             java.lang.String id_column,
                             java.lang.String name_column)
Construct helper

Parameters:
rdb - RDBUTil
table - Name of RDB table
id_column - Name of the ID column
name_column - Name of the Name column
Method Detail

dispose

public void dispose()
Description copied from class: StringIDHelper
Must be called for cleanup when no longer needed

Overrides:
dispose in class StringIDHelper

find

public StringID find(int id)
              throws java.lang.Exception
Description copied from class: StringIDHelper
Locate StringID by ID

Overrides:
find in class StringIDHelper
Parameters:
id - ID to locate
Returns:
StringID or null if nothing found
Throws:
java.lang.Exception - on error

find

public StringID find(java.lang.String name)
              throws java.lang.Exception
Description copied from class: StringIDHelper
Locate StringID by name

Overrides:
find in class StringIDHelper
Parameters:
name - Name to locate
Returns:
StringID or null if nothing found
Throws:
java.lang.Exception - on error

add

public StringID add(java.lang.String name)
             throws java.lang.Exception
Description copied from class: StringIDHelper
Add new name, unless it's already in the RDB.

Overrides:
add in class StringIDHelper
Parameters:
name - Name to add
Returns:
StringID found or generated
Throws:
java.lang.Exception - on error