Cumulus4j API
(1.1.0)

org.cumulus4j.store.model
Class IndexEntry

java.lang.Object
  extended by org.cumulus4j.store.model.IndexEntry
All Implemented Interfaces:
StoreCallback
Direct Known Subclasses:
IndexEntryByte, IndexEntryContainerSize, IndexEntryCurrency, IndexEntryDate, IndexEntryDouble, IndexEntryFloat, IndexEntryInteger, IndexEntryLong, IndexEntryShort, IndexEntryStringLong, IndexEntryStringShort, IndexEntryURI, IndexEntryURL, IndexEntryUUID

public abstract class IndexEntry
extends Object
implements StoreCallback

Persistent index information with encrypted pointers to DataEntrys.

Since the index is type-specific, there are sub-classes for each data type. One IndexEntry instance is used for each distinct value of one certain field. Therefore, the field (represented by the property fieldMeta) and the value together form a unique key of IndexEntry - thus the value is represented by the property indexKey.

Example:

 // persistent class:
 @PersistenceCapable
 class Person
 {
        public Person(String firstName, String lastName) {
                this.firstName = firstName;
                this.lastName = lastName;
        }

        private String firstName;
        private String lastName;

        // ...
 }

 class SomeTest
 {
        @Test
        public void persistPersons()
        {
                pm.makePersistent(new Person("Alice", "Müller"));
                pm.makePersistent(new Person("Alice", "Meier"));
        }
 }
 

After running this test, there would be three instances of IndexEntryStringShort in the database indexing the values "Alice", "Müller" and "Meier". Note, that "Alice" occurs only once in the index, even though there are two Person instances using it. The two persons would be referenced from the one index-entry via getIndexValue().

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Constructor Summary
IndexEntry()
           
 
Method Summary
 boolean equals(Object obj)
           
 ClassMeta getClassMeta()
          Get the ClassMeta of the concrete type of the instance containing the field.
 FieldMeta getFieldMeta()
           Get the descriptor of the indexed field.
 long getIndexEntryID()
          Get the single primary key field (= object-identifier) of this IndexEntry.
abstract  Object getIndexKey()
          Get the value which is indexed by this instance.
 byte[] getIndexValue()
          Get the encrypted pointers to DataEntry.
 long getKeyID()
          Get the identifier of the encryption-key used to encrypt the indexValue.
 int getKeyStoreRefID()
          Get the numeric identifier of the key store.
protected  PersistenceManager getPersistenceManager()
           
 int hashCode()
           
 void jdoPreStore()
           
 void setClassMeta(ClassMeta classMeta)
           
protected  void setFieldMeta(FieldMeta fieldMeta)
           
protected abstract  void setIndexKey(Object indexKey)
           
 void setIndexValue(byte[] indexValue)
           
 void setKeyID(long keyID)
          Set the identifier of the encryption-key used to encrypt the indexValue.
 void setKeyStoreRefID(int keyStoreRefID)
          Set the numeric identifier of the key store.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexEntry

public IndexEntry()
Method Detail

getIndexEntryID

public long getIndexEntryID()
Get the single primary key field (= object-identifier) of this IndexEntry.

Returns:
the object-identifier (= primary key).

getFieldMeta

public FieldMeta getFieldMeta()

Get the descriptor of the indexed field.

Every IndexEntry instance belongs to one field or a part of the field (e.g. a Map's key).

Returns:
the descriptor of the indexed field.

setFieldMeta

protected void setFieldMeta(FieldMeta fieldMeta)

getClassMeta

public ClassMeta getClassMeta()
Get the ClassMeta of the concrete type of the instance containing the field.

If a field is declared in a super-class, all sub-classes have it, too. But when querying instances of a sub-class (either as candidate-class or in a relation (as concrete type of the field/property), only this given sub-class and its sub-classes should be found.

The ClassMeta here is either the same as fieldMeta.classMeta (if it is an instance of the class declaring the field) or a ClassMeta of a sub-class of fieldMeta.classMeta.

Returns:
the ClassMeta of the concrete type of the instance containing the field.

getPersistenceManager

protected PersistenceManager getPersistenceManager()

setClassMeta

public void setClassMeta(ClassMeta classMeta)

getKeyStoreRefID

public int getKeyStoreRefID()
Get the numeric identifier of the key store. The key store's String-ID is mapped to this numeric ID via KeyStoreRef instances.

Returns:
the numeric identifier of the key store.

setKeyStoreRefID

public void setKeyStoreRefID(int keyStoreRefID)
Set the numeric identifier of the key store.

Parameters:
keyStoreRefID - the numeric identifier of the key store.

getIndexKey

public abstract Object getIndexKey()
Get the value which is indexed by this instance. It serves as 2nd part of the unique key together with the property fieldMeta.

Returns:
the key.

setIndexKey

protected abstract void setIndexKey(Object indexKey)

getKeyID

public long getKeyID()
Get the identifier of the encryption-key used to encrypt the indexValue.

Returns:
the encryption-key used to encrypt this IndexEntry's contents.
See Also:
setKeyID(long)

setKeyID

public void setKeyID(long keyID)
Set the identifier of the encryption-key used to encrypt the indexValue.

Parameters:
keyID - the encryption-key used to encrypt this IndexEntry's contents.
See Also:
getKeyID()

getIndexValue

public byte[] getIndexValue()
Get the encrypted pointers to DataEntry. After decrypting this byte array, you can pass it to IndexValue.IndexValue(byte[]).

Returns:
the encrypted pointers to DataEntrys.

setIndexValue

public void setIndexValue(byte[] indexValue)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

jdoPreStore

public void jdoPreStore()
Specified by:
jdoPreStore in interface StoreCallback

Cumulus4j API
(1.1.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.