The KeyDescriptor class defines the position, length and other attributes of a particular key field within a record of an indexed-sequential file (key definition). It provides methods for accessing these key attributes of an indexed-sequential file.
A KeyDescriptor object is used for generating or extracting a concrete key value. Appropriate implementations of this abstract class are provided for ISAM. You can thus generate such KeyDescriptor objects themselves or have them provided via the methods of the KeyedAccessRecordFile class.
If you are working on an ISAM file with key definitions they have generated themselves, you must naturally ensure that these fit the keys defined in the file.
A KeyDescriptor object is serializable and can thus be used for Remote Method Interfaces (RMIs).
Methods
The getPosition() method returns the position of the key field in a record.
The getLength() method returns the length of the key field.
The getName() method returns the name of a named key, or null for unnamed keys. Thus with secondary keys the unique name is always returned. In the case of the primary key, whether or not a name is returned depends on the implementation.
The hasDuplicates() method is used to check whether identical key values are permitted in different records for the key concerned.
Whether the key is a primary or secondary key is checked using the isPrimary() or isSecondary() method.
PrimaryKeyDescriptorISAM
The PrimaryKeyDescriptorISAM class in the com.fujitsu.ts.jrio.DMS package is an implementation of the abstract class KeyDescriptor and represents the primary key of an ISAM file. The class offers only those methods which the abstract class specifies, as well as constructors for generating the key definitions. The following particular features apply for ISAM:
The key position must be a value between 0 and 32767. However, this does not mean that these values always make sense. The values actually used for I/O depend on other factors (block size, record format, key length), but these cannot be checked by the constructor.
The length of the key must be a value between 1 and 255.
The primary ISAM key does not have a name, and the getName() method therefore always returns null.
SecondaryKeyDescriptorISAM
The SecondaryKeyDescriptorISAM class in the com.fujitsu.ts.jrio.DMS package is an implementation of the abstract class KeyDescriptor and represents a secondary key of an ISAM file. The class offers only those methods which the abstract class specifies, as well as constructors for generating the key definitions. The following particular features apply for ISAM:
The key position must be a value between 0 and 32767. However, this does not mean that these values always make sense. The values actually used for I/O depend on other factors (block size, record format, key length), but these cannot be checked by the constructor.
The length of the key must be a value between 1 and 127.
A secondary ISAM key must have a unique name up to 8 characters in length which complies with the DMS rules. Upper/lower case is ignored in these names, and a name is always returned in upper case by getName().