jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r900430 - in /jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi: client/ value/
Date Mon, 18 Jan 2010 15:45:20 GMT
Author: jukka
Date: Mon Jan 18 15:45:19 2010
New Revision: 900430

URL: http://svn.apache.org/viewvc?rev=900430&view=rev
Log:
JCRRMI-26: JSR-283 support

Improved JCR 2.0 value implementations. Especially support for large binaries.

Added:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java
      - copied, changed from r896362, jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BaseValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java   (with props)
Removed:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BaseValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ISO8601.java
Modified:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/client/ClientRepository.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BooleanValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DateValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DecimalValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DoubleValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/LongValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/NameValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/PathValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ReferenceValue.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/StringValue.java

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/client/ClientRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/client/ClientRepository.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/client/ClientRepository.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/client/ClientRepository.java Mon Jan 18 15:45:19 2010
@@ -27,7 +27,7 @@
 import org.apache.jackrabbit.commons.AbstractRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
-import org.apache.jackrabbit.rmi.value.StringValue;
+import org.apache.jackrabbit.rmi.value.SerialValueFactory;
 
 /**
  * Local adapter for the JCR-RMI
@@ -71,7 +71,7 @@
     public Value getDescriptorValue(String key) {
         String descriptor = getDescriptor(key);
         if (descriptor != null) {
-            return new StringValue(descriptor);
+            return SerialValueFactory.getInstance().createValue(descriptor);
         } else {
             return null;
         }

Copied: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java (from r896362, jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BaseValue.java)
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java?p2=jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java&p1=jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BaseValue.java&r1=896362&r2=900430&rev=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BaseValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java Mon Jan 18 15:45:19 2010
@@ -47,7 +47,7 @@
  * The {@link #getStream()} method uses {@link #getBinary()} to implement
  * the deprecated JCR 1.0 behaviour. This method must not be overridden.
  */
