Technology
 

Agent and Component declarations

From Indus Communities

An Agent or Component declaration specifies a new Agent or Component.

AgentDeclaration:
	AgentModifieropt Agent ''Identifier'' 
				AgentBody

ComponentDeclaration:
	ComponentModifieropt Component ''Identifier''
				ComponentBody

The identifier in a declaration specifies the name of the Agent or Component. A compile time error occurs if an Agent or Component has the same simple name as any of its enclosing members.

An Agent or Component declaration may include the following modifiers. public abstract static strictfp

The access modifier static pertains to only member Agents and Components. A compile time error occurs if the same modifier appears more than once in an Agent or Component declaration.

Every Agent and Component is implicitly abstract and public. The effect of the strictfp modifier is to make all float or double expressions within the Agent or Component declaration be explicitly FP-strict.

Indus does not use extends clause for extension of interface behavioral specification. Instead, Agents and Components allow other Agents and Components to be members thus implying that they extend their behavioral specification. Any class that implements the declared Agent or Component is also considered to implement all the Agents and Components that the declared Agent or Component has members. However, to be members, Agents and Components need to be accessible.

Agents and Components cannot be recursive that is they cannot depend on themselves. An Agent or Component K is a supertype of I if either of the following is true:

  • K is a direct supertype of I
  • There exists an Agent or Component J such that K is a supertype of J and J is a supertype of I
  • A compile time error occurs if Agents and Components depend on themselves or are declared recursively.

The body of an Agent or Component may declare members of the Agent or Component.

AgentMemberDeclarations:
ConstantDeclaration	
		AgentDeclaration
                ComponentDeclaration
	        AbstractMethodDeclaration
	        ;
	
 ComponentMemberDeclarations:
		ConstantDeclaration
		PortDeclaration
		ComponentDeclaration
	        ;

The scope of the declaration of a member m declared in or inherited by an Agent or Component I is the entire body of I, including any nested type declarations.

The members of an Agent or Component are

  • Those members declared in the Agent or Component
  • Those members inherited from direct super types
  • Implicitly public

Every field declaration in the body of a Agent or Component is implicitly public, static and final. If the Agent or Component declares a field with a certain name, then the declaration of that field is said to hide any and all accessible declarations of fields with the same name in the Agent’s or Component’s super types. Every field in the body of an Agent or Component must have an initialization expression, which need not be a constant expression.

A compile-time error will result in the following cases:

  • Field declarations with the same name
  • Reference to fields with the same name inherited from super types
  • Where an initialization expression for an Agent or Component field contains a reference by a simple name to the same field or to another field whose declaration occurs textually later in the same Agent or Component or by reference by the simple name to the same field contained in the Agent’s or Component’s super type

If an Agent or Component declares a method, then the declaration of that method is said to override any and all methods with the same signature in the super types of the Agent or Component. A compile time error occurs if

  • If over ridden method do not share the same return type with the method overriding it
  • If the over ridden method has a throws clause that conflicts with that of any methods that over ride it
  • Two inherited methods with the same signature in an Agent or Component declaration are referred to when the methods do not have the same return types (conflicting throws clauses will not cause an error in this case)

Methods are overridden on a signature-by-signature basis. If, for example, an Agent or Component declares two methods with the same name but different signatures (different number of parameters or return types), and an Agent or Component overrides one of them, the other method is still inherited.

If two methods of an Agent or Component (whether both declared in the same Agent or Component, or both inherited by an Agent or Component, or one declared and one inherited) have the same name but different signatures, then the method name is said to be overloaded. This fact doesn’t cause any difficulty in compilation.


Next : Agent and Component implementations