User`s manual
5 Calling Java from MATLAB
5-80
Description of Function pb_remove
1. Look For the Key in the Phone Book
Arguments passed to pb_remove are the Properties object pb_htable and the
name key for the entry to remove. The pb_remove function calls containsKey on
pb_htable with the name key, on which support function pb_keyfilter is
called to change spaces to underscores. If name is not in the phone book,
disp
displays a message and the function returns.
function pb_remove(pb_htable,name)
if ~pb_htable.containsKey(pb_keyfilter(name))
disp(sprintf('The name %s is not in the phone book',name))
return
end;
2. Ask for Confirmation and If Given, Remove the Key
If the key is in the hash table, pb_remove asks for user confirmation. If the user
confirms the removal by entering
y, pb_remove calls remove on pb_htable with
the (filtered)
name key, and displays a message that the entry has been
removed. If the user enters
n, the removal is not performed and disp displays
a message that the removal has not been performed.
r = input(sprintf('Remove entry %s (y/n)? ',name), 's');
if r == 'y'
pb_htable.remove(pb_keyfilter(name));
disp(sprintf('%s has been removed from the phone book',name))
else
disp(sprintf('%s has not been removed',name))
end;
Description of Function pb_change
1. Find the Entry to Change, and Confirm
Arguments passed to pb_change are the Properties object pb_htable and the
name key for the requested entry. The pb_change function calls get on
pb_htable with the name key, on which pb_keyfilter is called to change
spaces to underscores. The
get method returns the entry (or null, if the entry
is not found) to variable
entry. pb_change calls isempty to determine whether
the entry is empty. If the entry is empty,
pb_change displays a message that