Similar objects in Rexx are grouped into classes, forming a hierarchy. Rexx gives you a basic class hierarchy to start with. All of the classes in the hierarchy are described in detail in the Open Object Rexx: Reference. The following list shows the classes Rexx provides (there may be others in the system). The classes indented are subclasses. Classes in the list that are described later in this chapter are printed in bold:
Object Alarm Class Collection classes Array List Queue Table Set Directory Relation Bag Message Method Monitor Stem Stream String Supplier
The classes Rexx supplies provide the starting point for object-oriented programming. Some key classes that you are likely to work with are described in the following sections.
The Alarm class is used to create objects with timing and notification capability. An alarm object is able to send a message to an object at any time in the future, and until then, you can cancel the alarm.
The collection classes are used to manipulate collections of objects. A collection is an object that contains a number of items, which can be any objects. These manipulations might include counting objects, organizing them, or assigning them a supplier (for example, to indicate that a specific assortment of baked goods is supplied by the Pie-by-Night Bakery).
Rexx includes classes, for example, for arrays, lists, queues, tables, and directories. Each item stored in a Rexx collection has an associated index that you can use to retrieve the item from the collection with the AT or [] (left and right bracket) methods, and each collection defines its own acceptable index types:
A sequenced collection of objects ordered by whole-number indexes.
A sequenced collection that lets you add new items at any position in the sequence. A list generates and returns an index value for each item placed in the list. The returned index remains valid until the item is removed from the list.
A sequenced collection of items ordered as a queue. You can remove items from the head of the queue and add items at either its tail or its head. Queues index the items with whole-number indexes, in the order in which the items would be removed. The current head of the queue has index 1, the item after the head item has index 2, up to the number of items in the queue.
A collection of indexes that can be any object. For example, string objects, array objects, alarm objects, or any user-created object can be a table index. The Table class determines an index match by using the == comparison method to test for strict equality. A table contains no duplicate indexes.
A collection of character string indexes. Indexes are compared using the string == comparison method to test for strict equality.
A collection of indexes that can be any object (as with the Table class). A relation can contain duplicate indexes.
A collection where the indexes are equal to the values. Set indexes can be any object (as with the Table class) and each index is unique.
A collection where the index is equal to the value. Bag indexes can be any object (as with the Table class) and each index can appear more than once.
To manipulate message objects, you use the Message class. Methods created for this class are used, for example, to send a message, to notify the sender object when an error occurs or when message processing is complete, to return the results of that processing to the sender or to some other object, or to process the message object concurrently with the sender object.
The Monitor class provides a way to forward messages to a specified destination. Monitor methods let you initialize a monitor object, specify a destination object or use a previously specified one, and obtain the name of the current destination object.
A stem is a symbol that must start with a letter and end with a period, like "FRED." or "A.". The value of a stem is a stem object by default. A stem object is a collection of unique indexes that are character strings. Stem objects are automatically created when a Rexx stem variable or Rexx compound variable is used. In addition to the items assigned to the collection indexes, a stem object also has a default value that is used for all uninitialized indexes of the collection. You can assign a default value to a stem object and later retrieve this value.
Input and output streams let Rexx communicate with external objects, such as people, files, queues, serial interfaces, displays, and networks. In programming there are many stream actions that can be coded as methods for manipulating the various stream objects. These methods and objects are organized in the Stream class.
The methods are used to open streams for reading or writing, close streams at the end of an operation, move the line-read or line-write position within a file stream, or get information about a stream. Methods are also provided to get character strings from a stream or send them to a stream, count characters in a stream, flush buffered data to a stream, query path specifications, time stamps, size, and other information from a stream, or do any other I/O stream manipulation (see Input and Output for examples).
Strings are data values that can have any length and contain any characters. They are subject to logical operations like AND, OR, exclusive OR, and logical NOT. Strings can be concatenated, copied, reversed, joined, and split. When strings are numeric, there is the need to perform arithmetic operations on them or find their absolute value or convert them from binary to hexadecimal, and vice versa. All this and more can be accomplished using the String class of objects.
Some collections have suppliers: a bakery, for example, can supply certain breads, cookies, cakes and pies; a financial report can supply certain data, statistics, tables, and reports. The Supplier class is used to enumerate items that a collection contained when the supplier was created. For example, this class contains methods to verify if an item is available from a supplier (Does the Pie-by-Night Bakery sell chocolate cake?). Another method returns the index of the current item in a collection (What is the position of the apple pie record?). Others return the current collection item in a collection object, and the next item in the collection.