jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r431341 - /jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java
Date Mon, 14 Aug 2006 13:30:54 GMT
Author: angela
Date: Mon Aug 14 06:30:54 2006
New Revision: 431341

URL: http://svn.apache.org/viewvc?rev=431341&view=rev
Log:
work in progress

- additional create method

Modified:
    jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java

Modified: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java?rev=431341&r1=431340&r2=431341&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java
(original)
+++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValue.java
Mon Aug 14 06:30:54 2006
@@ -38,6 +38,8 @@
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.Reader;
+import java.io.StringReader;
 import java.util.Calendar;
 import java.util.Arrays;
 
@@ -85,31 +87,43 @@
     }
 
     /**
-     * @param qValue
+     * @param values
      * @return
      */
-    public static QValue create(String qValue, int type) {
-        if (qValue == null) {
+    public static QValue[] create(String[] values) {
+        QValue[] ret = new QValue[values.length];
+        for (int i = 0; i < values.length; i++) {
+            ret[i] = new QValue(values[i]);
+        }
+        return ret;
+    }
+
+    /**
+     * @param value
+     * @return
+     */
+    public static QValue create(String value, int type) {
+        if (value == null) {
             throw new IllegalArgumentException("Cannot create QValue from null value.");
         }
         switch (type) {
             case PropertyType.BOOLEAN:
-                return new QValue(Boolean.valueOf(qValue).booleanValue());
+                return new QValue(Boolean.valueOf(value).booleanValue());
             case PropertyType.DATE:
-                return new QValue(ISO8601.parse(qValue));
+                return new QValue(ISO8601.parse(value));
             case PropertyType.DOUBLE:
-                return new QValue(Double.valueOf(qValue).doubleValue());
+                return new QValue(Double.valueOf(value).doubleValue());
             case PropertyType.LONG:
-                return new QValue(Long.valueOf(qValue).longValue());
+                return new QValue(Long.valueOf(value).longValue());
             case PropertyType.REFERENCE:
                 // DIFF JR: references are not forced to represent a UUID object
-                return new QValue(qValue, true);
+                return new QValue(value, true);
             case PropertyType.PATH:
-                return new QValue(Path.valueOf(qValue));
+                return new QValue(Path.valueOf(value));
             case PropertyType.NAME:
-                return new QValue(QName.valueOf(qValue));
+                return new QValue(QName.valueOf(value));
             case PropertyType.STRING:
-                return new QValue(qValue);
+                return new QValue(value);
             case PropertyType.BINARY:
                 throw new IllegalArgumentException("this method does not support the type
PropertyType.BINARY");
             default:
@@ -118,6 +132,18 @@
     }
 
     /**
+     * @param values
+     * @return
+     */
+    public static QValue[] create(String[] values, int type) {
+        QValue[] ret = new QValue[values.length];
+        for (int i = 0; i < values.length; i++) {
+            ret[i] = QValue.create(values[i], type);
+        }
+        return ret;
+    }
+
+    /**
      * @param value
      * @return
      */
@@ -172,7 +198,7 @@
      * @return
      * @throws IOException
      */
-    public static QValue create(InputStream value, int type) throws IOException, RepositoryException
{
+    public static QValue create(InputStream value, int type) throws IOException {
         if (value == null) {
             throw new IllegalArgumentException("Cannot create QValue from null value.");
         }
@@ -201,9 +227,9 @@
                     return create(text, type);
 
                 } catch (UnsupportedEncodingException e) {
-                    throw new RepositoryException(DEFAULT_ENCODING + " not supported on this
platform", e);
+                    throw new IllegalArgumentException(DEFAULT_ENCODING + " not supported
on this platform: " + e.getMessage());
                 } catch (IOException e) {
-                    throw new RepositoryException("conversion from stream to string failed",
e);
+                    throw new IllegalArgumentException("conversion from stream to string
failed: " + e.getMessage());
                 } finally {
                     value.close();
                 }
@@ -213,6 +239,18 @@
     }
 
     /**
+     * @param values
+     * @return
+     */
+    public static QValue[] create(InputStream[] values, int type) throws IOException {
+        QValue[] ret = new QValue[values.length];
+        for (int i = 0; i < values.length; i++) {
+            ret[i] = QValue.create(values[i], type);
+        }
+        return ret;
+    }
+
+    /**
      * @param value
      * @param temp
      * @return
@@ -252,30 +290,6 @@
     }
 
     /**
-     * @param values
-     * @return
-     */
-    public static QValue[] create(String[] values) {
-        QValue[] ret = new QValue[values.length];
-        for (int i = 0; i < values.length; i++) {
-            ret[i] = new QValue(values[i]);
-        }
-        return ret;
-    }
-
-    /**
-     * @param values
-     * @return
-     */
-    public static QValue[] create(Calendar[] values) {
-        QValue[] ret = new QValue[values.length];
-        for (int i = 0; i < values.length; i++) {
-            ret[i] = new QValue(values[i]);
-        }
-        return ret;
-    }
-
-    /**
      * @param value
      * @return
      */
@@ -291,6 +305,7 @@
         return new QValue(value);
     }
 
+    //--------------------------------------------------------------------------
     /**
      * @return
      */



Mime
View raw message