Class MFieldAccessor


  • @PublicAPI
    public abstract class MFieldAccessor
    extends Object
    Abstract class for extracting fields (properties) from input and storing them. Under development, please do not implement it yet!
    Since:
    Marvin 5.0, 11/08/2007
    • Constructor Detail

      • MFieldAccessor

        public MFieldAccessor()
    • Method Detail

      • getMainMolecule

        public abstract Molecule getMainMolecule​(int irec,
                                                 Molecule mol)
        Gets the main molecule object in a record.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        Returns:
        the main molecule object or null if it does not exist
      • getKeys

        public abstract String[] getKeys​(int irec,
                                         Molecule mol)
        Gets the keys in a record.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        Returns:
        the array of keys
      • getFields

        public abstract void getFields​(int irec,
                                       Molecule mol,
                                       String[] keys,
                                       MProp[] values)
        Extracts properties.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        keys - array of field keys
        values - the output array, may contain null if a property is not found
      • setFields

        public abstract void setFields​(int irec,
                                       Molecule mol,
                                       String[] keys,
                                       MProp[] values)
        Sets properties.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        keys - array of field keys
        values - array of values
      • isEditable

        public abstract boolean isEditable​(int irec,
                                           Molecule mol,
                                           String key)
        Tests whether a field is editable or not.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        key - the field key
        Returns:
        true if setFields works for this key, false otherwise
      • setField

        public final void setField​(int irec,
                                   Molecule mol,
                                   String key,
                                   MProp p)
        Sets a property.
        Parameters:
        irec - the record number
        mol - input molecule, may be null in case of an implementation for which the record number is enough
        key - the field key
        p - the property value
      • propToString

        protected String propToString​(MProp p)
        Converts a property to a string. Utility method called by implementations.
        Parameters:
        p - the property
        Returns:
        the string value