You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2012/06/20 11:31:46 UTC

[jira] [Created] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Konrad Windszus created SLING-2513:
--------------------------------------

             Summary: ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
                 Key: SLING-2513
                 URL: https://issues.apache.org/jira/browse/SLING-2513
             Project: Sling
          Issue Type: Improvement
          Components: JCR
    Affects Versions: JCR Resource 2.0.10
            Reporter: Konrad Windszus


Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.

I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13400452#comment-13400452 ] 

Carsten Ziegeler commented on SLING-2513:
-----------------------------------------

The problem I see is that you "usually" know the type and it "usually" doesn't change. However, it can happen that numbers are stored as strings for example. And in this case you'll run into nasty cast exceptions at runtime at some point of time. And they even can occur out of the sudden while everything was working well for a long time.
One way to solve this would be to say if the type is a List we always return a list of strings, however again this is only useful for some cases
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Konrad Windszus (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397504#comment-13397504 ] 

Konrad Windszus commented on SLING-2513:
----------------------------------------

This would only be possible with T ValueMap#get(String name, T default Value), since from T you can also derive the class of the individual items in the list. Unfortunately this is not possible for T ValueMap#get(String name, Class<T>), because the class does not carry information about the individual item.
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Georg Henzler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397385#comment-13397385 ] 

Georg Henzler commented on SLING-2513:
--------------------------------------

This is useful, because most APIs these days work with the collection framework. So if you're not just rendering the multivalue property in the response but you have to use it elsewhere, it would be just handy to have the ValueMap support java.util.List.
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Georg Henzler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397475#comment-13397475 ] 

Georg Henzler commented on SLING-2513:
--------------------------------------

We're talking about org.apache.sling.api.resource.ValueMap#get(String, Class)

It would be good if
   List list = values.get(propName, List.class);
was supported, at the moment only 
   String[] = values.get(propName,String[].class);
is supported.


                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Justin Edelson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397461#comment-13397461 ] 

Justin Edelson commented on SLING-2513:
---------------------------------------

@Konrad/@Georg - Could you provide an example of what you think this should look like?
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13400452#comment-13400452 ] 

Carsten Ziegeler edited comment on SLING-2513 at 6/25/12 1:10 PM:
------------------------------------------------------------------

The problem I see is that you "usually" know the type and it "usually" doesn't change. However, it can happen that numbers are stored as strings for example. And in this case you'll run into nasty cast exceptions at runtime at some point of time. And they even can occur out of the sudden while everything was working well for a long time.
One way to solve this would be to specify if the type is a List we always return a list of strings, however again this is only useful for some cases
                
      was (Author: cziegeler):
    The problem I see is that you "usually" know the type and it "usually" doesn't change. However, it can happen that numbers are stored as strings for example. And in this case you'll run into nasty cast exceptions at runtime at some point of time. And they even can occur out of the sudden while everything was working well for a long time.
One way to solve this would be to say if the type is a List we always return a list of strings, however again this is only useful for some cases
                  
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13399993#comment-13399993 ] 

Carsten Ziegeler commented on SLING-2513:
-----------------------------------------

I agree that would be nice, but as
List<String> list = values.get(propName, List<String>.class); 
doesn't work and
List list = values.get(propName, List.class); 
can easily lead to problems unless the client code checks the type of each element in the list which imho defeats the purpose.
I think there isn't much we can do about it
Adding the support for T ValueMap#get(String name, T default Value) would be possible, but does not help in all use cases

And it's easy to use the Arrays class to create a list out of the array
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Justin Edelson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397499#comment-13397499 ] 

Justin Edelson commented on SLING-2513:
---------------------------------------

But is it actually helpful to have an untyped List like this? You'd really want
List<String> list = values.get(propName, List<String>.class);

but AFAIK, this isn't possible due to erasure.
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Georg Henzler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397475#comment-13397475 ] 

Georg Henzler edited comment on SLING-2513 at 6/20/12 12:57 PM:
----------------------------------------------------------------

We're talking about org.apache.sling.api.resource.ValueMap#get(String, Class)

It would be good if
   List list = values.get(propName, List.class);
was supported, at the moment only 
   String[] arr = values.get(propName,String[].class);
is supported.


                
      was (Author: henzlerg):
    We're talking about org.apache.sling.api.resource.ValueMap#get(String, Class)

It would be good if
   List list = values.get(propName, List.class);
was supported, at the moment only 
   String[] = values.get(propName,String[].class);
is supported.


                  
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Georg Henzler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13400171#comment-13400171 ] 

Georg Henzler commented on SLING-2513:
--------------------------------------

Although java isn't expressive enough to handle our problem nicely, I still think it would be useful to be able to use lists...
            T ValueMap#get(String name, T default Value)
is easy to add and 
            @SuppressWarnings("unchecked")
            List<String> list = (List<String>) values.get(propName, List.class);
isn't exactly nice but wouldn't normally cause problems as the developer knows what type is in the JCR (and the type doesn't usually change). 


                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2513) ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403093#comment-13403093 ] 

Felix Meschberger commented on SLING-2513:
------------------------------------------

I don't think we should do this.

First we have the typing problem.
Second a list returned may well be immutable; so adding to or removing from the list returned may fail
Third you can still do Arrays.asList(values.get("name", String[].class));
                
> ValueMap#get(java.lang.String name, T defaultValue) should support java.util.List for multivalue properties
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-2513
>                 URL: https://issues.apache.org/jira/browse/SLING-2513
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.10
>            Reporter: Konrad Windszus
>
> Instead of just supporting arrays, the ValueMap used for JCR access should support java.util.List as well.
> I know that this is not supported by the JCR API, but it would be very useful, if that list would be extended afterwards.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira