Section 4.3 CSN for the restricted clause in a class definition


A restricted clause consists of one or more statements. Each statement has three phrases: (i) the attribute phrase, including the attribute's name and possibly its path (as explained below), (ii) a colon, and (iii) a domain phrase, defined by types or values.

The attribute phrase, containing the attribute name, can take several different forms. 1 the simple case for specifying an attribute The attribute may be referenced simply by providing its name, e.g., attribute1. 2 using dot notation to specify an attribute's path The name of an attribute may include its path, using dot notation, as in attribute1.attributeX. This implies that attribute1 comes from a domain which contains attributeX, and that the restriction applies to that particular attribute. A path statement includes an attribute name for each level of the containment hierarchy until the particular attribute of interest is reached. 3 using brace notation to reference objects inside a multiset An attribute may have a multiset in its domain statement, e.g., the domain of attributeA may be defined as List(DomainA). Assume that a restriction is intended to apply to any members of the list. In order to specify a restriction on that attribute, it is required to be able to reference objects within the list. This is accomplished by the following: attributeA{}. The opening and closing braces signify that the objects within the multiset are being referenced. This notation applies to any kind of multiset. Assume now that DomainA includes attributeX and that it is desired to place a restriction on attributeX. The first part of the statement would be attributeA{}.attributeX. Assume next that DomainA also includes attributeY which comes from Set(DomainY). The members of this set may be referenced with attributeA{}.attributeY{}. 4 using wildcard notation when the path is uncertain or very long We may wish to place a restriction on a lower level attribute when the path to that attribute is not known. For example, it may be desired to place a restriction on the type of coordinate used to describe geometric locations, regardless of which subclass of GeometricObject is actually used. A restricted phrase would reference the type of coordinate used by the geometry, with the actual geometry unknown, by the following phrase: geometry*Coordinate . The name of the high level attribute is followed by an asterisk and then the name of the domain of the lower level attribute. If we wished to place a restriction specifically on t (the time coordinate) as used in CoordXYT or any of its subclasses, we would reference t by: geometry*CoordXYT.t . Here we have the name of the high level attribute, an asterisk, the name of the domain of the lower level attribute, a dot, and the name of the specific attribute referenced in that domain. Even if the exact attribute path is known, it may be so long that the wildcard syntax is more straightforward and easier to understand.

