Section 2.2.3.1 Class Definitions


A set of objects belong to a class if their behaviour or function is similar and if they can be described in a like fashion. The class may be viewed as a subclass, that is, a more specialized version of another class called the superclass; conversely, the superclass is a more generalized version of the subclass. Each class has a name descriptive of the objects which are members of it. Objects in the class are typically characterized by certain attributes which are explicitly stated in the definition of the class (or a superclass). Certain restrictions and constraints may also apply to these objects.

The following items may be contained within a class definition. The first two must always be provided and the remainder are optional.

1 superclassThe name of the superclass from which the class is derived must be provided. That is, the class being defined is a subclass of the superclass. As discussed previously, this relationship is central to the type inheritance hierarchy in SAIF. If the superclass is not from the SAIF data model (i.e., Tuple or Enumeration) or the SAIF standard schema, the name of the schema of which the superclass is a part must also be specified.

2 class nameNext to be stated is the name of the class which is currently being defined, including the name of the schema to which it belongs. (If the class is part of the SAIF standard schema, the schema name is not provided.) User defined schema names should be approved by a central authority, if the classes defined in the schema are of interest to a wide audience. It is recommended that each class name be connotative and readily understandable. For example, if defining a class to handle towers from the Canadian National Topographic Database, the name of the class should be Tower and not a numeric code.

3 tagA unique tag for each type may be required by certain encoding schemes and not by others. The SAIF profile being used will indicate whether it is necessary to provide tags. A tag is an integer value which distinguishes one type from another in a transfer. References to a type in a binary encoding are through the tag value, and not through the name of the type. For types in the SAIF data model and standard schema, tag assignments may be found in Spatial Archive and Interchange Format: Encoding Schemes. When tags are required, they must be explicitly provided in the definition of each user defined class. The user may consider his or her types as of general interest, in which case a central authority should authorize the tags, ensuring that they are unique across all recognized schemas. If the user is defining project specific types, the tags may be assigned directly by the user and it is the user's responsibility to ensure that within the transfer all referenced types have unique tag values. (Tags corresponding to types in the SAIF data model or standard schema are considered as universal. Those assigned by a central authority fall into the application category. Those defined directly by the user are referred to as private.)

4 subclassingIn the SAIF standard schema only certain classes may be used as the superclass of a new subclass defined by the user. These cases are clearly identified in Chapter 3. Any classes defined in other schemas may be used as superclasses, unless stated otherwise.

5 attributesAttributes characterizing objects in the class are listed. The fact that attributes in the class may themselves have attributes is the basis of the object containment hierarchies reviewed earlier. With each attribute is an indication of whether provision of a data value is considered as optional or mandatory. If an attribute is considered as mandatory, a (non-nil) value must be specified in the encoding for each object belonging to the class. A domain is also provided for each attribute. The domain may be a type of primitive, a class or an enumeration, or a multiset (e.g., a list or set) of one of these. From zero to n attributes may be specified. In addition to those attributes defined in the class definition, attributes may be inherited from the superclass. The order of the attributes in the class definition is up to the user; however, once the class is defined, the order is fixed in terms of the binary encoding of objects belonging to the class. (Inherited attributes precede explicitly given attributes. Of the inherited attributes those from the first or left most parent come before those from the second parent, etc.)

6 class attributesAny class attributes, including their respective domains, are stated next. Where every object in a class has the same value for an attribute, and that value is considered an inherent part of the class definition, then that attribute should be considered a class attribute, distinct from a typical (object) attribute as described above. Alternatively, a class attribute may simply refer to the class as a whole and not specifically to instances of the class; this would be the case with class attributes expressing the cardinality of a relationship. Zero to n class attributes may be defined explicitly in the class definition or inherited from the superclass. The domain for a class attribute is always a type of primitive or enumeration. Values for class attributes may be specified either as a class attribute default or a class attribute value, as described below. As an integral part of a class definition, values for class attributes are not specified in the encoding of objects in a transfer.

7 defaultsDefault values applicable to the (object) attributes may be provided. If an attribute is defined as optional and a default is given in the class definition, leaving it unspecified in the transfer implies to the receiver of the data that the default value applies. By providing a default, an unspecified value will never be interpreted as nil (i.e., null); consequently, if it is desired that nil be considered a legitimate value for the attribute, do not provide a default. That is, with an attribute as optional and no default given, the receiver will interpret an unspecified value as nil. If an attribute is mandatory, a value must be specified and a default should not be provided. A default supplied in a superclass may be overridden by a default provided in a subclass.

8 restrictedDomain restrictions may apply to the (object) attributes. It may be of interest to limit the domain of an attribute further than the domain statement provided with the attribute. The restriction may involve primitive values. For example, pH may be defined as an attribute with the domain Real32; a restricted clause may specify that the values for pH are limited to the range between 0.0 and 14.0. Alternatively, a restriction may be based on more complex domains. An object's geometry may be restricted to come from either Point or Polygon. The restricted clause in SAIF follows a formal syntax which allows it to be parsed by computer programs, designed to aid quality and consistency checking for example. The syntax is described in detail in Chapter 4. Information provided in a restricted clause in a superclass may be refined or narrowed in a restricted clause in a subclass, but it cannot be contradicted. If the geometry in a superclass is restricted to come from Point or Polygon, in a subclass it may be further restricted to come from Polygon.

9 constraintsConstraints related to the (object) attributes may be supplied. A user may wish to provide a series of restrictions which are too complicated or inappropriate for expression in a restricted clause. It may involve a series of if-then-else statements or comparisons with other objects. It may involve limitations associated with data capture; e.g., only landslides longer than 200 metres are included in the data. For cases such as these, a constraints clause may be specified. The constraints clause is much more flexible than a restricted clause, but it is expressed as natural language text, not in a formal syntax. Like the restricted clause, information in a constraints clause in a superclass should be honoured within subclasses.

10 class attribute defaultsDefault values may apply to one or more of the class attributes. A default value may be overridden in a subclass. A default value for a class attribute is referred to as a class attribute default. A class attribute default always assigns to the class attribute a single value from a primitive type or a description from an enumeration.

11 class attribute valuesA value for a class attribute which is not a default, is simply referred to as a class attribute value. Values for the class attributes must be given as class attribute values, if they have not already been addressed as class attribute defaults. Typically, a class attribute value is specified as a single value from a primitive type or a description from an enumeration. In the case of the definition of an abstract superclass, the value may be defined, as well, as a set of values, or a range of primitives, or simply as a primitive type. In any of these cases, any subclass which may be instantiated directly must have for each class attribute a single value from this range or set, defined in its class definition or inherited from a superclass.

12 commentsComments may provide a common language definition of the class, the attributes, or other pertinent information. The comments may be short or long, and may include diagrams.


Links to the SAIF 3.1 Specification document and the complete SAIF class list