next up previous contents index
Next: Constraints Up: ClassesComponents, and Previous: Component declarations

Attribute declarations

An attribute declaration in a class, which takes the following form, declares one or more attributes of the class:

   attribute Type AttributeDeclarator, ..., AttributeDeclarator;
where the Type must be one of the following: int, float, boolean, String, Color, and Fontgif. An attribute declarator declares one attribute variable or an array of attribute variables of the Type. An attribute declarator for one single attribute variable has one of the following forms:
       Identifier
       Identifier in Domain
       Identifier R expression
where Domain is an interval or a list of values , and R is an arithmetic relation symbol. The declarator Identifier in Domain is a domain constraint and Identifier R expression is an arithmetic constraint (see the Constraints Section). The declaration of component arrays will be described in the Arrays section.      

The following shows three examples:

       attribute int width == rect.width;
       attribute Color color in {red,black,white};
       attribute int x in 0..9;
The first one declares an attribute, named width, and constrains it to be the same as rect.width where rect must be a component declared in the same class. The other two examples declare two attribute variables and specify their domains.



Neng-Fa ZHOU
Sat Apr 18 16:14:29 JST 1998