BiodbEntryField-class {biodb} | R Documentation

## A class for describing an entry field.

### Description

This class is used by `BiodbEntryFields` for storing field characteristics, and returning them through the `get()` method. The constructor is not meant to be used, but for development purposes the constructor's parameters are nevertheless described in the Fields section.

### Details

The constructor accepts the following arguments:

name: The name of the field.

alias: A character vector containing zero or more aliases for the field.

type: A type describing the field. One of: "mass", "name" or "id". Optional.

class: The class of the field. One of: "character", "integer", "double", "logical", "object", "data.frame".

card: The cardinality of the field: either "1" or "*".

forbids.duplicates: If set to TRUE, the field forbids duplicated values.

description: A description of the field.

allowed.values: The values authorized for the field.

lower.case: Set to TRUE if you want all values set to the field to be forced to lower case.

case.insensitive: Set to TRUE of you want the field to ignore case when checking a value.

computable.from: The Biodb ID of a database, from which this field can be computed.

virtual: If set to `TRUE`, the field is computed from other fields, and thus cannot be modified.

virtual.group.by.type: For a virtual field of class data.frame, this indicates to gather all fields of the specified type to build a data frame.

### Methods

`addAlias(alias)`

  :

  Adds an alias to the list of aliases.

  alias: The name of a valid alias.

  Returned value: None.

`addAllowedValue(key, value)`

  :

  Adds an allowed value, as a synonym to already an existing value. Note that not all enumerate fields accept synonyms.

  key: The key associated with the value (i.e.: the key is the main name of an allowed value).

  value: The new value to add.

  Returned value: None.

`addComputableFrom(directive)`

  :

  Adds a directive from the list of computableFrom.

  directive: A valid "computable from" directive.

  Returned value: None.

`checkValue(value)`

  :

  Checks if a value is correct. Fails if 'value' is incorrect.

  value: The value to check.

  Returned value: None.

`correctValue(value)`

  :

  Corrects a value so it is compatible with this field.

  value: A value.

  Returned value: The corrected value.

`equals(other, fail = FALSE)`

  :

  Compares this instance with another, and tests if they are equal.

  other: Another BiodbEntryField instance.

  fail: If set to TRUE, then throws error instead of returning FALSE.

  Returned value: TRUE if they are equal, FALSE otherwise.

`forbidsDuplicates()`

  :

  Tests if this field forbids duplicates.

  Returned value: TRUE if this field forbids duplicated values, FALSE otherwise.

`getAliases()`

  :

  Get aliases.

  Returned value: The list of aliases if some are defined, otherwise returns NULL.

`getAllNames()`

  :

  Gets all names.

  Returned value: The list of all names (main name and aliases).

`getAllowedValues(value = NULL)`

  :

  Gets allowed values.

  value: If this parameter is set to particular allowed values, then the method returns a list of synonyms for this value (if any).

  Returned value: A character vector containing all allowed values.

`getDataFrameGroup()`

  :

  Gets the defined data frame group, if any.

  Returned value: The data frame group, as a character value.

`getDescription()`

  :

  Get field's description.

  Returned value: The description of this field.

`getName()`

  :

  Gets the name.

  Returned value: The name of this field.

`getType()`

  :

  Gets field's type.

  Returned value: The type of this field.

`getVirtualGroupByType()`

  :

  Gets type for grouping field values when building a virtual data frame.

  Returned value: The type, as a character value.

`hasAliases()`

  :

  Tests if this field has aliases.

  Returned value: TRUE if this entry field defines aliases, FALSE otherwise.

`hasCardMany()`

  :

  Tests if this field has a cardinality greater than one.

  Returned value: TRUE if the cardinality of this field is many, FALSE otherwise.

`hasCardOne()`

  :

  Tests if this field has a cardinality of one.

  Returned value: TRUE if the cardinality of this field is one, FALSE otherwise.

`isAtomic()`

  :

  Tests if this field's type is an atomic type.

  Returned value: TRUE if the field's type is vector (i.e.: character, integer, double or logical), FALSE otherwise.

`isCaseInsensitive()`

  :

  Tests if this field is case sensitive.

  Returned value: TRUE if this field is case insensitive, FALSE otherwise.

`isComputable()`

  :

  Tests if this field is computable from another field or another database.

  Returned value: TRUE if the field is computable, FALSE otherwise.

`isComputableFrom()`

  :

  Gets the ID of the database from which this field can be computed.

  Returned value: The list of databases where to find this field's value.

`isDataFrame()`

  :

  Tests if this field's type is 'data.frame'.

  Returned value: TRUE if field's type is data frame, FALSE otherwise.

`isEnumerate()`

  :

  Tests if this field is an enumerate type (i.e.: it defines allowed values).

  Returned value: TRUE if this field defines some allowed values, FALSE otherwise.

`isObject()`

  :

  Tests if this field's type is a class.

  Returned value: TRUE if field's type is a class, FALSE otherwise.

`isVector()`

  :

  Tests if this field's type is a basic vector type.

  Returned value: TRUE if the field's type is vector (i.e.: character, integer, double or logical), FALSE otherwise.

`isVirtual()`

  :

  Tests if this field is a virtual field.

  Returned value: TRUE if this field is virtual, FALSE otherwise.

`removeAlias(alias)`

  :

  Removes an alias from the list of aliases.

  alias: The name of a valid alias.

  Returned value: None.

`removeComputableFrom(directive)`

  :

  Removes a directive from the list of computableFrom.

  directive: A valid "computable from" directive.

  Returned value: None.

`updateWithValuesFrom(other)`

  :

  Updates fields using values from 'other' instance. The updated fields are: 'alias' and 'computable.from'. No values will be removed from those vectors. The new values will only be appended. This allows to extend an existing field inside a new connector definition.

  other: Another BiodbEntryField instance.

  Returned value: None.

### See Also

Parent class `BiodbEntryFields`.

### Examples

    # Get the class of the InChI field.
    mybiodb <- biodb::newInst()
    inchi.field.class <- mybiodb$getEntryFields()$get('inchi')$getClass()

    # Test the cardinality of a field
    card.one <- mybiodb$getEntryFields()$get('name')$hasCardOne()
    card.many <- mybiodb$getEntryFields()$get('name')$hasCardMany()

    # Get the description of a field
    desc <- mybiodb$getEntryFields()$get('inchi')$getDescription()

    # Terminate instance.
    mybiodb$terminate()

[Package biodb version 1.0.4 Index]