Bắt đầu với IBM Websphere smash - p 12

92 Chapter 5 Global Context zdelete Method To remove a list from the global context, we use zdelete: boolean zdelete(String location [, boolean deleteChildren ]); The zdelete method deletes the specified location, removing any values stored there (see Listing ). Listing zdelete a List ("/app/stringList"); ("/app/integerList"); Here we delete both of the lists we’ve previously created and updated. The optional deleteChildren parameter works the same as the object usage of this method. As with zput, we can delete single elements from our list by specifying the # in the location (see Listing ). Listing zdelete a List Element ("/app/stringList#0"); ("/app/integerList#1"); The first zdelete removes the first element of the. | 92 Chapter 5 Global Context zdelete Method To remove a list from the global context we use zdelete boolean zdelete String location boolean deleteChildren The zdelete method deletes the specified location removing any values stored there see Listing . Listing zdelete a List app stringList app integerList Here we delete both of the lists we ve previously created and updated. The optional deleteChildren parameter works the same as the object usage of this method. As with zput we can delete single elements from our list by specifying the key in the location see Listing . Listing zdelete a List Element app stringList 0 app integerList 1 The first zdelete removes the first element of the string list and the second zdelete removes the second element of the integer list. Sometimes code requires that a particular list be available before executing. We can test the availability of a list by using the zcontains method the same way we do for objects. zcontains Method To test if a list is in the global context we use the zcontains method boolean zcontains String location The zcontains method returns a boolean value indicating whether the particular list is available in the global context see Listing . Listing The zcontains Method for a List if app stringList do something The zcontains method can be used as a guard code that must have particular lists available. Like other list operations the zcontains method can access particular elements of a list by using the key notation see Listing . Download from Accessing the Global Context 93 Listing The zcontains Method for a List Element if app stringList 0 do something This code tests to be sure that the first element in the string list exists before executing some code. The rest of the global context methods zlist zlistAll and zdump work the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.