Java Reference
In-Depth Information
Table 6.1
IDL types and
their Java equivalents
IDL type
Java type
boolean
boolean
char
and
wchar
char
octet
byte
string
and
wstring
String
short
short
long
int
long long
long
double
double
fi xed
java.math.BigDecimal
Example
module Sales
{
interface StockItem
{
readonly attribute string code;
attribute long currentLevel;
long addStock(in long incNumber);
long removeStock(in long decNumber);
};
interface .....
{
...................;
...................;
};
........(Etc.)......
........(Etc.)......
};
(Again, notice the semi-colons after closing brackets!)
If only one interface is required, then some programmers may choose to omit the
module
level in the
.idl
fi le.
In addition to the basic types, there are six structured types that may be specifi ed
in IDL:
enum
,
struct
,
union
,
exception
,
sequence
and
array
. The fi rst
four of these are mapped to
classes
in Java, while the last two are mapped to
arrays
.
(The difference between a
sequence
and an
array
in IDL is that a sequence
does not have a fi xed size.) Since
enum
,
struct
and
union
are used only infre-
quently, they will not be given further coverage here.
IDL exceptions are of two types: system exceptions and user-defi ned exceptions.
The former inherit (indirectly) from
java.lang.RuntimeException
and are unchecked
exceptions (i.e., can be ignored, if we wish), while the latter inherit (indirectly)
from
java.lang.Exception
via
org.omg.CORBA.UserException
and are checked
exceptions (i.e., must be either caught and handled or be thrown for the runtime
Search WWH ::
Custom Search