Class ORecordAbstract

java.lang.Object
com.orientechnologies.orient.core.record.ORecordAbstract
All Implemented Interfaces:
OIdentifiable, ORecordElement, ORecord, OSerializableStream, Serializable, Comparable<OIdentifiable>, Comparator<OIdentifiable>
Direct Known Subclasses:
ODocument, ORecordBytes, ORecordFlat

public abstract class ORecordAbstract extends Object implements ORecord
See Also:
  • Field Details

  • Constructor Details

    • ORecordAbstract

      public ORecordAbstract()
    • ORecordAbstract

      public ORecordAbstract(byte[] iSource)
  • Method Details

    • getIdentity

      public ORID getIdentity()
      Description copied from interface: ORecord
      Returns the record identity as <cluster-id>:<cluster-position>
      Specified by:
      getIdentity in interface OIdentifiable
      Specified by:
      getIdentity in interface ORecord
      Returns:
      ORID instance
    • setIdentity

      protected ORecordAbstract setIdentity(ORecordId iIdentity)
    • getOwner

      public ORecordElement getOwner()
      Specified by:
      getOwner in interface ORecordElement
      Returns:
      Returns record element which contains given one.
    • getRecord

      public ORecord getRecord()
      Description copied from interface: OIdentifiable
      Returns the record instance.
      Specified by:
      getRecord in interface OIdentifiable
      Returns:
      ORecord instance
    • detach

      public boolean detach()
      Description copied from interface: ORecord
      Removes all the dependencies with other records. All the relationships remain in form of RecordID. If some links contain dirty records, the detach cannot be complete and this method returns false.
      Specified by:
      detach in interface ORecord
      Returns:
      True if the document has been successfully detached, otherwise false.
    • clear

      public ORecordAbstract clear()
      Description copied from interface: ORecord
      All the fields are deleted but the record identity is maintained. Use this to remove all the document's fields.
      Specified by:
      clear in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • reset

      public ORecordAbstract reset()
      Description copied from interface: ORecord
      Resets the record to be reused. The record is fresh like just created. Use this method to recycle records avoiding the creation of them stressing the JVM Garbage Collector.
      Specified by:
      reset in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • toStream

      public byte[] toStream()
      Description copied from interface: OSerializableStream
      Marshalls the object. Transforms the current object in byte[] form to being stored or transferred over the network.
      Specified by:
      toStream in interface OSerializableStream
      Returns:
      The byte array representation of the object
      See Also:
    • fromStream

      public ORecordAbstract fromStream(byte[] iRecordBuffer)
      Description copied from interface: OSerializableStream
      Unmarshalls the object. Fills the current object with the values contained in the byte array representation restoring a previous state. Usually byte[] comes from the storage or network.
      Specified by:
      fromStream in interface OSerializableStream
      Parameters:
      iRecordBuffer - byte array representation of the object
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • fromStream

      protected ORecordAbstract fromStream(byte[] iRecordBuffer, ODatabaseDocumentInternal db)
    • setDirty

      public ORecordAbstract setDirty()
      Description copied from interface: ORecordElement
      Marks the instance as dirty. The dirty status could be propagated up if the implementation supports ownership concept.
      Specified by:
      setDirty in interface ORecordElement
      Returns:
      The object it self. Useful to call methods in chain.
    • setDirtyNoChanged

      public void setDirtyNoChanged()
      Specified by:
      setDirtyNoChanged in interface ORecordElement
    • isDirty

      public boolean isDirty()
      Description copied from interface: ORecord
      Checks if the record is dirty, namely if it was changed in memory.
      Specified by:
      isDirty in interface ORecord
      Returns:
      True if dirty, otherwise false
    • fromJSON

      public <RET extends ORecord> RET fromJSON(String iSource, String iOptions)
    • fromJSON

      public <RET extends ORecord> RET fromJSON(String iSource)
      Description copied from interface: ORecord
      Fills the record parsing the content in JSON format.
      Specified by:
      fromJSON in interface ORecord
      Parameters:
      iSource - Object content in JSON format
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • fromJSON

      public <RET extends ORecord> RET fromJSON(String iSource, boolean needReload)
    • fromJSON

      public <RET extends ORecord> RET fromJSON(InputStream iContentResult) throws IOException
      Throws:
      IOException
    • toJSON

      public String toJSON()
      Description copied from interface: ORecord
      Exports the record in JSON format.
      Specified by:
      toJSON in interface ORecord
      Returns:
      Object content in JSON format
    • toJSON

      public String toJSON(String format)
      Description copied from interface: ORecord
      Exports the record in JSON format specifying additional formatting settings.
      Specified by:
      toJSON in interface ORecord
      Parameters:
      format - Format settings separated by comma. Available settings are:
      • rid: exports the record's id as property "@rid"
      • version: exports the record's version as property "@version"
      • class: exports the record's class as property "@class"
      • attribSameRow: exports all the record attributes in the same row
      • indent:<level>: Indents the output if the <level> specified. Default is 0
      Example: "rid,version,class,indent:6" exports record id, version and class properties along with record properties using an indenting level equals of 6.
      Returns:
      Object content in JSON format
    • toJSON

      public void toJSON(String format, OutputStream stream) throws IOException
      Throws:
      IOException
    • toJSON

      public void toJSON(OutputStream stream) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVersion

      public int getVersion()
      Description copied from interface: ORecord
      Returns the current version number of the record. When the record is created has version = 0. At every change the storage increment the version number. Version number is used by Optimistic transactions to check if the record is changed in the meanwhile of the transaction.
      Specified by:
      getVersion in interface ORecord
      Returns:
      The version number. 0 if it's a brand new record.
      See Also:
    • setVersion

      protected void setVersion(int iVersion)
    • unload

      public ORecordAbstract unload()
      Description copied from interface: ORecord
      Unloads current record. All information are lost but the record identity. At the next access the record will be auto-reloaded. Useful to free memory or to avoid to keep an old version of it.
      Specified by:
      unload in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • load

      @Deprecated public ORecord load()
      Deprecated.
      Description copied from interface: ORecord
      Loads the record content in memory. If the record is in cache will be returned a new instance, so pay attention to use the returned. If the record is dirty, then it returns to the original content. If the record does not exist a ORecordNotFoundException exception is thrown.

      Use

      invalid reference
      ODatabaseSession#load(ORecord)
      instead.
      Specified by:
      load in interface ORecord
      Returns:
      The record loaded or itself if the record has been reloaded from the storage. Useful to call methods in chain.
    • getDatabase

      public ODatabaseDocumentInternal getDatabase()
      Description copied from interface: ORecord
      Returns the database where the record belongs.
      Specified by:
      getDatabase in interface ORecord
      Returns:
    • getDatabaseIfDefined

      public ODatabaseDocumentInternal getDatabaseIfDefined()
    • reload

      @Deprecated public ORecord reload()
      Deprecated.
      Description copied from interface: ORecord
      Loads the record content in memory. No cache is used. If the record is dirty, then it returns to the original content. If the record does not exist a ORecordNotFoundException exception is thrown.

      Use ODatabaseDocument.reload(OElement) instead.

      Specified by:
      reload in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • reload

      @Deprecated public ORecord reload(String fetchPlan)
      Deprecated.
    • reload

      @Deprecated public ORecord reload(String fetchPlan, boolean ignoreCache)
      Deprecated.
    • reload

      @Deprecated public ORecord reload(String fetchPlan, boolean ignoreCache, boolean force) throws ORecordNotFoundException
      Deprecated.
      Description copied from interface: ORecord
      Use
      invalid reference
      ODatabaseSession#reload(ORecord, String, boolean)
      instead.
      Specified by:
      reload in interface ORecord
      Throws:
      ORecordNotFoundException
    • save

      Deprecated.
      Description copied from interface: ORecord
      Saves in-memory changes to the database. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others cannot access to it since it's locked.

      Use

      invalid reference
      ODatabaseSession#save(ORecord)
      instead.
      Specified by:
      save in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • save

      @Deprecated public ORecordAbstract save(String iClusterName)
      Deprecated.
      Description copied from interface: ORecord
      Saves in-memory changes to the database defining a specific cluster where to save it. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others cannot access to it since it's locked.

      Use

      invalid reference
      ODatabaseSession#save(ORecord, String)
      instead.
      Specified by:
      save in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • save

      @Deprecated public ORecordAbstract save(boolean forceCreate)
      Deprecated.
      Description copied from interface: ORecord
      Use
      invalid reference
      ODatabaseSession#save(ORecord, String)
      instead.
      Specified by:
      save in interface ORecord
      Returns:
    • save

      @Deprecated public ORecordAbstract save(String iClusterName, boolean forceCreate)
      Deprecated.
      Description copied from interface: ORecord
      Use
      invalid reference
      ODatabaseSession#save(ORecord, String)
      instead.
      Specified by:
      save in interface ORecord
      Returns:
    • delete

      @Deprecated public ORecordAbstract delete()
      Deprecated.
      Description copied from interface: ORecord
      Deletes the record from the database. Behavior depends by the current running transaction if any. If no transaction is running then the record is deleted immediately. If an Optimistic transaction is running then the record will be deleted at commit time. The current transaction will continue to see the record as deleted, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as deleted, while others cannot access to it since it's locked.
      Specified by:
      delete in interface ORecord
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • getSize

      public int getSize()
      Description copied from interface: ORecord
      Returns the size in bytes of the record. The size can be computed only for not new records.
      Specified by:
      getSize in interface ORecord
      Returns:
      the size in bytes
    • lock

      @Deprecated public void lock(boolean iExclusive)
      Deprecated.
      Description copied from interface: OIdentifiable
      Specified by:
      lock in interface OIdentifiable
    • isLocked

      @Deprecated public boolean isLocked()
      Deprecated.
      Specified by:
      isLocked in interface OIdentifiable
    • lockingStrategy

      @Deprecated public OStorage.LOCKING_STRATEGY lockingStrategy()
      Deprecated.
      Specified by:
      lockingStrategy in interface OIdentifiable
    • unlock

      @Deprecated public void unlock()
      Deprecated.
      Description copied from interface: OIdentifiable
      Specified by:
      unlock in interface OIdentifiable
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Comparator<OIdentifiable>
      Overrides:
      equals in class Object
    • compare

      public int compare(OIdentifiable iFirst, OIdentifiable iSecond)
      Specified by:
      compare in interface Comparator<OIdentifiable>
    • compareTo

      public int compareTo(OIdentifiable iOther)
      Specified by:
      compareTo in interface Comparable<OIdentifiable>
    • getInternalStatus

      public ORecordElement.STATUS getInternalStatus()
      Description copied from interface: ORecord
      Returns the current status of the record.
      Specified by:
      getInternalStatus in interface ORecord
      Returns:
      Current status as value between the defined values in the enum ORecordElement.STATUS
    • setInternalStatus

      public void setInternalStatus(ORecordElement.STATUS iStatus)
      Description copied from interface: ORecord
      Changes the current internal status.
      Specified by:
      setInternalStatus in interface ORecord
      Parameters:
      iStatus - status between the values defined in the enum ORecordElement.STATUS
    • copyTo

      public ORecordAbstract copyTo(ORecordAbstract cloned)
    • fill

      protected ORecordAbstract fill(ORID iRid, int iVersion, byte[] iBuffer, boolean iDirty)
    • fill

      protected ORecordAbstract fill(ORID iRid, int iVersion, byte[] iBuffer, boolean iDirty, ODatabaseDocumentInternal db)
    • setIdentity

      protected ORecordAbstract setIdentity(int iClusterId, long iClusterPosition)
    • unsetDirty

      protected void unsetDirty()
    • getRecordType

      protected abstract byte getRecordType()
    • onBeforeIdentityChanged

      protected void onBeforeIdentityChanged(ORecord iRecord)
    • onAfterIdentityChanged

      protected void onAfterIdentityChanged(ORecord iRecord)
    • getDatabaseInternal

      protected ODatabaseDocumentInternal getDatabaseInternal()
    • getDatabaseIfDefinedInternal

      protected ODatabaseDocumentInternal getDatabaseIfDefinedInternal()
    • flatCopy

      protected <RET extends ORecord> RET flatCopy()
    • addIdentityChangeListener

      protected void addIdentityChangeListener(OIdentityChangeListener identityChangeListener)
    • removeIdentityChangeListener

      protected void removeIdentityChangeListener(OIdentityChangeListener identityChangeListener)
    • setup

      protected void setup(ODatabaseDocumentInternal db)
    • checkForLoading

      protected void checkForLoading()
    • isContentChanged

      protected boolean isContentChanged()
    • setContentChanged

      protected void setContentChanged(boolean contentChanged)
    • clearSource

      protected void clearSource()
    • getDirtyManager

      protected ODirtyManager getDirtyManager()
    • setDirtyManager

      protected void setDirtyManager(ODirtyManager dirtyManager)
    • track

      protected void track(OIdentifiable id)
    • unTrack

      protected void unTrack(OIdentifiable id)