I'm not sure :) One can argue that it's up to the implementation how it
stores data.

So if I put a date into a MVM and later on read the resource and get the
value, I expect a date to be returned. So from a documentation pov, a MVM
supports all serializable types - and should ensure that the type you put
is the type you get.

Carsten


2013/9/26 Daniel Klco <[email protected]>

> When setting a java.util.Date as the value in the ModifiableValueMap, the
> Date object is serialized and saved as the value.  This seems like odd
> functionality, as java.util.Calendar is supported and the internal datatype
> is called 'date'.
>
> I understand that the reason is that internally the JCR uses
> java.util.Calendars to store and access dates, but it's just not a very
> intuitive thing to happen.  I think one (or more) of the three things
> should happen to make the functionality more intuitive:
>
>  - The JavaDocs for the ModifiableValueMap should list the supported types
> and what happens when an unsupported type is encountered.  This will mean
> that all implementations of the ModifiableValueMap will need to support the
> same types.
>
>  - The ModifiableValueMap implementations should throw a
> java.lang.IllegalArgumentException if an invalid value type is specified.
>  Of course this is going to require more error checking and definitely
> requires some additional documentation.
>
> - The ModifiableValueMap should have a method for retrieving the supported
> types based on the ResourceProvider being used.
>
> - The JcrModifiableValueMap (and other implementations) should attempt to
> coerce reasonable values.  For example: java.util.Date ->
> java.util.Calendar, byte[] -> InputStream
>
> Personally, I like a combination of all four options.  What do you think?
>
> Regards,
> Dan
>



-- 
Carsten Ziegeler
[email protected]

Reply via email to