Title: PART%20II%20
1PART II The IDL And the Mapping to Java
- or
- A language which is not a programming language
but used to develop programs.
2The OMG IDL - Overview
- The syntax of the IDL is largely drawn from C
(but you don't need to know C to learn the IDL)
. - There are no programming statements, the only
purpose is to define interface signatures.
3The OMG IDL Overview.
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces and Modules
- and more ...
4IDL Lexical Analysis
- The standard C preprocessing macros (include,
define, ifdef, pragma) are available in IDL. - Keywords are in lowercase.
- Comments are in C/Java style
- //, / ... /
5IDL Modules and Interfaces
- To avoid name conflicts a module is used as a
naming scope. - Modules can contain any well formed IDL,
including nested modules. - An interface also opens a new naming scope and
can contain constants, data type declarations,
attributes, and operations.
6IDL Inheritance.
- IDL supports inheritance
- module InheritanceExample
- interface Fred
- string sayHi()
-
- interface Kurt Fred
- string sayGoodBye()
-
-
Also allowed Multiple Inheritance
7IDL Types and Constants
- The following basic types are available in IDL
- short, unsigned short, long, unsigned long, long
long, unsigned long long, float, double, long
double, fixed, char, wchar, boolean, string,
wstring, octet, enum, any. - Excercise How are all this types mapped into
Java? C?
8IDL Types and Constants- Integer types
- unsigned short
- Signed unsigned 16-bit 2's complement integer
- unsigned long
- Signed unsigned 32-bit 2's complement integer
- unsigned long long
- Signed unsigned 64-bit 2's complement integer
9IDL Types and Constants- Floating point types
- float
- 16-bit IEEE floating point number
- double
- 32-bit IEEE floating point number
- long double
- 64-bit IEEE floating point number
10IDL Types and Constants- Fixed point type
- fixed
- fixed-point decimal number of up to 31 digits.
- Fixed-point types are template types and need to
be introduced via typedef - typedef fixedlt5,2gt priceTag
- declares a fixed point type priceTag with 3
digits before and two digits behind the point,
e.g. 123.45
11IDL Types and Constants- characters
- char
- ISO Latin-1 character
- wchar
- character from other character sets to support
internationalisation. The size is implementation
dependent.
12IDL Types and Constants- strings
- string
- Variable-length string of characters whose length
is available at run time. - wstring
- Variable-length string of wchar characters.
- Strings may be bounded or unbounded, e.g. typedef
stringlt8gt eightLetters for a bounded string of 8
characters.
13IDL Types and Constants- miscellaneous
- boolean
- TRUE or FALSE
- octet
- 8-bit uninterpreted type
- enum
- Enumerated type with named integer values.
14IDL Types and Constants- miscellaneous
- any
- Can represent a value from any possible IDL type,
basic or constructed, object or nonobject. any
has an application interface describing how
values are inserted, extracted, and how the type
can be discovered.
15IDL other constructs
- Arrays (similar to Java, C, ...)
- Sequences (a more flexible version of arrays)
- Exceptions, Constants, Structs Unions.
16IDL Operations Attributes
- As seen in the example operations are similar
to C function prototypes - They contain a name, return type, and the
parameter list. - An Attribute is logically equivalent to a pair of
accessor/modifier operations. - No "private" part!
17IDL - Operations
- CORBA specific extensions
- one-way operations
- in, out and inout parameters
- and others
18The IDL to Java mapping
- or
- How to translate an IDL to a language where you
can really write programs.
http//www.omg.org/technology/documents/idl2x_spec
_catalog.htm
19Mapping IDL to Java
- The IDL compiler (e.g. idlj) translates an IDL to
a set of Java classes. - That means that each IDL construct is mapped to a
Java construct.
20Mapping IDL to Java
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces
- Modules
- IDL Attributes are mapped to a pair of accessor
and modifier methods in Java. - Note IDL Attributes are not mapped to private
attributes.
21Mapping IDL to Java
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces
- Modules
- IDL operations are mapped to Java methods as seen
in the HelloWorld example.
22Mapping IDL to Java
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces
- Modules
- Interfaces are mapped to Java interfaces/classes
as seen in the example. - Note One interface generates more then one Java
class/interface (Helper classes, )
23Mapping IDL to Java
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces
- Modules
- Modules are mapped to Java package names.
- Each module generates a directory in which other
modules ore classes/interfaces can be found.
24Mapping IDL to Java
- IDL supports the following constructs
- Data type declarations
- Attributes
- Operations
- Interfaces
- Modules
- Basic data types are mapped as good as possible
to matching basic data types or classes of Java. - More details on next slides
25IDL Types and Constants
- This is the complete list of the basic types
available in IDL - short, unsigned short, long, unsigned long, long
long, unsigned long long, float, double, long
double, fixed, char, wchar, boolean, string,
wstring, octet, enum, any. - The blue ones do also exist in Java. What about
the others?
26IDL Java mapping- Signed integer types
- short (16 bit)
- Mapped to Java short.
- long (32 bit)
- Mapped to Java int
- long long (64 bit)
- Mapped to Java long
- Caveat!
- The CORBA type long and the Java type long are
different!
27IDL Java Mapping- Unsigned integer types
- There is an obvious type mismatch here.
- However, the mapping is defined from unsigned
CORBA types to signed Java types.
- unsigned short (16 bit)
- Mapped to Java short.
- unsigned long (32 bit)
- Mapped to Java int
- unsigned long long (64 bit)
- Mapped to Java long
Is this a problem? Why? Why not?
28IDL Types and Constants- Floating point types
- float
- 16-bit IEEE floating point number
- mapped to the Java type float
- double
- 32-bit IEEE floating point number
- mapped to the Java type double
- long double
- 64-bit IEEE floating point number
- so far not mapped!
29IDL to Java mapping- Fixed point type
- fixed
- fixed-point deximal number of up to 31 digits,
e.g. - typedef fixedlt5,2gt priceTag
- The IDL type fixed is mapped to the Java class
java.math.BigDecimal. - Range checking is performed at run time.
- Exceptions are raised if values are outside of
the range.
30IDL to Java mapping- characters
- char, wchar
- are both mapped to the Java type char.
- Note IDL char is 8-bit, IDL wchar is 16-bit, the
Java char is 16-bit. - Also The IDL wchar can hold characters which are
not part of Javas native Unicode set (possible
problems with non-European character sets
possible C/Java incompatibilities).
31IDL Types and Constants- strings
- string
- Variable-length string of characters whose length
is available at run time. - wstring
- Variable-length string of wchar characters.
- Strings may be bounded or unbounded, e.g.
typedef stringlt8gt eightLetters for a bounded
string of 8 characters.
- These are mapped to java.lang.String with
possible exceptions raised for bounded strings.
32IDL Types and Constants- miscellaneous
- boolean (TRUE or FALSE)
- mapped to the Java type boolean.
- octet (8-bit uninterpreted type)
- mapped to the Java type byte.
- enum (enumerated type with named integer values.)
- mapped to a final Java class emulating the
required properties. (Maybe different in future
because of Java 1.5 supporting enum type)
33IDL mapping of any
- any (Can represent a value from any possible IDL
type, basic or constructed, object or nonobject.
any has an application interface describing how
values are inserted, extracted, and how the type
can be discovered.) - mapped to org.omg.CORBA.any
34Summary
- Overview of the IDL (Examples)
- Overview on how the IDL is mapped to Java
(Examples)