Introduction to Class Definition Syntax and Keywords
This reference formally describes the syntax and keywords used in class definitions. See the Table of Contents for a complete list of structures and keywords that apply to specific class members.
Class definitions are not formally part of ObjectScript. Rather, you can use ObjectScript within specific parts of class definitions (particularly within method definitions, where you can also use other implementation languages).
This page briefly surveys the class definition structures that are discussed in this reference.
Class Definitions
A class definition defines a class. A class definition consists of class members (such as properties and methods) and other items, called keywords, each with associated values, that specify details of the class behavior. In InterSystems IRIS, a class can also include items not usually defined in classes, including triggers, queries, and indexes.
The language used to define the various class members (not including any ObjectScript, Python, SQL or other code used to implement the members) is sometimes referred to as the Class Definition Language (CDL).
See Class Definition Syntax and Keywords in this reference.
See also:
Foreign Key Definitions
A foreign key defines a referential integrity constraint. When a table containing a foreign key constraint is modified, the foreign key constraints are checked. You can add foreign key definitions to persistent classes. They are not meaningful in other kinds of classes. You can also enforce reference integrity by defining relationship properties that connect the classes.
See Foreign Key Syntax and Keywords in this reference.
See also:
-
Defining a Foreign Key in Relationships Between Tables
-
Adding SQL Triggers and Foreign Keys to a Class in Using Studio
Index Definitions
An index is a structure maintained by a persistent class that is intended to be used to optimize queries and other functions. These indexes are automatically maintained whenever INSERT, UPDATE, or DELETE SQL-based operations are carried out against the database; likewise for object-based actions. The SQL Query Processor makes use of available indexes when preparing and executing SQL queries. You can add index definitions to persistent classes. They are not meaningful in other kinds of classes.
See Index Syntax and Keywords in this reference.
See also:
-
Adding Indexes to a Class in Using Studio
Method Definitions
InterSystems IRIS supports two types of methods: instance methods and class methods. An instance method is invoked from a specific instance of a class and performs some action related to that instance; this type of method is useful only in object classes. A class method is a method that can be invoked whether or not an instance of its class is in memory; this type of method is called a static method in other languages.
See Method Syntax and Keywords in this reference.
See also:
Parameter Definitions
A parameter definition defines a constant value available to all objects of a given class. When you create a class definition (or at any point before compilation), you can set the values for its class parameters. By default, the value of each parameter is the null string, but you can specify a non-null value as part of the parameter definition. At compile-time, the value of the parameter is established for all instances of a class. With rare exceptions, this value cannot be altered at runtime.
See Parameter Syntax and Keywords in this reference.
See also:
Projection Definitions
A class projection provides a way to extend the behavior of the class compiler. The projection mechanism is used by the Java projections; hence the origin of the term projection.
A projection definition instructs the class compiler to perform specified operations when a class definition is compiled or removed. A projection defines the name of a projection class (derived from the %Projection.AbstractProjectionOpens in a new tab class) that implements methods that are called when the compilation of a class is complete and when a class definition is removed (either because it is being deleted or because the class is about to be recompiled).
See Projection Syntax and Keywords in this reference.
See also:
-
Adding Projections to a Class in Using Studio
Property Definitions
A property contains information relevant to an instance of a class. You can add property definitions to object classes. They are not meaningful in other kinds of classes.
See Property Syntax and Keywords in this reference.
See also:
Query Definitions
A class query defines an SQL query that can be used by the class and specifies a class to use as a container for the query. Often (but not necessarily), you define class queries in a persistent class, to perform queries on the stored data for that class. You can, however, define class queries in any class.
See Query Syntax and Keywords in this reference.
See also:
-
Adding Queries to a Class in Using Studio
Trigger Definitions
Triggers are code segments executed when specific events occur in InterSystems SQL. InterSystems IRIS supports triggers based on the execution of INSERT, UPDATE, and DELETE commands. The specified code will be executed either immediately before or immediately after the relevant command is executed, depending on the trigger definition. Each event can have multiple triggers as long as they are assigned an execution order. You can add trigger definitions to persistent classes. They are not meaningful in other kinds of classes.
See Trigger Syntax and Keywords in this reference.
See also:
XData Blocks
An XData block is a named unit of data defined within the class, typically for use by a method in the class. These have many possible applications.
See XData Block Syntax and Keywords in this reference.
See also:
-
Adding XData Blocks to a Class in Using Studio
Storage Definitions
The %PersistentOpens in a new tab class provides the high-level interface for storing and retrieving objects in the database. The actual work of storing and loading objects is performed by a storage class. The class is specified by a storage definition, which contains a set of keywords, values, and additional parameters used by the storage interface.
See Storage Keywords in this reference.
See also:
-
Adding Storage Definitions to a Class in Using Studio