Implementations

2.3 Agent and Component Implementations Class declarations define new reference types and describe how they implement agents and components. Every class must implement either an Agent or Component or extend a class that implements an Agent or Component. A class that implements an agent is different from a class that implements a component. A class that implements a component describes its behavior, either by composing member components using connectors or by logic implemented in its methods, whereas a class that implements an agent makes use of connectors and channels to describe the behavior of a composite system where the agent composes components using connectors and communicates with other agents using channels.

2.3.1 Class Declaration A variable whose declared type is a Agent or Component type may have as its value as reference to any instance of a class which implements the specified Agent or Component.

Class Declaration: ClassModifiers (opt) Class Identifier implements InterfaceName { //Class Body }

The Identifier in the above declaration is the name of the class. It is a compile time error if a class has the simple name as any of its enclosing classes or interfaces. Each class must mandatorily implement an Agent or Component whose name must be specified in the class declaration. 2.3.1.1 Class Modifiers A class declaration may include class modifiers. Class modifiers may be one of the following. Public Protected Private Abstract Final Strictfp If two or more class modifiers appear in a class declaration, then it is customary, though not required, that they appear in the order consistent with that shown above. It is a compile time error for a modifier to appear more than once in a class declaration.

An abstract class is a class that is incomplete. Only abstract classes may have abstract methods, methods that are declared but not yet implemented. If a class that is not abstract contains abstract methods, then a compile-time error occurs. A class C has abstract methods if any one of the following is true. C explicitly contains a declaration of an abstract method Any of C’s super classes declares an abstract method that has not been implemented in C or any of its super classes A class that inherits an abstract class must be declared as abstract whereas a class that implements an abstract class may not be declared abstract. A subclass of an abstract class that is not itself abstract may be instantiated, resulting in the execution of a constructor for the abstract class and therefore, the execution of the field initializers for instance variables of that class. It is a compile time error to instantiate an abstract class or declare abstract methods in such a way that it is impossible for a class to implement them together. A class can be declared final if its definition is complete and no subclasses are desired or acquired. A compile-time error occurs if a class is declared both final and abstract or if the final class appears in an extends clause of a class inheriting behavior from another class. 2.3.1.2 Inner Classes and Nested Classes Indus does not support the provision of inner classes and nested classes as it supports reuse only through a mix of single inheritance and method reuse (see below in section on Inheritance). 2.3.1.3 Super classes and Sub classes The optional extends clause in a class declaration specifies the direct super class of the current class. A class is said to be a direct subclass of the class it extends. Final classes are not allowed to have subclasses. The subclass relationship is the transitive closure of direct subclass relationship. A class A is a subclass of class C if either of the following is true: A is the direct subclass of C There exists a class B such that A is a subclass of B and B is a subclass of C, applying this definition recursively 2.3.1.4 Super Interfaces Unlike in Java, the implements clause in a class declaration is not optional. In Indus, the implements clause in the class declaration lists the name of the agent or component that the class implements. Unless the class being declared is abstract, the declarations of all the member methods of the agent or component that the class implements must be implemented either by declaration in this class or by an existing method declaration inherited from the direct super class. A class in Indus can, at the most, implement one agent or component declaration. There is no concept of member interfaces in Indus classes unlike in Java. However, agent and component interfaces in Indus may have nested interfaces. In such cases, classes that implement interfaces that are nested within other interfaces may not be declared static. Such classes may not declare static members. Inner classes may not declare static members unless they are compile-time constant fields. 2.3.1.5 Class Members A class body may contain declarations of members of the class, i.e. fields and methods. A class body may also contain instance initializer, static intializer and declarations of constructors for the class. Classes and Interfaces can not be members of classes. The members of a class type are all of the following : Members inherited from its direct super class, except in class object which has no direct super class. Members declared in the body of the class.

Members of a class that are declared private are not inherited by subclasses of that class. Only members of a class that are declared protected or public are inherited by subclasses. Constructors, static initializers, and instance initializers are not members and therefore, are not inherited. Even though a class might not be declared public, instances of the class might be available at run time if it has a public super class.