Cumulus4j API
(1.0.1)

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)
           
 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 hashCode()
           
 void jdoPreStore()
           
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.
 
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)

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.0.1)

Copyright © 2012 NightLabs Consulting GmbH. All Rights Reserved.