The different kinds of notation described above may be mixed as required in order to specify a given attribute. Regardless of how simple or complicated the reference to the attribute, it is always followed by a colon (the set to or assignment character), and then by a domain phrase. The domain phrase may take several different forms. 1 the domain as a primitive value or enumerate The right side of the restricted statement may be a single primitive value, such as 2.5 (a numeric value) or passed (a string value) or false (a boolean value). It may also be a single description from an enumeration. If an enumeration had been defined for primary color, the domain phrase may read blue for example. 2 the domain as a set of primitive values or a set of enumerates This is similar to the above case but more than one value is given. The attribute takes a value from the discrete set of options provided. Adjacent values are separated by vertical lines, ( | ), indicating an or construct. An attribute with an integer domain may be further restricted to be either 1 or 2 or 4; the domain phrase in the restricted statement becomes: 1 | 2 | 4. Character string values may be provided similarly: Carr | Friesen | Kucera | Sondheim. With the primary color enumeration, the options may be restricted to green or blue: green | blue, without double quotes around each description. 3 the domain as a range of primitives The value for pH may be restricted to the range between 0.0 and 14.0, by stating the lower value, two adjacent dots, and then the upper value: 0.0 .. 14.0. In order to limit a name to the first half of the alphabet (names beginning with A through M), we could define the restricted domain as A .. Mzzz. 4 the domain as a type The domain for an attribute inherited from a superclass may be further restricted as to the type of domain. There are three different situations under which a domain may be restricted to a type. (i) In the first case, a particular type of primitive is specified in a restricted statement in the subclass. For example, in the superclass the domain for an attribute may be defined as Integer. In the subclass definition we may further specify that it is Integer32. (ii) In the second case, a domain previously specified as a multiset of objects of some type, is restricted further to be a set or list or other specific kind of multiset. To accomplish this the domain phrase may be given as IsoList, for example. (iii) In the third case an attribute may be restricted to come from a subclass of the original domain. This is essentially the same as the first case, but here we are talking about classes as opposed to primitive types. If the class appearing in the domain phrase is from an external schema, the name of the class must be followed by two colons and the schema name. The relationships associated with a type of geographic object may be limited in a given set of data to topologic ones only. That is, the class Topology can be considered a more restricted form of Relationship, and the restricted domain phrase would be stated as Topology. 5 the domain as a class, without any of its subclasses We may want to specify that an object must be a direct instance of a class; that is, it does not come from any of the subclasses which the class may have. The class Topology has subclasses. If the relationships are intended to come from Topology directly (and not from TopologyExtended, etc.), then a carat precedes the name of the domain, i.e., ^Topology. This notation cannot be used of course with an abstract superclass; similarly if a class has no subclasses, the carat should not be given. Otherwise, wherever a class appears as part of a restricted domain, it is also legal to use the carat notation. 6 the domain as a set of classes Different subclasses of a superclass may be given in a restricted domain. This is logical when an attribute has been inherited and it is desired to restrict its domain further. Thus the geometry of a type of geographic object may be restricted to be from the class Point or Polygon with the following phrase: Point | Polygon. If we wanted to exclude subclasses of both classes, we can write: ^Point | ^Polygon. 7 excluding particular values or subclasses from a domain Occassionally it may be of interest to exclude a value or subclass from consideration as part of the domain. For example, for some we can exclude the number 5 from a integer domain by using the character ~ as follows: ~5. Similarly, a string value may be excluded as a possible value with the domain phrase: ~Fraser Basin. A subclass can be excluded in the same way: ~Real80 or ~GeometricAggregate. However, unless the set of possible types is very long, it is considered better form to state what options are available, as opposed to what options are not allowed. 8 using nil and notNil in a restricted domain phrase For an inherited optional attribute, it may be desired to state that it will never be specified or that it must always be specified. These two cases can be handled by stating the attribute in a restricted statement and defining its domain as nil or notNil, respectively.

Some examples of restricted statements in a restricted clause may be useful to examine. Spaces may be placed between parts of a statement to improve readability, as has been done here.

restricted: attribute0: descriptionFromAnEnumeration

// attribute0 takes a specific value from an enumeration.

attribute1: RestrictedDomainForAttribute1::Schema1 attribute1.attributeA: string value1 | string value2 | string value3

// attribute1, inherited from a superclass, is restricted to a particular domain from an // external schema. On the following line attributeA, which is part of attribute1, is // restricted to one of three string values.

attribute2.attributeB.attributeX: ^SpecificDomainForX attribute2.attributeB.attributeX: notNil

// Both of the above statements indicate that attributeX is included in attributeB, which // in turn is contained in attribute2. The first statement says that attributeX must come // directly from a specific domain and not one of its subclasses. The second statement // specifies that a value for attributeX must always be given.

attribute3: List attribute3{}: lowerNumericValue .. upperNumericValue

// The domain for attribute3 was stated in a superclass as a multiset (i.e. a list) of numbers. // The firstline above specifies that the aggregate consists of a list. The second line indicates // that the the numbers in the list must come from a range, defined by a lower bound and an // upper bound.

attribute4: nil

// The assignment of attribute4 to nil, as shown above, indicates that the attribute is never // specified.

attribute5.attributeC*ClassM: Subclass1ofClassM | Subclass2ofClassM

// In the above statement, attributeC is contained by attribute5. It is known that at some // lower level in the containment hierarchy, there exists an attribute whose domain is specified // as ClassM. The restricted statement asserts that the attribute may come specifically from one // of two subclass of ClassM.

Other examples, dealing with real data, are provided in Chapter 2 and later in this chapter.


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