Try OpenEdge Now
skip to main content
Object-oriented Programming
Getting Started with Classes, Interfaces, and Objects : Class definition files and object type names : Referencing an object type name without its package
 

Referencing an object type name without its package

In both procedure and class definition files where you refer to class or interface types, you can specify one or more USING statements that allow you to reference object types defined in packages using their unqualified class or interface names. Any and all USING statements must appear at the beginning of the source file before all other compilable statements, and you can specify each statement using this syntax:
USING {object-type-name|package.* } .
You can specify object-type-name as the fully qualified object type name for a single class or interface that you want to reference, or you can specify package as the package defined for multiple classes and interfaces that you want to reference. Note that the asterisk (*) wildcard cannot match a partial package, but only the names of class or interface types that are defined in the specified package. You can also only have one wildcard that terminates the specified package, as shown. For more information on object type names and packages, see Defining and referencing object type names.
Thus, to access a class with the type name acme.myObjs.Common.CommonObj using only its unqualified class name, you can define either of the following USING statements:
USING acme.myObjs.Common.*.
USING acme.myObjs.Common.CommonObj.
The first statement (a package USING statement) allows you to reference all classes and interfaces defined in the acme.myObjs.Common package using only their class or interface names. The second statement (a type-name USING statement) allows you to access the single specified type defined in the same acme.myObjs.Common package using only its class name (CommonObj). A type-name USING statement is useful when you want to limit class or interface name references to a specified class or interface within a package.
You can include multiple USING statements in a source file to allow unqualified name access to class and interface types defined in multiple packages. If you reference a class or interface type that is defined with the same name in multiple packages, ABL uses the first class or interface type name match that it encounters in order of the specified USING statements, starting with all type-name USING statements (type-name priority), and following with all package USING statements, until an appropriate match is found.