jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1484695 - in /jackrabbit/branches/2.6: ./ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
Date Tue, 21 May 2013 08:37:03 GMT
Author: jukka
Date: Tue May 21 08:37:03 2013
New Revision: 1484695

URL: http://svn.apache.org/r1484695
Log:
2.6: Merged revision 1461646 (JCR-3550)

Modified:
    jackrabbit/branches/2.6/   (props changed)
    jackrabbit/branches/2.6/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1461646

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java?rev=1484695&r1=1484694&r2=1484695&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
Tue May 21 08:37:03 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.value;
 
+import static javax.jcr.PropertyType.UNDEFINED;
+
 import org.apache.jackrabbit.util.Base64;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.util.TransientFileFactory;
@@ -818,4 +820,29 @@ public class ValueHelper {
             return convert(value, type, factory);
         }
     }
+
+    /**
+     * Determine the {@link javax.jcr.PropertyType} of the passed values if all are of
+     * the same type.
+     *
+     * @param values array of values of the same type
+     * @return  {@link javax.jcr.PropertyType#UNDEFINED} if {@code values} is empty,
+     *          {@code values[0].getType()} otherwise.
+     * @throws javax.jcr.ValueFormatException  if not all {@code values} are of the same
type
+     */
+    public static int getType(Value[] values) throws ValueFormatException {
+        int type = UNDEFINED;
+        for (Value value : values) {
+            if (value != null) {
+                if (type == UNDEFINED) {
+                    type = value.getType();
+                } else if (value.getType() != type) {
+                    throw new ValueFormatException(
+                            "All values of a multi-valued property must be of the same type");
+                }
+            }
+        }
+        return type;
+    }
+
 }



Mime
View raw message