public class KeyManager<T> extends java.lang.Object
Constructor and Description |
---|
KeyManager()
Creates a KeyManager instance.
|
Modifier and Type | Method and Description |
---|---|
KeyQuery<T> |
createKeyQuery(java.lang.Class<T> klass,
java.lang.String keyName)
Returns a new instance of a KeyQuery class.
|
KeyQuery<T> |
createKeyQuery(java.lang.String className,
java.lang.String keyName)
Returns a new instance of a KeyQuery class.
|
static byte[] |
getKeyData(java.lang.Object obj,
java.lang.String keyName)
Access the key data for the given object and key.
|
static void |
updateIndexes(java.lang.Object obj)
Update the key indexes for the given object.
|
public KeyManager()
public KeyQuery<T> createKeyQuery(java.lang.Class<T> klass, java.lang.String keyName) throws KeyUnknownKeyNameError
klass
- Class containing the key.keyName
- Name defining the key.KeyUnknownKeyNameError
- The given keyName is not defined for the type.public KeyQuery<T> createKeyQuery(java.lang.String className, java.lang.String keyName) throws KeyUnknownKeyNameError
className
- Class name containing the key.keyName
- Name defining the key.KeyUnknownKeyNameError
- The given keyName is not defined for the type.public static void updateIndexes(java.lang.Object obj) throws ObjectNotUniqueError, ManagedClassError
This method must be called after any mutable key fields have been updated to insure the key indexes reflects the field values. If the Managed object has no keys, or no key fields have been modified, this method quietly does nothing.
If mutable key fields are updated, and this method is not called, a fatal exception is thrown by the runtime at commit time.
This method does not need to be executed in a constructor, key field changes made in constructors are automatically applied to key indexes when the constructor finishes execution.
obj
- Object containing the modified key fields.ObjectNotUniqueError
- The updated fields would result in a duplicate instance.ManagedClassError
- if object is not Managed.public static byte[] getKeyData(java.lang.Object obj, java.lang.String keyName) throws ManagedClassError, KeyUnknownKeyNameError
This method returns a byte array containing the key data stored in the fields that comprise a key for the object. This byte array can be used to compute a hash value for the instance by key value.
obj
- Object containing the key fields.keyName
- Name defining the key.ManagedClassError
- The object is not Managed.KeyUnknownKeyNameError
- The given keyName is not defined for the object class.