Skip to main content

Data Type Classes

Data Type Classes

Data type classes enable you to enforce sets of rules about the values of properties.

InterSystems IRIS provides data type classes which include %Library.StringOpens in a new tab, %Library.IntegerOpens in a new tab, %Library.NumericOpens in a new tab, %Library.DateOpens in a new tab, and many others. Because the names of classes of the %Library package can be abbreviated, you can abbreviate many of these; for example, %DateOpens in a new tab is an abbreviation for %Library.DateOpens in a new tab.

Each data type class has the following features:

  • It specifies values for compiler keywords. For a property, a compiler keyword can do things like the following:

    • Make the property required

    • Specify an initial value for the property

    • Control how the property is projected to SQL, ODBC, and Java clients

  • It specifies values for parameters that affect the details such as the following:

    • Maximum and minimum allowed logical value for the data type

    • Maximum and minimum number of characters the string can contain

    • Number of digits following the decimal point

    • Whether to truncate the string if it exceeds the maximum number of characters

    • Display format

    • How to escape any special XML or HTML characters

    • Enumerated lists of logical values and display values to use in any user interface

    • Pattern that the string must match (automatically uses the InterSystems IRIS pattern-matching operator)

    • Whether to respect or ignore the UTC time zone when importing or exporting to XML

  • It provides a set of methods to translate literal data among the stored (on disk), logical (in memory), and display formats.

You can add your own data type classes. For example, the following shows a custom subclass of %Library.StringOpens in a new tab:

Class MyApp.MyType Extends %Library.String
{

/// The maximum number of characters the string can contain.
Parameter MAXLEN As INTEGER = 2000;

}
FeedbackOpens in a new tab