IDL Constructed Types   «Prev  Next»
Lesson 9 Mapping for arrays
Objective Describe and use the Java produced by the Mapping for IDL Arrays

Mapping Java IDL Arrays

Java produced by the Mapping for IDL Arrays

Java Array Mapping

IDL arrays are mapped to Java just like IDL bounded sequences. An explicit class corresponding to the array is not produced; instead, everywhere the IDL array is used, the corresponding Java array is used. The array is bounds checked during marshalling[1]. Corresponding helper and holder classes are generated.
As with bounded sequences, it is best to specify the array size with an IDL const. This way the Java code can make use of the sizing value by referring to the const's value.


Let's look at another Weather Service example, this time using arrays. Here is the IDL:
module Module4{
 const long DaysInWeek = 7;
 typedef string FullWeekForecasts[DaysInWeek];
 interface WeatherService{
   FullWeekForecasts getForecastsForWeek(in string city);

The Java operations interface generated for the WeatherService IDL interface is:
package Module4;
public interface WeatherServiceOperations{
 public java.lang.String[] getForecastsForWeek
   (java.lang.String city);

Note that the return type for the method is simply an array of String, corresponding exactly to the IDL array.

Using Arrays in Java

As with bounded sequences, the usage is simple and the Java arrays produced by the mapping are just regular Java arrays. The next lesson concludes this module.

[1]marshalling: Conversion of language-specific data types to values, which can be put onto a byte stream.