-abstract class BaseValue implements Value, Serializable {
+abstract class AbstractValue implements Value, Serializable {
 
     /**
      * Serial version UID

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java Mon Jan 18 15:45:19 2010
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.rmi.value;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.util.Calendar;
 
@@ -35,14 +32,17 @@
 /**
  * Binary value.
  */
-public class BinaryValue implements Value, Serializable {
+class BinaryValue implements Value, Serializable {
 
     /**
      * Serial version UID.
      */
-    private static final long serialVersionUID = -2837970977514458618L;
+    private static final long serialVersionUID = 1719020811685971215L;
 
-    private final byte[] data;
+    /**
+     * The binary value
+     */
+    private final Binary value;
 
     /**
      * The stream instance returned by {@link #getStream()}. Note that
@@ -51,68 +51,47 @@
     private transient InputStream stream = null;
 
     /**
-     * Creates a binary value from the given stream. The stream is closed.
-     *
-     * @param stream The <code>InputStream</code> providing the value.
-     * @throws IOException if the stream can not be read
+     * Creates a binary value.
      */
-    protected BinaryValue(InputStream stream) throws IOException {
-        try {
-            byte[] buffer = new byte[100 * 1024];
-            ByteArrayOutputStream output = new ByteArrayOutputStream();
-            int n = stream.read(buffer);
-            while (n != -1) {
-                output.write(buffer, 0, n);
-                n = stream.read(buffer);
-            }
-            this.data = output.toByteArray();
-        } finally {
-            stream.close();
-        }
+    public BinaryValue(Binary value) {
+        this.value = value;
     }
 
     /**
      * Returns {@link PropertyType#BINARY}.
-     *
-     * @return property type
      */
     public int getType() {
         return PropertyType.BINARY;
     }
 
     public Binary getBinary() {
-        return new Binary() {
-            public int read(byte[] b, long position) {
-                if (position < 0 || position >= data.length) {
-                    return -1;
-                } else {
-                    int n = Math.min(b.length, data.length - (int) position);
-                    System.arraycopy(data, (int) position, b, 0, n);
-                    return n;
-                }
-            }
-            public InputStream getStream() {
-                return new ByteArrayInputStream(data);
-            }
-            public long getSize() {
-                return data.length;
-            }
-            public void dispose() {
-            }
-        };
+        return value;
     }
 
     public String getString() throws RepositoryException {
         try {
-            return new String(data, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new RepositoryException("UTF-8 is not supported", e);
+            InputStream stream = value.getStream();
+            try {
+                Reader reader = new InputStreamReader(stream, "UTF-8");
+                StringBuilder builder = new StringBuilder();
+                char[] buffer = new char[1024];
+                int n = reader.read(buffer);
+                while (n != -1) {
+                    builder.append(buffer, 0, n);
+                    n = reader.read(buffer);
+                }
+                return builder.toString();
+            } finally {
+                stream.close();
+            }
+        } catch (IOException e) {
+            throw new RepositoryException("Unable to read the binary value", e);
         }
     }
 
-    public synchronized InputStream getStream() {
+    public synchronized InputStream getStream() throws RepositoryException {
         if (stream == null) {
-            stream = new ByteArrayInputStream(data);
+            stream = value.getStream();
         }
         return stream;
     }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BooleanValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BooleanValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BooleanValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/BooleanValue.java Mon Jan 18 15:45:19 2010
@@ -21,7 +21,7 @@
 /**
  * Boolean value.
  */
-class BooleanValue extends BaseValue {
+class BooleanValue extends AbstractValue {
 
     /**
      * Serial version UID
@@ -50,6 +50,7 @@
     /**
      * Returns the boolean value.
      */
+    @Override
     public boolean getBoolean() {
         return value;
     }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DateValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DateValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DateValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DateValue.java Mon Jan 18 15:45:19 2010
@@ -16,7 +16,11 @@
  */
 package org.apache.jackrabbit.rmi.value;
 
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
 
 import javax.jcr.PropertyType;
 import javax.jcr.ValueFormatException;
@@ -24,13 +28,18 @@
 /**
  * Date value.
  */
-class DateValue extends BaseValue {
+class DateValue extends AbstractValue {
 
     /**
      * Serial version UID
      */
     private static final long serialVersionUID = -2382837055824423966L;
 
+    // misc. numeric formats used in formatting
+    private static final DecimalFormat XX_FORMAT = new DecimalFormat("00");
+    private static final DecimalFormat XXX_FORMAT = new DecimalFormat("000");
+    private static final DecimalFormat XXXX_FORMAT = new DecimalFormat("0000");
+
     /**
      * The date value
      */
@@ -45,25 +54,6 @@
         this.value = value;
     }
 
-   /**
-    * Creates a new <code>DateValue</code> initialized to the value
-    * represented by the specified <code>String</code>.
-    * <p/>
-    * The specified <code>String</code> must be a ISO8601-compliant date/time
-    * string.
-    *
-    * @param value the string to be parsed.
-    * @throws javax.jcr.ValueFormatException If the <code>String</code> is not a valid
-    *                              ISO8601-compliant date/time string.
-    * @see ISO8601
-    */
-    protected DateValue(String value) throws ValueFormatException {
-        this(ISO8601.parse(value));
-        if (this.value == null) {
-            throw new ValueFormatException("Invalid date value: " + value);
-        }
-    }
-
     /**
      * Returns {@link PropertyType#DATE}.
      */
@@ -72,20 +62,32 @@
     }
 
     /**
+     * Returns a copy of this <code>Calendar</code> value. Modifying the
+     * returned <code>Calendar</code> does not change the value of this
+     * instance.
+     */
+    @Override
+    public Calendar getDate() {
+        return (Calendar) value.clone();
+    }
+
+    /**
      * The date is converted to the number of milliseconds since
-     * 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z). If this number
-     * is out-of-range for a double, a ValueFormatException is thrown.
+     * 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z).
      */
-    public double getDouble() {
-        return value.getTimeInMillis();
+    @Override
+    public BigDecimal getDecimal() {
+        return new BigDecimal(value.getTimeInMillis());
     }
 
     /**
-     * Returns the string represented of this <code>DateValue</code> value
-     * formatted using a ISO8601-compliant date/time.
+     * The date is converted to the number of milliseconds since
+     * 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z). If this number
+     * is out-of-range for a double, a ValueFormatException is thrown.
      */
-    public String getString() {
-        return ISO8601.format(value);
+    @Override
+    public double getDouble() {
+        return value.getTimeInMillis();
     }
 
     /**
@@ -93,17 +95,113 @@
      * 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z). If this number
      * is out-of-range for a long, a ValueFormatException is thrown.
      */
+    @Override
     public long getLong() {
         return value.getTimeInMillis();
     }
 
     /**
-     * Returns (a copy) of this <code>Calendar</code> value. Modifying the
-     * returned <code>Calendar</code> does not change the value of this
-     * instance.
+     * The date is converted to the following format:
+     * <code>sYYYY-MM-DDThh:mm:ss.sssTZD</code>
+     * where:
+     * <dl>
+     *   <dt>sYYYY</dt>
+     *   <dd>
+     *     Four-digit year with optional leading positive (‘+’) or
+     *     negative (‘-’) sign. 0000 , -0000 and +0000 all indicate
+     *     the year 1 BCE. –YYYY where YYYY is the number y indicates
+     *     the year (y+1) BCE. The absence of a sign or the presence
+     *     of a positive sign indicates a year CE. For example, -0054
+     *     would indicate the year 55 BCE, while +1969 and 1969
+     *     indicate the year 1969 CE.
+     *   </dd>
+     *   <dt>MM</dt>
+     *   <dd>
+     *     Two-digit month (01 = January, etc.)
+     *   </dd>
+     *   <dt>DD</dt>
+     *   <dd>
+     *     Two-digit day of month (01 through 31)
+     *   </dd>
+     *   <dt>hh</dt>
+     *   <dd>
+     *     Two digits of hour (00 through 23, or 24 if mm is 00 and
+     *     ss.sss is 00.000)
+     *   </dd>
+     *   <dt>mm</dt>
+     *   <dd>
+     *     Two digits of minute (00 through 59)
+     *   </dd>
+     *   <dt>ss.sss</dt>
+     *   <dd>
+     *     Seconds, to three decimal places (00.000 through 59.999 or
+     *     60.999 in the case of leap seconds)
+     *   </dd>
+     *   <dt>TZD</dt>
+     *   <dd>
+     *     Time zone designator (either Z for Zulu, i.e. UTC, or +hh:mm or
+     *     -hh:mm, i.e. an offset from UTC)
+     *   </dd>
+     * </dl>
+     * <p>
+     * Note that the “T” separating the date from the time and the
+     * separators “-”and “:” appear literally in the string.
+     * <p>
+     * This format is a subset of the format defined by ISO 8601:2004.
+     * If the DATE value cannot be represented in this format a
+     * {@link ValueFormatException} is thrown.
      */
-    public Calendar getDate() {
-        return (Calendar) value.clone();
+    public String getString() {
+        // determine era and adjust year if necessary
+        int year = value.get(Calendar.YEAR);
+        if (value.isSet(Calendar.ERA)
+                && value.get(Calendar.ERA) == GregorianCalendar.BC) {
+            // calculate year using astronomical system:
+            // year n BCE => astronomical year - n + 1
+            year = 0 - year + 1;
+        }
+
+        // note that we cannot use java.text.SimpleDateFormat for
+        // formatting because it can't handle years <= 0 and TZD's
+        StringBuilder buf = new StringBuilder(32);
+
+        // year ([-]YYYY)
+        buf.append(XXXX_FORMAT.format(year));
+        buf.append('-');
+        // month (MM)
+        buf.append(XX_FORMAT.format(value.get(Calendar.MONTH) + 1));
+        buf.append('-');
+        // day (DD)
+        buf.append(XX_FORMAT.format(value.get(Calendar.DAY_OF_MONTH)));
+        buf.append('T');
+        // hour (hh)
+        buf.append(XX_FORMAT.format(value.get(Calendar.HOUR_OF_DAY)));
+        buf.append(':');
+        // minute (mm)
+        buf.append(XX_FORMAT.format(value.get(Calendar.MINUTE)));
+        buf.append(':');
+        // second (ss)
+        buf.append(XX_FORMAT.format(value.get(Calendar.SECOND)));
+        buf.append('.');
+        // millisecond (SSS)
+        buf.append(XXX_FORMAT.format(value.get(Calendar.MILLISECOND)));
+
+        // time zone designator (Z or +00:00 or -00:00)
+        TimeZone tz = value.getTimeZone();
+        // time zone offset (in minutes) from UTC (including daylight saving)
+        int offset = tz.getOffset(value.getTimeInMillis()) / 1000 / 60;
+        if (offset != 0) {
+            int hours = Math.abs(offset / 60);
+            int minutes = Math.abs(offset % 60);
+            buf.append(offset < 0 ? '-' : '+');
+            buf.append(XX_FORMAT.format(hours));
+            buf.append(':');
+            buf.append(XX_FORMAT.format(minutes));
+        } else {
+            buf.append('Z');
+        }
+
+        return buf.toString();
     }
 
 }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DecimalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DecimalValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DecimalValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DecimalValue.java Mon Jan 18 15:45:19 2010
@@ -20,13 +20,12 @@
 import java.util.Calendar;
 
 import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
 
 /**
  * Decimal value.
  */
-class DecimalValue extends BaseValue {
+class DecimalValue extends AbstractValue {
 
     /**
      * Serial version UID.
@@ -34,6 +33,18 @@
     private static final long serialVersionUID = 2077767642124007133L;
 
     /**
+     * The minimum value for date conversion.
+     */
+    private static final BigDecimal MIN_DATE =
+        BigDecimal.valueOf(Long.MIN_VALUE);
+
+    /**
+     * The maximum value for date conversion.
+     */
+    private static final BigDecimal MAX_DATE =
+        BigDecimal.valueOf(Long.MAX_VALUE);
+
+    /**
      * The decimal value.
      */
     private final BigDecimal value;
@@ -56,22 +67,40 @@
      * The decimal is converted to a long and interpreted as the number of
      * milliseconds since 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z).
      * If the resulting value is out of range for a date,
-     * a ValueFormatException is thrown.
+     * a {@link ValueFormatException} is thrown.
      */
+    @Override
     public Calendar getDate() throws ValueFormatException {
-        Calendar date = Calendar.getInstance();
-        date.setTimeInMillis(getLong());
-        return date;
+        if (value.compareTo(MIN_DATE) >= 0 && value.compareTo(MAX_DATE) <= 0) {
+            Calendar date = Calendar.getInstance();
+            date.setTimeInMillis(getLong());
+            return date;
+        } else {
+            throw new ValueFormatException(
+                    "Decimal value is outside the date range: " + value);
+        }
     }
 
+    /**
+     * Returns the decimal value.
+     */
     @Override
-    public BigDecimal getDecimal() throws RepositoryException {
+    public BigDecimal getDecimal() {
         return value;
     }
 
     /**
+     * The decimal is converted using {@link BigDecimal#doubleValue()}.
+     */
+    @Override
+    public double getDouble() {
+        return value.doubleValue();
+    }
+
+    /**
      * The decimal is converted using {@link BigDecimal#longValue()}.
      */
+    @Override
     public long getLong() {
         return value.longValue();
     }
@@ -83,11 +112,4 @@
         return value.toString();
     }
 
-    /**
-     * The decimal is converted using {@link BigDecimal#doubleValue()}.
-     */
-    public double getDouble() {
-        return value.doubleValue();
-    }
-
 }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DoubleValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DoubleValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DoubleValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/DoubleValue.java Mon Jan 18 15:45:19 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.rmi.value;
 
+import java.math.BigDecimal;
 import java.util.Calendar;
 
 import javax.jcr.PropertyType;
@@ -24,7 +25,7 @@
 /**
  * Double value.
  */
-class DoubleValue extends BaseValue {
+class DoubleValue extends AbstractValue {
 
     /**
      * Serial version UID.
@@ -52,34 +53,52 @@
 
     /**
      * Returns a <code>Calendar</code> instance interpreting the double as the
-     * time in milliseconds since the epoch (1.1.1970, 0:00, UTC).
+     * time in milliseconds since the epoch (1.1.1970, 0:00, UTC). If the
+     * resulting value is out of range for a date,
+     * a {@link ValueFormatException} is thrown.
      */
+    @Override
     public Calendar getDate() throws ValueFormatException {
-        Calendar date = Calendar.getInstance();
-        date.setTimeInMillis((long) value);
-        return date;
+        if (Long.MIN_VALUE <= value && value <= Long.MAX_VALUE) {
+            Calendar date = Calendar.getInstance();
+            date.setTimeInMillis((long) value);
+            return date;
+        } else {
+            throw new ValueFormatException(
+                    "Double value is outside the date range: " + value);
+        }
+    }
+
+    /**
+     * The double is converted using the constructor
+     * {@link BigDecimal#BigDecimal(double)}.
+     */
+    @Override
+    public BigDecimal getDecimal() {
+        return new BigDecimal(value);
     }
 
     /**
      * Returns the double value.
      */
+    @Override
     public double getDouble() {
         return value;
     }
 
     /**
-     * Returns the double as a string converted by the
-     * <code>Double.toString(double)</code>.
+     * Standard Java type coercion is used.
      */
-    public String getString() {
-        return Double.toString(value);
+    @Override
+    public long getLong() {
+        return (long) value;
     }
 
     /**
-     * Returns the value converted to a long.
+     * The double is converted using {@link Double#toString(double)}.
      */
-    public long getLong() {
-        return (long) value;
+    public String getString() {
+        return Double.toString(value);
     }
 
 }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/LongValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/LongValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/LongValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/LongValue.java Mon Jan 18 15:45:19 2010
@@ -16,19 +16,15 @@
  */
 package org.apache.jackrabbit.rmi.value;
 
+import java.math.BigDecimal;
 import java.util.Calendar;
 
 import javax.jcr.PropertyType;
-import javax.jcr.ValueFormatException;
 
 /**
- * The <code>LongValue</code> class implements the committed value state for
- * Long values as a part of the State design pattern (Gof) used by this
- * package.
- *
- * @since 0.16.4.1
+ * Long value.
  */
-public class LongValue extends BaseValue {
+class LongValue extends AbstractValue {
 
     /**
      * Serial version UID.
@@ -41,38 +37,11 @@
     /**
      * Creates an instance for the given long <code>value</code>.
      */
-    protected LongValue(long value) {
+    public LongValue(long value) {
         this.value = value;
     }
 
     /**
-     * Creates an instance for the given string representation of a long.
-     * <p>
-     * This implementation uses the <code>Long.valueOf(String)</code> method
-     * to convert the string to a long.
-     *
-     * @throws ValueFormatException if the string <code>value</code> cannot be
-     *      parsed to long.
-     */
-    protected LongValue(String value) throws ValueFormatException {
-        this(toLong(value));
-    }
-
-    /**
-     * Returns the long value represented by the string <code>value</code>.
-     *
-     * @throws ValueFormatException if the string <code>value</code> cannot be
-     *      parsed to long.
-     */
-    protected static long toLong(String value) throws ValueFormatException {
-        try {
-            return Long.valueOf(value).longValue();
-        } catch (NumberFormatException e) {
-            throw new ValueFormatException(e);
-        }
-    }
-
-    /**
      * Returns <code>PropertyType.LONG</code>.
      */
     public int getType() {
@@ -80,35 +49,45 @@
     }
 
     /**
-     * Returns a <code>Calendar</code> instance interpreting the long as the
-     * time in milliseconds since the epoch (1.1.1970, 0:00, UTC).
+     * The long is interpreted as the number of milliseconds since
+     * 00:00 (UTC) 1 January 1970 (1970-01-01T00:00:00.000Z).
      */
-    public Calendar getDate() throws ValueFormatException {
+    @Override
+    public Calendar getDate() {
         Calendar date = Calendar.getInstance();
-        date.setTimeInMillis((long) value);
+        date.setTimeInMillis(value);
         return date;
     }
 
     /**
-     * Returns the double value.
+     * The long is converted using the method {@link BigDecimal#valueOf(long)}.
      */
-    public long getLong() {
-        return value;
+    @Override
+    public BigDecimal getDecimal() {
+        return BigDecimal.valueOf(value);
     }
 
     /**
-     * Returns the long as a string converted by the
-     * <code>Long.toString(long)</code>.
+     * Standard Java type coercion is used.
      */
-    public String getString() {
-        return Long.toString(value);
+    @Override
+    public double getDouble() {
+        return value;
     }
 
     /**
-     * Returns the value converted to a double.
+     * Returns the long value.
      */
-    public double getDouble() {
+    @Override
+    public long getLong() {
         return value;
     }
 
+    /**
+     * The long is converted using {@link Long#toString(long)}.
+     */
+    public String getString() {
+        return Long.toString(value);
+    }
+
 }

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/NameValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/NameValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/NameValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/NameValue.java Mon Jan 18 15:45:19 2010
@@ -26,7 +26,7 @@
  *
  * @since 0.16.4.1
  */
-public class NameValue extends BaseValue {
+public class NameValue extends AbstractValue {
 
     /**
      * Serial version UID.

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/PathValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/PathValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/PathValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/PathValue.java Mon Jan 18 15:45:19 2010
@@ -26,7 +26,7 @@
  *
  * @since 0.16.4.1
  */
-public class PathValue extends BaseValue {
+public class PathValue extends AbstractValue {
 
     /**
      * Serial version UID.

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ReferenceValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ReferenceValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ReferenceValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/ReferenceValue.java Mon Jan 18 15:45:19 2010
@@ -27,7 +27,7 @@
  *
  * @since 0.16.4.1
  */
-public class ReferenceValue extends BaseValue {
+public class ReferenceValue extends AbstractValue {
 
     /**
      * Serial version UID.

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java Mon Jan 18 15:45:19 2010
@@ -162,22 +162,20 @@
         case PropertyType.BINARY:
             Binary binary = value.getBinary();
             try {
-                return new BinaryValue(binary.getStream());
-            } catch (IOException e) {
-                throw new RepositoryException("Unable to read binary value");
+                return createValue(binary.getStream());
             } finally {
                 binary.dispose();
             }
         case PropertyType.BOOLEAN:
-            return new BooleanValue(value.getBoolean());
+            return createValue(value.getBoolean());
         case PropertyType.DATE:
-            return new DateValue(value.getDate());
+            return createValue(value.getDate());
         case PropertyType.DECIMAL:
-            return new DecimalValue(value.getDecimal());
+            return createValue(value.getDecimal());
         case PropertyType.DOUBLE:
-            return new DoubleValue(value.getDouble());
+            return createValue(value.getDouble());
         case PropertyType.LONG:
-            return new LongValue(value.getLong());
+            return createValue(value.getLong());
         case PropertyType.NAME:
             return new NameValue(value.getString());
         case PropertyType.PATH:
@@ -185,7 +183,7 @@
         case PropertyType.REFERENCE:
             return new ReferenceValue(value.getString());
         case PropertyType.STRING:
-            return new StringValue(value.getString());
+            return createValue(value.getString());
         default:
             throw new ValueFormatException("Unknown value type " + type);
         }
@@ -219,9 +217,9 @@
     /** {@inheritDoc} */
     public final Value createValue(InputStream value) {
         try {
-            return new BinaryValue(value);
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to create binary value", e);
+            return createValue(createBinary(value));
+        } catch (RepositoryException e) {
+            throw new RuntimeException("Unable to create a binary value", e);
         }
     }
 
@@ -232,20 +230,18 @@
 
     public Binary createBinary(InputStream stream) throws RepositoryException {
         try {
-            return new BinaryValue(stream).getBinary();
+            try {
+                return new SerializableBinary(stream);
+            } finally {
+                stream.close();
+            }
         } catch (IOException e) {
             throw new RepositoryException("Unable to read binary stream", e);
         }
     }
 
     public Value createValue(Binary value) {
-        try {
-            return new BinaryValue(value.getStream());
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to read binary stream", e);
-        } catch (RepositoryException e) {
-            throw new RuntimeException("Unable to create binary stream", e);
-        }
+        return new BinaryValue(value);
     }
 
     public Value createValue(Node value, boolean weak)

Added: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java?rev=900430&view=auto
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java (added)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java Mon Jan 18 15:45:19 2010
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.value;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.RandomAccessFile;
+import java.io.Serializable;
+
+import javax.jcr.Binary;
+import javax.jcr.RepositoryException;
+
+/**
+ * Serializable binary.
+ */
+class SerializableBinary implements Binary, Serializable {
+
+    /**
+     * Serial version UID.
+     */
+    private static final long serialVersionUID = -7742179594834275853L;
+
+    private static final int BUFFER_SIZE = 64 * 1024;
+
+    private transient long length;
+
+    private transient byte[] data;
+
+    private transient File file;
+
+    /**
+     * Creates a binary from the given stream. The stream is not closed.
+     *
+     * @param stream binary stream
+     */
+    public SerializableBinary(InputStream stream) throws IOException {
+        length = 0;
+        data = null;
+        file = null;
+
+        OutputStream output = null;
+        try {
+            byte[] buffer = new byte[BUFFER_SIZE];
+            int n = stream.read(buffer);
+            while (n != -1) {
+                length += n;
+                if (length < buffer.length) {
+                    n = stream.read(
+                            buffer, (int) length, buffer.length - (int) length);
+                } else {
+                    if (file == null) {
+                        file = File.createTempFile("jackrabbit-jcr-rmi-", null);
+                        output = new FileOutputStream(file);
+                        output.write(buffer);
+                    } else {
+                        output.write(buffer, 0, n);
+                    }
+                    n = stream.read(buffer);
+                }
+            }
+            if (file == null) {
+                data = new byte[(int) length];
+                System.arraycopy(buffer, 0, data, 0, (int) length);
+            }
+        } finally {
+            if (output != null) {
+                output.close();
+            }
+        }
+    }
+
+    public synchronized int read(byte[] b, long position)
+            throws RepositoryException {
+        if (position < 0 || position >= length) {
+            return -1;
+        } else if (data != null) {
+            int n = Math.min(b.length, data.length - (int) position);
+            System.arraycopy(data, (int) position, b, 0, n);
+            return n;
+        } else if (file != null) {
+            try {
+                RandomAccessFile random = new RandomAccessFile(file, "r");
+                try {
+                    random.seek(position);
+                    return random.read(b);
+                } finally {
+                    random.close();
+                }
+            } catch (FileNotFoundException e) {
+                throw new RepositoryException("Binary file is missing", e);
+            } catch (IOException e) {
+                throw new RepositoryException("Unable to read the binary", e);
+            }
+        } else {
+            throw new IllegalStateException("This binary has been disposed");
+        }
+    }
+
+    public synchronized InputStream getStream() throws RepositoryException {
+        if (data != null) {
+            return new ByteArrayInputStream(data);
+        } else if (file != null) {
+            try {
+                return new FileInputStream(file);
+            } catch (FileNotFoundException e) {
+                throw new RepositoryException("Binary file is missing", e);
+            }
+        } else {
+            throw new IllegalStateException("This binary has been disposed");
+        }
+    }
+
+    public long getSize() {
+        return length;
+    }
+
+    public synchronized void dispose() {
+        data = null;
+        if (file != null) {
+            file.delete();
+            file = null;
+        }
+    }
+
+    private synchronized void writeObject(ObjectOutputStream stream)
+            throws IOException {
+        stream.writeLong(length);
+        if (data != null) {
+            stream.write(data);
+        } else if (file != null) {
+            InputStream input = new FileInputStream(file);
+            try {
+                byte[] buffer = new byte[BUFFER_SIZE];
+                int n = input.read(buffer);
+                while (n != -1) {
+                    stream.write(buffer, 0, n);
+                    n = input.read(buffer);
+                }
+            } finally {
+                input.close();
+            }
+        } else {
+            throw new IllegalStateException("This binary has been disposed");
+        }
+    }
+
+    private synchronized void readObject(ObjectInputStream stream)
+            throws IOException {
+        length = stream.readLong();
+        if (length <= BUFFER_SIZE) {
+            data = new byte[(int) length];
+            stream.readFully(data);
+            file = null;
+        } else {
+            data = null;
+            file = File.createTempFile("jackrabbit-jcr-rmi-", null);
+            OutputStream output = new FileOutputStream(file);
+            try {
+                byte[] buffer = new byte[BUFFER_SIZE];
+                long count = 0;
+                int n = stream.read(buffer);
+                while (n != -1) {
+                    output.write(buffer, 0, n);
+                    count += n;
+                    n = stream.read(buffer, 0, Math.min(
+                            buffer.length, (int) (length - count)));
+                }
+            } finally {
+                output.close();
+            }
+        }
+    }
+
+    public void finalize() {
+        dispose();
+    }
+
+}

Propchange: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/SerializableBinary.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/StringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/StringValue.java?rev=900430&r1=900429&r2=900430&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/StringValue.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/value/StringValue.java Mon Jan 18 15:45:19 2010
@@ -16,19 +16,18 @@
  */
 package org.apache.jackrabbit.rmi.value;
 
+import java.math.BigDecimal;
 import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
 
 import javax.jcr.PropertyType;
 import javax.jcr.ValueFormatException;
 
 /**
- * The <code>StringValue</code> class implements the committed value state for
- * String values as a part of the State design pattern (Gof) used by this
- * package.
- *
- * @since 0.16.4.1
+ * String value.
  */
-public class StringValue extends BaseValue {
+class StringValue extends AbstractValue {
 
     /**
      * Serial version UID.
@@ -46,33 +45,171 @@
     }
 
     /**
-     * Returns <code>PropertyType.STRING</code>.
+     * Returns {@link PropertyType#STRING}.
      */
     public int getType() {
         return PropertyType.STRING;
     }
 
     /**
-     * Returns the string value.
+     * The string is converted using {@link Boolean#valueOf(String)}.
      */
-    public String getString() {
-        return value;
+    @Override
+    public boolean getBoolean() {
+        return Boolean.valueOf(value);
     }
 
     /**
-     * The string is converted using {@link Long#valueOf(String)}.
+     * If the string is in the format described in
+     * {@link DateValue#getString()}, it is converted directly, otherwise
+     * a {@link ValueFormatException} is thrown.
      */
-    public long getLong() throws ValueFormatException {
+    @Override
+    public Calendar getDate() throws ValueFormatException {
+        // check optional leading sign
+        char sign = '+';
+        int start = 0;
+        if (value.startsWith("-")) {
+            sign = '-';
+            start = 1;
+        } else if (value.startsWith("+")) {
+            sign = '+';
+            start = 1;
+        }
+
+        // note that we cannot use java.text.SimpleDateFormat for
+        // parsing because it can't handle years <= 0 and TZD's
+        int year, month, day, hour, min, sec, ms;
+        String tzID;
         try {
-            return Long.valueOf(value);
+            // year (YYYY)
+            year = Integer.parseInt(value.substring(start, start + 4));
+            start += 4;
+            // delimiter '-'
+            if (value.charAt(start) != '-') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // month (MM)
+            month = Integer.parseInt(value.substring(start, start + 2));
+            start += 2;
+            // delimiter '-'
+            if (value.charAt(start) != '-') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // day (DD)
+            day = Integer.parseInt(value.substring(start, start + 2));
+            start += 2;
+            // delimiter 'T'
+            if (value.charAt(start) != 'T') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // hour (hh)
+            hour = Integer.parseInt(value.substring(start, start + 2));
+            start += 2;
+            // delimiter ':'
+            if (value.charAt(start) != ':') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // minute (mm)
+            min = Integer.parseInt(value.substring(start, start + 2));
+            start += 2;
+            // delimiter ':'
+            if (value.charAt(start) != ':') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // second (ss)
+            sec = Integer.parseInt(value.substring(start, start + 2));
+            start += 2;
+            // delimiter '.'
+            if (value.charAt(start) != '.') {
+                throw new ValueFormatException("Not a date: " + value);
+            }
+            start++;
+            // millisecond (SSS)
+            ms = Integer.parseInt(value.substring(start, start + 3));
+            start += 3;
+            // time zone designator (Z or +00:00 or -00:00)
+            if (value.charAt(start) == '+' || value.charAt(start) == '-') {
+                // offset to UTC specified in the format +00:00/-00:00
+                tzID = "GMT" + value.substring(start);
+            } else if (value.substring(start).equals("Z")) {
+                tzID = "GMT";
+            } else {
+                throw new ValueFormatException(
+                        "Invalid time zone in a date: " + value);
+            }
+        } catch (IndexOutOfBoundsException e) {
+            throw new ValueFormatException("Not a date: " + value, e);
         } catch (NumberFormatException e) {
-            throw new ValueFormatException("Not a long value: " + value, e);
+            throw new ValueFormatException("Not a date: " + value, e);
+        }
+
+        TimeZone tz = TimeZone.getTimeZone(tzID);
+        // verify id of returned time zone (getTimeZone defaults to "GMT")
+        if (!tz.getID().equals(tzID)) {
+            throw new ValueFormatException(
+                    "Invalid time zone in a date: " + value);
+        }
+
+        // initialize Calendar object
+        Calendar cal = Calendar.getInstance(tz);
+        cal.setLenient(false);
+        // year and era
+        if (sign == '-' || year == 0) {
+            // not CE, need to set era (BCE) and adjust year
+            cal.set(Calendar.YEAR, year + 1);
+            cal.set(Calendar.ERA, GregorianCalendar.BC);
+        } else {
+            cal.set(Calendar.YEAR, year);
+            cal.set(Calendar.ERA, GregorianCalendar.AD);
+        }
+        // month (0-based!)
+        cal.set(Calendar.MONTH, month - 1);
+        // day of month
+        cal.set(Calendar.DAY_OF_MONTH, day);
+        // hour
+        cal.set(Calendar.HOUR_OF_DAY, hour);
+        // minute
+        cal.set(Calendar.MINUTE, min);
+        // second
+        cal.set(Calendar.SECOND, sec);
+        // millisecond
+        cal.set(Calendar.MILLISECOND, ms);
+
+        try {
+            // the following call will trigger an IllegalArgumentException
+            // if any of the set values are illegal or out of range
+            cal.getTime();
+        } catch (IllegalArgumentException e) {
+            throw new ValueFormatException("Not a date: " + value, e);
+        }
+
+        return cal;
+    }
+
+    /**
+     * The string is converted using the constructor
+     * {@link BigDecimal#BigDecimal(String)}.
+     */
+    @Override
+    public BigDecimal getDecimal() throws ValueFormatException {
+        try {
+            return new BigDecimal(value);
+        } catch (NumberFormatException e) {
+            throw new ValueFormatException("Not a decimal value: " + value, e);
         }
     }
 
+
     /**
      * The string is converted using {@link Double#valueOf(String)}.
      */
+    @Override
     public double getDouble() throws ValueFormatException {
         try {
             return Double.valueOf(value);
@@ -82,27 +219,22 @@
     }
 
     /**
-     * Returns the string value parsed to a <code>Calendar</code> using the
-     * same formatter as the {@link DateValue} class. This formatting bears the
-     * same issues as parsing and formatting that class.
-     *
-     * @throws ValueFormatException if the string cannot be parsed into a
-     *      <code>Calendar</code> instance.
+     * The string is converted using {@link Long#valueOf(String)}.
      */
-    public Calendar getDate() throws ValueFormatException {
-        Calendar date = ISO8601.parse(value);
-        if (date != null) {
-            return date;
-        } else {
-            throw new ValueFormatException("Invalid date value: " + value);
+    @Override
+    public long getLong() throws ValueFormatException {
+        try {
+            return Long.valueOf(value);
+        } catch (NumberFormatException e) {
+            throw new ValueFormatException("Not a long value: " + value, e);
         }
     }
 
     /**
-     * The string is converted using {@link Boolean#valueOf(String)}.
+     * Returns the string value.
      */
-    public boolean getBoolean() {
-        return Boolean.valueOf(value);
+    public String getString() {
+        return value;
     }
 
 }



Mime
View raw message