com.indexdata.torus2.rw.impl
Class ProxyReaderWriter

java.lang.Object
  extended by com.indexdata.torus2.rw.impl.ProxyReaderWriter
All Implemented Interfaces:
RealmReaderWriter
Direct Known Subclasses:
CachingReaderWriter

public class ProxyReaderWriter
extends Object
implements RealmReaderWriter

Author:
jakub

Field Summary
protected  RealmReaderWriter rw
           
 
Constructor Summary
ProxyReaderWriter(RealmReaderWriter rw)
           
 
Method Summary
 boolean create(RealmDefinition rd)
          Creates a new new realm store.
 void deleteCachedAsOriginal(String id)
           
 void deleteMasterRecord(String id)
           
 void deleteOverrideRecord(String id)
           
 void deleteParentRealm(String prId)
           
 void deleteWorldRecordsByParentId(String prId)
           
 RealmDefinition describe()
          Retrieves RealmDefinition for the given realm.
 void destroy()
          Destroys the underlying record store;
 boolean isCachedAsParent()
          In case the realm serves as parent to other realms within the same torus installation, the following function allows for fast propagation of changes to child realms.
 List<RealmDefinition> listRealms()
          List all realms available within the torus.
 boolean open()
          Attempts to open the realm store pointed to by this instance.
 Record.Layer readMasterRecord(String id)
           
 List<Record.Layer> readMasterRecords()
           
 Record.Layer readOverrideRecord(String id)
          Retrieve override record by id.
 List<Record.Layer> readOverrideRecords()
          Retrieve a list of override records within this realm, the query parameter is used ONLY to early filter out false matches, that is records that CONTAIN a given query field but the value DOES NOT match.
 ParentRealm readParentRealm(String prId)
           
 List<ParentRealm> readParentRealms()
           
 Record.Layer readWorldRecord(String id)
          Retrieve world (within a set of parents) record by id.
 List<Record.Layer> readWorldRecordsForParent(String prId)
          Retrieve a list of records for a parent specified within this realm,
 Record.Layer updateCachedAsOriginal(Record.Layer original)
           
 Record.Layer writeMasterRecord(Record.Layer record)
           
 Record.Layer writeMasterRecord(String id, Record.Layer record)
           
 Record.Layer writeOverrideRecord(Record.Layer doc)
          The method is to write new record to the record store.
 Record.Layer writeOverrideRecord(String id, Record.Layer doc)
          Write data to the existing record.
 ParentRealm writeParentRealm(ParentRealm pr)
           
 ParentRealm writeParentRealm(String prId, ParentRealm pr)
           
 List<Record.Layer> writeWorldRecordsForParent(List<Record.Layer> recs, String prId)
          Stores parent records for the given parent, updates each world record with an ID unique to this realm (so world records can be looked up without specifying parent)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rw

protected RealmReaderWriter rw
Constructor Detail

ProxyReaderWriter

public ProxyReaderWriter(RealmReaderWriter rw)
Method Detail

create

public boolean create(RealmDefinition rd)
               throws InternalIOException
Description copied from interface: RealmReaderWriter
Creates a new new realm store. Returns true if the realm store has been properly created or false if the realm store already exists. already exists.

Specified by:
create in interface RealmReaderWriter
Throws:
InternalIOException

open

public boolean open()
             throws InternalIOException
Description copied from interface: RealmReaderWriter
Attempts to open the realm store pointed to by this instance. Returns true if the realm has been properly opened or false if the realm has already been opened (e.g on consecutive calls)

Specified by:
open in interface RealmReaderWriter
Returns:
Throws:
InternalIOException

describe

public RealmDefinition describe()
Description copied from interface: RealmReaderWriter
Retrieves RealmDefinition for the given realm.

Specified by:
describe in interface RealmReaderWriter
Returns:

destroy

public void destroy()
             throws InternalIOException
Description copied from interface: RealmReaderWriter
Destroys the underlying record store;

Specified by:
destroy in interface RealmReaderWriter
Throws:
InternalIOException

readOverrideRecords

public List<Record.Layer> readOverrideRecords()
                                       throws InternalIOException
Description copied from interface: RealmReaderWriter
Retrieve a list of override records within this realm, the query parameter is used ONLY to early filter out false matches, that is records that CONTAIN a given query field but the value DOES NOT match.

Specified by:
readOverrideRecords in interface RealmReaderWriter
Returns:
list (possibly empty e.g when realm contains no records) of records
Throws:
InternalIOException - when experiencing problems reading/parsing records

readOverrideRecord

public Record.Layer readOverrideRecord(String id)
                                throws InternalIOException
Description copied from interface: RealmReaderWriter
Retrieve override record by id.

Specified by:
readOverrideRecord in interface RealmReaderWriter
Parameters:
id - override record id
Returns:
found record
Throws:
InternalIOException - when experiencing problems reading/parsing records

writeOverrideRecord

public Record.Layer writeOverrideRecord(String id,
                                        Record.Layer doc)
                                 throws InternalIOException
Description copied from interface: RealmReaderWriter
Write data to the existing record. This method does not merge anything, it simply override the existing record.

Specified by:
writeOverrideRecord in interface RealmReaderWriter
Parameters:
id - id of the records
Returns:
written contents doc, possibly with additional fields
Throws:
InternalIOException

writeOverrideRecord

public Record.Layer writeOverrideRecord(Record.Layer doc)
                                 throws InternalIOException
Description copied from interface: RealmReaderWriter
The method is to write new record to the record store.

Specified by:
writeOverrideRecord in interface RealmReaderWriter
Returns:
written contents doc, with additional fields (e.g id)
Throws:
InternalIOException

deleteOverrideRecord

public void deleteOverrideRecord(String id)
                          throws InternalIOException
Specified by:
deleteOverrideRecord in interface RealmReaderWriter
Throws:
InternalIOException

readWorldRecordsForParent

public List<Record.Layer> readWorldRecordsForParent(String prId)
                                             throws InternalIOException
Description copied from interface: RealmReaderWriter
Retrieve a list of records for a parent specified within this realm,

Specified by:
readWorldRecordsForParent in interface RealmReaderWriter
Returns:
list (possibly empty, e.g when world contains no records) of records
Throws:
InternalIOException - when experiencing problems reading/parsing records

readWorldRecord

public Record.Layer readWorldRecord(String id)
                             throws InternalIOException,
                                    MalformedInputException
Description copied from interface: RealmReaderWriter
Retrieve world (within a set of parents) record by id.

Specified by:
readWorldRecord in interface RealmReaderWriter
Returns:
found record
Throws:
InternalIOException - when experiencing problems reading/parsing records
MalformedInputException - when the realmUniqueId is malformed

writeWorldRecordsForParent

public List<Record.Layer> writeWorldRecordsForParent(List<Record.Layer> recs,
                                                     String prId)
                                              throws InternalIOException
Description copied from interface: RealmReaderWriter
Stores parent records for the given parent, updates each world record with an ID unique to this realm (so world records can be looked up without specifying parent)

Specified by:
writeWorldRecordsForParent in interface RealmReaderWriter
Returns:
Throws:
InternalIOException

deleteWorldRecordsByParentId

public void deleteWorldRecordsByParentId(String prId)
                                  throws InternalIOException
Specified by:
deleteWorldRecordsByParentId in interface RealmReaderWriter
Throws:
InternalIOException

readParentRealm

public ParentRealm readParentRealm(String prId)
                            throws InternalIOException
Specified by:
readParentRealm in interface RealmReaderWriter
Throws:
InternalIOException

writeParentRealm

public ParentRealm writeParentRealm(String prId,
                                    ParentRealm pr)
                             throws InternalIOException
Specified by:
writeParentRealm in interface RealmReaderWriter
Throws:
InternalIOException

writeParentRealm

public ParentRealm writeParentRealm(ParentRealm pr)
                             throws InternalIOException
Specified by:
writeParentRealm in interface RealmReaderWriter
Throws:
InternalIOException

deleteParentRealm

public void deleteParentRealm(String prId)
                       throws InternalIOException
Specified by:
deleteParentRealm in interface RealmReaderWriter
Throws:
InternalIOException

readParentRealms

public List<ParentRealm> readParentRealms()
                                   throws InternalIOException
Specified by:
readParentRealms in interface RealmReaderWriter
Throws:
InternalIOException

listRealms

public List<RealmDefinition> listRealms()
                                 throws InternalIOException
Description copied from interface: RealmReaderWriter
List all realms available within the torus. This method feels welted on here, but introducing tree hierarchy would complicate third-party implementations.

Specified by:
listRealms in interface RealmReaderWriter
Returns:
Throws:
InternalIOException

isCachedAsParent

public boolean isCachedAsParent()
                         throws InternalIOException
Description copied from interface: RealmReaderWriter
In case the realm serves as parent to other realms within the same torus installation, the following function allows for fast propagation of changes to child realms.

Specified by:
isCachedAsParent in interface RealmReaderWriter
Throws:
InternalIOException

updateCachedAsOriginal

public Record.Layer updateCachedAsOriginal(Record.Layer original)
                                    throws InternalIOException
Specified by:
updateCachedAsOriginal in interface RealmReaderWriter
Throws:
InternalIOException

deleteCachedAsOriginal

public void deleteCachedAsOriginal(String id)
                            throws InternalIOException
Specified by:
deleteCachedAsOriginal in interface RealmReaderWriter
Throws:
InternalIOException

readMasterRecord

public Record.Layer readMasterRecord(String id)
                              throws InternalIOException
Specified by:
readMasterRecord in interface RealmReaderWriter
Throws:
InternalIOException

writeMasterRecord

public Record.Layer writeMasterRecord(Record.Layer record)
                               throws InternalIOException
Specified by:
writeMasterRecord in interface RealmReaderWriter
Throws:
InternalIOException

writeMasterRecord

public Record.Layer writeMasterRecord(String id,
                                      Record.Layer record)
                               throws InternalIOException
Specified by:
writeMasterRecord in interface RealmReaderWriter
Throws:
InternalIOException

readMasterRecords

public List<Record.Layer> readMasterRecords()
                                     throws InternalIOException
Specified by:
readMasterRecords in interface RealmReaderWriter
Throws:
InternalIOException

deleteMasterRecord

public void deleteMasterRecord(String id)
                        throws InternalIOException
Specified by:
deleteMasterRecord in interface RealmReaderWriter
Throws:
InternalIOException


Copyright © 2008-2013 Index Data. All Rights Reserved.