Interface ORecordSchemaAware

All Known Implementing Classes:
ODocument, ODocumentEmbedded, OEdgeDocument, OVertexDocument, OViewDocument

public interface ORecordSchemaAware
Generic record representation with a schema definition. The record has multiple fields. Fields are also called properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsField(String iFieldName)
    Tells if a field is contained in current record.
    <RET> RET
    field(String iFieldName)
    Returns the value of a field.
    <RET> RET
    field(String iFieldName, OType iType)
    Returns the value of a field forcing the return type.
    field(String iFieldName, Object iFieldValue)
    Sets the value for a field.
    field(String iFieldName, Object iFieldValue, OType... iType)
    Sets the value for a field forcing the type.This is useful when you want avoid automatic conversions (for example record id to record) or need expressly a conversion between types.
    Returns the record's field names.
    int
    Returns the number of fields present in memory.
    Returns the record's field values.
    Returns the class name associated to the current record.
    Returns the schema class object for the record.
    removeField(String iFieldName)
    Removes a field.
    void
    setClassName(String iClassName)
    Sets the class for the current record.
    void
    Sets the class for the current record only if already exists in the schema.
    void
    Validates the record against the schema constraints if defined.
  • Method Details

    • field

      <RET> RET field(String iFieldName)
      Returns the value of a field.
      Parameters:
      iFieldName - Field name
      Returns:
      Field value if exists, otherwise null
    • field

      <RET> RET field(String iFieldName, OType iType)
      Returns the value of a field forcing the return type. This is useful when you want avoid automatic conversions (for example record id to record) or need expressly a conversion between types.
      Parameters:
      iFieldName - Field name
      iType - Type between the values defined in the OType enum
      Returns:
      Field value if exists, otherwise null
    • field

      ORecordSchemaAware field(String iFieldName, Object iFieldValue)
      Sets the value for a field.
      Parameters:
      iFieldName - Field name
      iFieldValue - Field value to set
      Returns:
      The Record instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • field

      ORecordSchemaAware field(String iFieldName, Object iFieldValue, OType... iType)
      Sets the value for a field forcing the type.This is useful when you want avoid automatic conversions (for example record id to record) or need expressly a conversion between types.
      Parameters:
      iFieldName - Field name
      iFieldValue - Field value to set
      iType - Type between the values defined in the OType enum
      Returns:
    • removeField

      Object removeField(String iFieldName)
      Removes a field. This operation does not set the field value to null but remove the field itself.
      Parameters:
      iFieldName - Field name
      Returns:
      The old value contained in the remove field
    • containsField

      boolean containsField(String iFieldName)
      Tells if a field is contained in current record.
      Parameters:
      iFieldName - Field name
      Returns:
      true if exists, otherwise false
    • fields

      int fields()
      Returns the number of fields present in memory.
      Returns:
      Fields number
    • fieldNames

      String[] fieldNames()
      Returns the record's field names. The returned Set object is disconnected by internal representation, so changes don't apply to the record. If the fields are ordered the order is maintained also in the returning collection.
      Returns:
      Set of string containing the field names
    • fieldValues

      Object[] fieldValues()
      Returns the record's field values. The returned object array is disconnected by internal representation, so changes don't apply to the record. If the fields are ordered the order is maintained also in the returning collection.
      Returns:
      Object array of the field values
    • getClassName

      String getClassName()
      Returns the class name associated to the current record. Can be null. Call this method after a
      invalid reference
      #reset()
      to re-associate the class.
      Returns:
      Class name if any
    • setClassName

      void setClassName(String iClassName)
      Sets the class for the current record. If the class not exists, it will be created in transparent way as empty (no fields).
      Parameters:
      iClassName - Class name to set
    • setClassNameIfExists

      void setClassNameIfExists(String iClassName)
      Sets the class for the current record only if already exists in the schema.
      Parameters:
      iClassName - Class name to set
    • getSchemaClass

      OClass getSchemaClass()
      Returns the schema class object for the record.
      Returns:
      OClass instance or null if the record has no class associated
    • validate

      void validate() throws OValidationException
      Validates the record against the schema constraints if defined. If the record breaks the validation rules, then a OValidationException exception is thrown.
      Throws:
      OValidationException