Project

Profile

Help

Bug #3969

closed

XdmMap - consistency of get(), containsKey(), put(), remove()

Added by Michael Kay over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Category:
s9api API
Sprint/Milestone:
-
Start date:
2018-10-12
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

Description

On XdmMap, the get() method accepts the key as an Object and attempts to convert this to XdmAtomicValue.

The containsKey() method is defined to accept Object but simply casts it to XdmAtomicValue.

The put() and remove() methods require the key to be supplied as an XdmAtomicValue.

The same inconsistent pattern is followed on .NET.

Actions #1

Updated by Michael Kay over 5 years ago

  • Category set to s9api API
  • Priority changed from Low to Normal

Because this was in the s9api API in 9.8, I think we have to live with the consequences.

I don't want to change put() and remove() to accept Object. I don't think we can restrict get(), having let the cat out of the bag. For containsKey() we have a choice. Since the method will currently throw an exception if anything other than an XdmAtomicValue is supplied, I've decided to put that in the signature of the method.

Actions #2

Updated by Michael Kay over 5 years ago

On reflection, for XdmMap.get(), I think I'm going to replace the current method get(Object) with a set of overloaded methods, get(XdmAtomicValue), get(String), get(long), get(double). This covers all the cases that are likely to be actually used.

Actions #3

Updated by Michael Kay over 5 years ago

  • Status changed from New to In Progress
  • Assignee changed from Michael Kay to O'Neil Delpratt
  • Applies to branch 9.9 added
  • Fix Committed on Branch 9.9 added

Note that the origins of this problem probably lie in the fact that XdmMap once implemented java.util.Map, which shows similar inconsistencies: get() and containsKey() and remove() accept Object, while put() only accepts the declared key type of the map.

Bug #3824 changed this so that XdmMap no longer implements Map, but we retained the inconsistencies.

I have changed XdmMap for Java (9.9) as indicated: put(), remove(), and containsKey() all expect XdmAtomicValue, while get() has overloads for XdmAtomicValue, String, long, and double.

Leaving open for the corresponding changes to be made on .NET

Actions #4

Updated by O'Neil Delpratt over 5 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Bug fix applied on Saxon 9.9 .NET

Actions #5

Updated by O'Neil Delpratt about 5 years ago

  • Fixed in Maintenance Release 9.9.1.1 added

Bug fix applied to the Saxon 9.9.1.1 maintenance release.

Actions #6

Updated by O'Neil Delpratt about 5 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF