Interface ObjectTranslator

  • All Known Subinterfaces:
    ObjectConstructor
    All Known Implementing Classes:
    TClass, TCollection, THashtable, TMap, TNull, TSerializable, TTransient, TTreeMap, TTreeSet, TVector

    public interface ObjectTranslator
    translator interface to translate objects on storage and activation.

    By writing classes that implement this interface, it is possible to define how application classes are to be converted to be stored more efficiently.

    Before starting a db4o session, translator classes need to be registered. An example:
    ObjectClass oc = config.objectClass("package.className");
    oc.translate(new FooTranslator());


    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void onActivate​(ObjectContainer container, java.lang.Object applicationObject, java.lang.Object storedObject)
      db4o calls this method during activation.
      java.lang.Object onStore​(ObjectContainer container, java.lang.Object applicationObject)
      db4o calls this method during storage and query evaluation.
      java.lang.Class storedClass()
      return the Class you are converting to.
    • Method Detail

      • onStore

        java.lang.Object onStore​(ObjectContainer container,
                                 java.lang.Object applicationObject)
        db4o calls this method during storage and query evaluation.
        Parameters:
        container - the ObjectContainer used
        applicationObject - the Object to be translated
        Returns:
        return the object to store.
        It needs to be of the class storedClass().
      • onActivate

        void onActivate​(ObjectContainer container,
                        java.lang.Object applicationObject,
                        java.lang.Object storedObject)
        db4o calls this method during activation.
        Parameters:
        container - the ObjectContainer used
        applicationObject - the object to set the members on
        storedObject - the object that was stored
      • storedClass

        java.lang.Class storedClass()
        return the Class you are converting to.
        Returns:
        the Class of the object you are returning with the method onStore(ObjectContainer, Object)