Author: cziegeler
Date: Thu Apr 25 14:25:16 2013
New Revision: 1475795
URL: http://svn.apache.org/r1475795
Log:
SLING-2840 : JcrPropertyMap should returned correct array type for multivalue
properties
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java?rev=1475795&r1=1475794&r2=1475795&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
Thu Apr 25 14:25:16 2013
@@ -88,7 +88,23 @@ public class JcrResourceUtil {
// multi-value property: return an array of values
if (property.isMultiple()) {
Value[] values = property.getValues();
- Object[] result = new Object[values.length];
+ final Object firstValue = values.length > 0 ?
toJavaObject(values[0]) : null;
+ final Object[] result;
+ if ( firstValue instanceof Boolean ) {
+ result = new Boolean[values.length];
+ } else if ( firstValue instanceof Calendar ) {
+ result = new Calendar[values.length];
+ } else if ( firstValue instanceof Double ) {
+ result = new Double[values.length];
+ } else if ( firstValue instanceof Long ) {
+ result = new Long[values.length];
+ } else if ( firstValue instanceof BigDecimal) {
+ result = new BigDecimal[values.length];
+ } else if ( firstValue instanceof InputStream) {
+ result = new Object[values.length];
+ } else {
+ result = new String[values.length];
+ }
for (int i = 0; i < values.length; i++) {
Value value = values[i];
if (value != null) {