Home Help Center

Intializing members of a slice generated class

Hi there,

Howdy. I've a question on intializing members of a slice generated class.

How are sequences intialized. Do we need to check for null everytime before we add something to it or is there any other way of initializing these members.

Thanks,
Venkat

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Which language mapping are you referring to? Java?

    Java initializes reference members to null by default, and the Slice mapping for Java doesn't alter that behavior. The Ice run time interprets a null sequence or dictionary member as an empty container, so there is no need to initialize the member before marshaling if you plan to leave it empty.

    Take care,
    - Mark
  • Venkat SeethVenkat Seeth Member ✭✭
    Hi Mark,

    Thanks for the reply. Yes, Java is the programming language.

    I've mapped the sequence as:

    ["java:type:java.util.ArrayList"] sequence<Foo> FooList;

    If I'm adding objetcs into FooList, I''ll need to check for NULL in the code before I add into that List. Is there any way to specify defaults or some callback to initialize these types.

    Thanks,
    Venkat
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    I'm afraid there is no way to change the initialization behavior of the generated code.

    Take care,
    - Mark
Sign In or Register to comment.