users@jsr311.java.net

Re: MediaType.isComaptible

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 13 Aug 2008 08:39:57 -0400

On Aug 13, 2008, at 2:26 AM, Reto Bachmann-Gmür wrote:

> Marc Hadley wrote:
>> On Aug 12, 2008, at 5:15 PM, Reto Bachmann-Gmür wrote:
>>> According to the API MediaType.isComaptible returns "true if other
>>> is a subtype of this media type, false otherwise".
>> That could probably do with a rewording. Something like "returns
>> true if this is compatible with other, false otherwise".
> Without definining "compatible" this doesn't make things more clear.
> > [...]
>>> Assert.assertTrue(MediaType.WILDCARD_TYPE.isCompatible(type1));
> We both agree */* is compatible with image/jpeg
>> [...]
>>>
>>> Assert.assertFalse(type1.isCompatible(MediaType.WILDCARD_TYPE));
>>>
>> image/jpeg is compatible with */* so I think the assertion is wrong
>> given the clarified javadoc suggested above.
>
> I don't think that a symmetric compatibility function is of much
> use, so I would stuck with the current asymmetric definition
> clarifying the wording with: "true if other is equals to or a
> subtype of this media type, false otherwise".
>
> In other words: A.isCompatible(B) is true if and only of the
> extension of A is a superset of the extension of B and not, as with
> your proposal if any of the extensions is a subset of the other.
>
The method is currently commutative so both "*/*".isCompatible("image/
jpeg") and "image/jpeg".isCompatible("*/*") return true.

I'll have to think about the implications of making it asymmetric. Can
you say more about why you think the current commutative behavior
isn't of much use ?

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.