You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2005/05/09 13:55:19 UTC

svn commit: r169297 [1/2] - in /incubator/jackrabbit/trunk/contrib/jcr-rmi: ./ src/java/org/apache/jackrabbit/rmi/client/ src/java/org/apache/jackrabbit/rmi/remote/ src/java/org/apache/jackrabbit/rmi/server/ src/java/org/apache/jackrabbit/value/ src/java/org/apache/jackrabbit/value/doc-files/ src/test/org/apache/jackrabbit/test/rmi/

Author: jukka
Date: Mon May  9 04:55:17 2005
New Revision: 169297

URL: http://svn.apache.org/viewcvs?rev=169297&view=rev
Log:
JCR-RMI: Upgrade to 0.16.4.1 contributed by Felix Meschberger.

Added:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/ReferenceValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/SerialValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/SerialValueFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/StatefullValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/StatefullValueAdapter.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/StringValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/doc-files/
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/doc-files/sequence.uxf
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/doc-files/state.uxf
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/package.html   (with props)
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemotePropertyDefinition.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/SerialValue.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerPropertyDefinition.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerRow.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/test/org/apache/jackrabbit/test/rmi/RemoteAdapterTest.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/project.xml?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/project.xml Mon May  9 04:55:17 2005
@@ -21,7 +21,7 @@
   <pomVersion>3</pomVersion>
   <id>jcr-rmi</id>
   <name>JCR-RMI</name>
-  <currentVersion>0.16.4</currentVersion>
+  <currentVersion>0.16.4.1</currentVersion>
   <inceptionYear>2004</inceptionYear>
   <package>org.apache.jackrabbit.rmi.*</package>
   <description>
@@ -60,8 +60,8 @@
     <dependency>
       <groupId>jsr170</groupId>
       <artifactId>jcr</artifactId>
-      <version>0.16.4</version>
-      <url>http://www.day.com/maven/jsr170/jars/jcr-0.16.4.jar</url>
+      <version>0.16.4.1</version>
+      <url>http://www.day.com/maven/jsr170/jars/jcr-0.16.4.1.jar</url>
     </dependency>
     <dependency>
       <groupId>xerces</groupId>

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java Mon May  9 04:55:17 2005
@@ -20,32 +20,25 @@
 import java.rmi.RemoteException;
 import java.util.Calendar;
 
-import javax.jcr.BinaryValue;
-import javax.jcr.BooleanValue;
-import javax.jcr.DateValue;
-import javax.jcr.DoubleValue;
 import javax.jcr.Item;
 import javax.jcr.ItemVisitor;
-import javax.jcr.LongValue;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
-import javax.jcr.ReferenceValue;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.StringValue;
 import javax.jcr.Value;
 import javax.jcr.lock.Lock;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.rmi.remote.RemoteLock;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Local adapter for the JCR-RMI
@@ -128,7 +121,7 @@
             throws RepositoryException {
         try {
             RemoteProperty property =
-                remote.setProperty(name, new SerialValue(value));
+                remote.setProperty(name, SerialValueFactory.makeSerialValue(value));
             return getFactory().getProperty(getSession(), property);
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
@@ -139,7 +132,7 @@
     public Property setProperty(String name, Value[] values)
             throws RepositoryException {
         try {
-            Value[] serials = SerialValue.makeSerialValueArray(values);
+            Value[] serials = SerialValueFactory.makeSerialValueArray(values);
             RemoteProperty property = remote.setProperty(name, serials);
             return getFactory().getProperty(getSession(), property);
         } catch (RemoteException ex) {
@@ -152,7 +145,7 @@
             throws RepositoryException {
         Value[] values = new Value[strings.length];
         for (int i = 0; i < strings.length; i++) {
-            values[i] = new StringValue(strings[i]);
+            values[i] = getSession().getValueFactory().createValue(strings[i]);
         }
         return setProperty(name, values);
     }
@@ -160,43 +153,43 @@
     /** {@inheritDoc} */
     public Property setProperty(String name, String value)
             throws RepositoryException {
-        return setProperty(name, new StringValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, InputStream value)
             throws RepositoryException {
-        return setProperty(name, new BinaryValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, boolean value)
             throws RepositoryException {
-        return setProperty(name, new BooleanValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, double value)
             throws RepositoryException {
-        return setProperty(name, new DoubleValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, long value)
             throws RepositoryException {
-        return setProperty(name, new LongValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, Calendar value)
             throws RepositoryException {
-        return setProperty(name, new DateValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
     public Property setProperty(String name, Node value)
             throws RepositoryException {
-        return setProperty(name, new ReferenceValue(value));
+        return setProperty(name, getSession().getValueFactory().createValue(value));
     }
 
     /** {@inheritDoc} */
@@ -501,7 +494,7 @@
             throws RepositoryException {
         Value[] values = new Value[strings.length];
         for (int i = 0; i < strings.length; i++) {
-            values[i] = new StringValue(strings[i]);
+            values[i] = getSession().getValueFactory().createValue(strings[i]);
         }
         return setProperty(name, values, type);
     }
@@ -510,7 +503,7 @@
     public Property setProperty(String name, Value[] values, int type)
             throws RepositoryException {
         try {
-            Value[] serials = SerialValue.makeSerialValueArray(values);
+            Value[] serials = SerialValueFactory.makeSerialValueArray(values);
             RemoteProperty property = remote.setProperty(name, serials, type);
             return getFactory().getProperty(getSession(), property);
         } catch (RemoteException ex) {
@@ -523,7 +516,7 @@
             throws RepositoryException {
         try {
             RemoteProperty property =
-                    remote.setProperty(name, new SerialValue(value), type);
+                    remote.setProperty(name, SerialValueFactory.makeSerialValue(value), type);
             return getFactory().getProperty(getSession(), property);
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
@@ -533,7 +526,7 @@
     /** {@inheritDoc} */
     public Property setProperty(String name, String value, int type)
             throws RepositoryException {
-        return setProperty(name, new StringValue(value), type);
+        return setProperty(name, getSession().getValueFactory().createValue(value), type);
     }
 
     /** {@inheritDoc} */

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java Mon May  9 04:55:17 2005
@@ -25,7 +25,7 @@
 
 import org.apache.jackrabbit.rmi.remote.RemoteNodeDefinition;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Local adapter for the JCR-RMI
@@ -148,7 +148,7 @@
     /** {@inheritDoc} */
     public boolean canSetProperty(String name, Value value) {
         try {
-            return remote.canSetProperty(name, new SerialValue(value));
+            return remote.canSetProperty(name, SerialValueFactory.makeSerialValue(value));
         } catch (RemoteException ex) {
             throw new RemoteRuntimeException(ex);
         }
@@ -157,7 +157,7 @@
     /** {@inheritDoc} */
     public boolean canSetProperty(String name, Value[] values) {
         try {
-            Value[] serials = SerialValue.makeSerialValueArray(values);
+            Value[] serials = SerialValueFactory.makeSerialValueArray(values);
             return remote.canSetProperty(name, serials);
         } catch (RemoteException ex) {
             throw new RemoteRuntimeException(ex);

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientProperty.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientProperty.java Mon May  9 04:55:17 2005
@@ -20,23 +20,16 @@
 import java.rmi.RemoteException;
 import java.util.Calendar;
 
-import javax.jcr.BinaryValue;
-import javax.jcr.BooleanValue;
-import javax.jcr.DateValue;
-import javax.jcr.DoubleValue;
 import javax.jcr.ItemVisitor;
-import javax.jcr.LongValue;
 import javax.jcr.Node;
 import javax.jcr.Property;
-import javax.jcr.ReferenceValue;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.StringValue;
 import javax.jcr.Value;
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Local adapter for the JCR-RMI
@@ -163,7 +156,7 @@
      * {@inheritDoc}
      */
     public void setValue(boolean value) throws RepositoryException {
-        setValue(new BooleanValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -173,7 +166,7 @@
      * {@inheritDoc}
      */
     public void setValue(Calendar value) throws RepositoryException {
-        setValue(new DateValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -183,7 +176,7 @@
      * {@inheritDoc}
      */
     public void setValue(double value) throws RepositoryException {
-        setValue(new DoubleValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -193,7 +186,7 @@
      * {@inheritDoc}
      */
     public void setValue(InputStream value) throws RepositoryException {
-        setValue(new BinaryValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -203,7 +196,7 @@
      * {@inheritDoc}
      */
     public void setValue(long value) throws RepositoryException {
-        setValue(new LongValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -213,7 +206,7 @@
      * {@inheritDoc}
      */
     public void setValue(Node value) throws RepositoryException {
-        setValue(new ReferenceValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -223,7 +216,7 @@
      * {@inheritDoc}
      */
     public void setValue(String value) throws RepositoryException {
-        setValue(new StringValue(value));
+        setValue(getSession().getValueFactory().createValue(value));
     }
 
     /**
@@ -235,7 +228,7 @@
     public void setValue(String[] strings) throws RepositoryException {
         Value[] values = new Value[strings.length];
         for (int i = 0; i < strings.length; i++) {
-            values[i] = new StringValue(strings[i]);
+            values[i] = getSession().getValueFactory().createValue(strings[i]);
         }
         setValue(values);
     }
@@ -243,7 +236,7 @@
     /** {@inheritDoc} */
     public void setValue(Value value) throws RepositoryException {
         try {
-            remote.setValue(new SerialValue(value));
+            remote.setValue(SerialValueFactory.makeSerialValue(value));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -252,7 +245,7 @@
     /** {@inheritDoc} */
     public void setValue(Value[] values) throws RepositoryException {
         try {
-            remote.setValue(SerialValue.makeSerialValueArray(values));
+            remote.setValue(SerialValueFactory.makeSerialValueArray(values));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryManager.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryManager.java Mon May  9 04:55:17 2005
@@ -82,7 +82,7 @@
     }
 
     /** {@inheritDoc} */
-    public String[] getSupportedQueryLanguages() {
+    public String[] getSupportedQueryLanguages() throws RepositoryException {
         try {
             return remote.getSupportedQueryLanguages();
         } catch (RemoteException ex) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java Mon May  9 04:55:17 2005
@@ -30,6 +30,7 @@
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
@@ -42,6 +43,7 @@
 
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
 import org.apache.jackrabbit.rmi.xml.SessionImportContentHandler;
+import org.apache.jackrabbit.value.SerialValueFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -205,6 +207,15 @@
         }
     }
 
+    /**
+     * Returns the {@link SerialValueFactory#getInstance()}.
+     *  
+     * {@inheritDoc}
+     */
+    public ValueFactory getValueFactory() {
+        return SerialValueFactory.getInstance();
+    }
+    
     /** {@inheritDoc} */
     public void checkPermission(String path, String actions)
             throws AccessControlException, RepositoryException {

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java Mon May  9 04:55:17 2005
@@ -42,9 +42,8 @@
  * and calling the generic setProperty methods. Note also that the
  * Value objects must be serializable and implemented using classes
  * available on both the client and server side. The
- * {@link org.apache.jackrabbit.rmi.remote.SerialValue SerialValue}
- * decorator utility provides a convenient way to satisfy these
- * requirements.
+ * {@link org.apache.jackrabbit.value.SerialValueFactory SerialValueFactory}
+ * class provides two convenience methods to satisfy these requirements.
  *
  * @author Jukka Zitting
  * @see javax.jcr.Node

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java Mon May  9 04:55:17 2005
@@ -39,13 +39,12 @@
  * <p>
  * Note that only the generic getValue and setValue methods are included
  * in this interface. Clients should implement the type-specific value
- * getters and setters wrapping using the generic methods. Note also that
- * the Value objects must be serializable and implemented using classes
+ * getters and setters wrapping using the generic methods. Note also that the
+ * Value objects must be serializable and implemented using classes
  * available on both the client and server side. The
- * {@link org.apache.jackrabbit.rmi.remote.SerialValue SerialValue}
- * decorator utility provides a convenient way to satisfy these
- * requirements.
- *
+ * {@link org.apache.jackrabbit.value.SerialValueFactory SerialValueFactory}
+ * class provides two convenience methods to satisfy these requirements.
+ * 
  * @author Jukka Zitting
  * @see javax.jcr.Property
  * @see org.apache.jackrabbit.rmi.client.ClientProperty

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemotePropertyDefinition.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemotePropertyDefinition.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemotePropertyDefinition.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemotePropertyDefinition.java Mon May  9 04:55:17 2005
@@ -34,11 +34,10 @@
  * values and possible exceptions are copied over the network. RMI errors
  * are signalled with RemoteExceptions.
  * <p>
- * Note that returned Value objects must be serializable and implemented
+ * Note that the returned Value objects must be serializable and implemented
  * using classes available on both the client and server side. The
- * {@link org.apache.jackrabbit.rmi.remote.SerialValue SerialValue}
- * decorator utility provides a convenient way to satisfy these
- * requirements.
+ * {@link org.apache.jackrabbit.value.SerialValueFactory SerialValueFactory}
+ * class provides two convenience methods to satisfy this requirement.
  *
  * @author Jukka Zitting
  * @see javax.jcr.nodetype.PropertyDefinition

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java Mon May  9 04:55:17 2005
@@ -64,8 +64,10 @@
      *
      * See {@link Query}.
      * @return An string array.
+     * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    String[] getSupportedQueryLanguages() throws RemoteException;
+    String[] getSupportedQueryLanguages() 
+            throws RepositoryException, RemoteException;
 
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/SerialValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/SerialValue.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/SerialValue.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/SerialValue.java Mon May  9 04:55:17 2005
@@ -1,274 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- *                     as applicable.
- *
- * Licensed 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.remote;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Calendar;
-
-import javax.jcr.BinaryValue;
-import javax.jcr.BooleanValue;
-import javax.jcr.DateValue;
-import javax.jcr.DoubleValue;
-import javax.jcr.LongValue;
-import javax.jcr.NameValue;
-import javax.jcr.PathValue;
-import javax.jcr.PropertyType;
-import javax.jcr.ReferenceValue;
-import javax.jcr.RepositoryException;
-import javax.jcr.StringValue;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-
-/**
- * Serializable {@link Value Value} decorator. A SerialValue decorator
- * makes it possible to serialize the contents of a Value object even
- * if the object itself is not serializable. For example the standard
- * JCR Value classes are not serializable.
- * <p>
- * Serialization is achieved by extracting and serializing the type and
- * underlying data of the Value object. On deserialization the type and
- * data information is used to create a standard JCR Value object as
- * a copy of the original value. This makes it possible to copy even
- * system-specific Value instances to a remote JVM that might not contain
- * the implementation class of the original Value object.
- * <p>
- * The SerialValue decorator adds no other functionality to the Value
- * interface. Normal method calls are simply forwarded to the decorated
- * Value object.
- * <p>
- * Note that a decorator object keeps a reference to the underlying value
- * object and uses the standard value access methods to perform serialization.
- * Serialization therefore affects the internal state of the underlying value!
- * On the other hand, the internal state of a value might interfere with the
- * serialization decorator. The safest course of action is to only decorate
- * and serialize fresh value objects and to discard them after serialization.
- *
- * @author Jukka Zitting
- * @see javax.jcr.Value
- * @see java.io.Serializable
- */
-public class SerialValue implements Value, Serializable {
-
-    /** Static serial version UID. */
-    static final long serialVersionUID = 8070492457339121953L;
-
-    /** The decorated value. */
-    private Value value;
-
-    /**
-     * Creates a serialization decorator for the given value.
-     *
-     * @param value the value to be decorated
-     */
-    public SerialValue(Value value) {
-        this.value = value;
-    }
-
-    /**
-     * Utility method for decorating an array of values. The
-     * returned array will contain SerialValue decorators for
-     * all the given values. Note that the contents of the
-     * original values will only be copied when the decorators
-     * are serialized.
-     * <p>
-     * If the given array is <code>null</code>, then an empty
-     * array is returned.
-     *
-     * @param values the values to be decorated
-     * @return array of decorated values
-     */
-    public static Value[] makeSerialValueArray(Value[] values) {
-        if (values != null) {
-            Value[] serials = new Value[values.length];
-            for (int i = 0; i < values.length; i++) {
-                serials[i] = new SerialValue(values[i]);
-            }
-            return serials;
-        } else {
-            return new Value[0];
-        }
-    }
-
-    /**
-     * Serializes the underlying Value object. Instead of using
-     * the normal serialization mechanism, the essential state
-     * of the Value object is extracted and written to the serialization
-     * stream as a type-value pair.
-     *
-     * @param out the serialization stream
-     * @throws IOException on IO errors
-     */
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        try {
-            int type = value.getType();
-            out.writeInt(type);
-            switch (type) {
-            case PropertyType.BINARY:
-                InputStream data = value.getStream();
-                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-                byte[] bytes = new byte[4096];
-                for (int n = data.read(bytes); n != -1; n = data.read(bytes)) {
-                    buffer.write(bytes, 0, n);
-                }
-                out.writeInt(buffer.size());
-                buffer.writeTo(out);
-                break;
-            case PropertyType.BOOLEAN:
-                out.writeBoolean(value.getBoolean());
-                break;
-            case PropertyType.DATE:
-                out.writeObject(value.getDate());
-                break;
-            case PropertyType.DOUBLE:
-                out.writeDouble(value.getDouble());
-                break;
-            case PropertyType.LONG:
-                out.writeLong(value.getLong());
-                break;
-            case PropertyType.NAME:
-            case PropertyType.PATH:
-            case PropertyType.REFERENCE:
-            case PropertyType.STRING:
-                out.writeUTF(value.getString());
-                break;
-            default:
-                throw new IOException("Unknown value type");
-            }
-        } catch (RepositoryException ex) {
-            throw new IOException(ex.getMessage());
-        }
-    }
-
-    /**
-     * Deserializes the underlying Value object. A new Value object
-     * is created based on the type and state data read fro the
-     * serialization stream.
-     *
-     * @param in the serialization stream
-     * @throws IOException on IO errors
-     */
-    private void readObject(ObjectInputStream in) throws IOException {
-        try {
-            int type = in.readInt();
-            switch (type) {
-            case PropertyType.BINARY:
-                byte[] bytes = new byte[in.readInt()];
-                in.readFully(bytes);
-                value = new BinaryValue(bytes);
-                break;
-            case PropertyType.BOOLEAN:
-                value = new BooleanValue(in.readBoolean());
-                break;
-            case PropertyType.DATE:
-                value =  new DateValue((Calendar) in.readObject());
-                break;
-            case PropertyType.DOUBLE:
-                value = new DoubleValue(in.readDouble());
-                break;
-            case PropertyType.LONG:
-                value = new LongValue(in.readLong());
-                break;
-            case PropertyType.NAME:
-                value = NameValue.valueOf(in.readUTF());
-                break;
-            case PropertyType.PATH:
-                value = PathValue.valueOf(in.readUTF());
-                break;
-            case PropertyType.REFERENCE:
-                value = ReferenceValue.valueOf(in.readUTF());
-                break;
-            case PropertyType.STRING:
-                value = new StringValue(in.readUTF());
-                break;
-            default:
-                throw new IllegalStateException("Illegal serial value type");
-            }
-        } catch (ValueFormatException ex) {
-            throw new IOException(ex.getMessage());
-        } catch (ClassNotFoundException ex) {
-            throw new IOException(ex.getMessage());
-        }
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public boolean getBoolean() throws ValueFormatException,
-            IllegalStateException, RepositoryException {
-        return value.getBoolean();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public Calendar getDate() throws ValueFormatException,
-            IllegalStateException, RepositoryException {
-        return value.getDate();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public double getDouble() throws ValueFormatException,
-            IllegalStateException, RepositoryException {
-        return value.getDouble();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public long getLong() throws ValueFormatException, IllegalStateException,
-            RepositoryException {
-        return value.getLong();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public InputStream getStream() throws ValueFormatException,
-            IllegalStateException, RepositoryException {
-        return value.getStream();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public String getString() throws ValueFormatException,
-            IllegalStateException, RepositoryException {
-        return value.getString();
-    }
-
-    /**
-     * Forwards the method call to the decorated value.
-     * {@inheritDoc}
-     */
-    public int getType() {
-        return value.getType();
-    }
-
-}

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerProperty.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerProperty.java Mon May  9 04:55:17 2005
@@ -24,7 +24,7 @@
 
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
 import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Remote adapter for the JCR {@link javax.jcr.Property Property}
@@ -58,7 +58,7 @@
     /** {@inheritDoc} */
     public Value getValue() throws RepositoryException, RemoteException {
         try {
-            return new SerialValue(property.getValue());
+            return SerialValueFactory.makeSerialValue(property.getValue());
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }
@@ -67,7 +67,7 @@
     /** {@inheritDoc} */
     public Value[] getValues() throws RepositoryException, RemoteException {
         try {
-            return SerialValue.makeSerialValueArray(property.getValues());
+            return SerialValueFactory.makeSerialValueArray(property.getValues());
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerPropertyDefinition.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerPropertyDefinition.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerPropertyDefinition.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerPropertyDefinition.java Mon May  9 04:55:17 2005
@@ -22,7 +22,7 @@
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Remote adapter for the JCR
@@ -67,7 +67,7 @@
 
     /** {@inheritDoc} */
     public Value[] getDefaultValues() throws RemoteException {
-        return SerialValue.makeSerialValueArray(def.getDefaultValues());
+        return SerialValueFactory.makeSerialValueArray(def.getDefaultValues());
     }
 
     /** {@inheritDoc} */

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryManager.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryManager.java Mon May  9 04:55:17 2005
@@ -80,8 +80,13 @@
     }
 
     /** {@inheritDoc} */
-    public String[] getSupportedQueryLanguages() throws RemoteException {
+    public String[] getSupportedQueryLanguages()
+            throws RepositoryException, RemoteException {
+        try {
         return manager.getSupportedQueryLanguages();
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+    }
     }
 
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerRow.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerRow.java?rev=169297&r1=169296&r2=169297&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerRow.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerRow.java Mon May  9 04:55:17 2005
@@ -23,7 +23,7 @@
 import javax.jcr.query.Row;
 
 import org.apache.jackrabbit.rmi.remote.RemoteRow;
-import org.apache.jackrabbit.rmi.remote.SerialValue;
+import org.apache.jackrabbit.value.SerialValueFactory;
 
 /**
  * Remote adapter for the JCR {@link javax.jcr.query.Row Row} interface.
@@ -61,6 +61,6 @@
     /** {@inheritDoc} */
     public Value getValue(String propertyName)
             throws RepositoryException, RemoteException {
-        return new SerialValue(row.getValue(propertyName));
+        return SerialValueFactory.makeSerialValue(row.getValue(propertyName));
     }
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.InputStream;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>BaseNonStreamValue</code> class implements the basic committed
+ * value state for non-stream values as a part of the State design pattern (Gof)
+ * used by this package.
+ * <p>
+ * This class implements all methods of the
+ * {@link org.apache.jackrabbit.value.StatefullValue} except
+ * <code>getString</code> and <code>getType</code> interface by always
+ * throwing an appropriate exception. Extensions of this class should overwrite
+ * methods as appropriate except for the {@link #getStream()} which must throw
+ * an <code>IllegalStateException</code> for this line of committed non-stream
+ * states.
+ * 
+ * @version $Revision$, $Date$
+ * @author Felix Meschberger
+ * @since 0.16.4.1
+ */
+public abstract class BaseNonStreamValue implements StatefullValue {
+
+    /**
+     * Default constructor with no special tasks.
+     */
+    protected BaseNonStreamValue() {}
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only non-stream
+     * getters are available from this implementation.
+     * <p>
+     * This method is declared final to mark that this line of implementations
+     * does not provide access to <code>InputStream</code>s.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public final InputStream getStream() {
+        throw new IllegalStateException("Stream not available");
+    }
+
+    /**
+     * Always throws a <code>ValueFormatException</code>. Implementations should
+     * overwrite if conversion to boolean is supported.
+     * 
+     * @throws ValueFormatException If the value cannot be converted to a
+     *      boolean.
+     */
+    public boolean getBoolean() throws ValueFormatException {
+        throw getValueFormatException(PropertyType.TYPENAME_BOOLEAN);
+    }
+
+    /**
+     * Always throws a <code>ValueFormatException</code>. Implementations should
+     * overwrite if conversion to <code>Calender</code> is supported.
+     * 
+     * @throws ValueFormatException If the value cannot be converted to a
+     *      <code>Calendar</code> instance.
+     */
+    public Calendar getDate() throws ValueFormatException {
+        throw getValueFormatException(PropertyType.TYPENAME_DATE);
+    }
+
+    /**
+     * Always throws a <code>ValueFormatException</code>. Implementations should
+     * overwrite if conversion to double is supported.
+     * 
+     * @throws ValueFormatException If the value cannot be converted to a
+     *      double.
+     */
+    public double getDouble() throws ValueFormatException {
+        throw getValueFormatException(PropertyType.TYPENAME_DOUBLE);
+    }
+
+    /**
+     * Always throws a <code>ValueFormatException</code>. Implementations should
+     * overwrite if conversion to long is supported.
+     * 
+     * @throws ValueFormatException If the value cannot be converted to a
+     *      long.
+     */
+    public long getLong() throws ValueFormatException {
+        throw getValueFormatException(PropertyType.TYPENAME_LONG);
+    }
+    
+    /**
+     * Returns a <code>ValueFormatException</code> with a message indicating
+     * what kind of type conversion is not supported.
+     * 
+     * @param destType The name of the value type to which this value cannot
+     *      be converted. 
+     */
+    protected ValueFormatException getValueFormatException(String destType) {
+        return new ValueFormatException("Cannot convert value of type "
+            + PropertyType.nameFromValue(getType()) + " to " + destType);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>BinaryValue</code> class implements the committed value state for
+ * Binary values as a part of the State design pattern (Gof) used by this
+ * package. 
+ * <p>
+ * NOTE: This class forwards the <code>InputStream</code> from which it was
+ * created through the {@link #getStream()} method but does not close the
+ * stream. It is the sole responsibility of the user of this value to close the
+ * stream if not needed anymore to prevent memory loss.
+ * 
+ * @version $Revision$, $Date$
+ * @author Jukka Zitting
+ * @since 0.16.4.1
+ * 
+ * @see org.apache.jackrabbit.value.SerialValue
+ */
+public class BinaryValue implements StatefullValue {
+
+    /** The <code>InputStream</code> providing the value */
+    private final InputStream stream;
+
+    /**
+     * Creates an instance on the given <code>InputStream</code>. This exact
+     * stream will be provided by the {@link #getStream()}, thus care must be
+     * taken to not inadvertendly read or close the stream.
+     * 
+     * @param stream The <code>InputStream</code> providing the value.
+     */
+    protected BinaryValue(InputStream stream) {
+        this.stream = stream;
+    }
+
+    /**
+     * Creates an instance providing the UTF-8 representation of the given
+     * string value.
+     * 
+     * @param value The string whose UTF-8 representation is provided as the
+     *      value of this instance.
+     * 
+     * @throws ValueFormatException If the platform does not support UTF-8
+     *      encoding (which is unlikely as UTF-8 is required to be available
+     *      on all platforms).
+     */
+    protected BinaryValue(String value) throws ValueFormatException {
+        this(toStream(value));
+    }
+
+    /**
+     * Helper method to convert a string value into an <code>InputStream</code>
+     * from which the UTF-8 representation can be read.
+     * 
+     * @param value The string value to be made available through a stream.
+     * 
+     * @return The <code>InputStream</code> from which the UTF-8 representation
+     *      of the <code>value</code> may be read.
+     * 
+     * @throws ValueFormatException If the platform does not support UTF-8
+     *      encoding (which is unlikely as UTF-8 is required to be available
+     *      on all platforms).
+     */
+    protected static InputStream toStream(String value)
+            throws ValueFormatException {
+        try {
+            return new ByteArrayInputStream(value.getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            throw new ValueFormatException("Invalid string value encoding", e);
+        }
+    }
+
+    /**
+     * Returns the <code>InputStream</code> from which this instance has been
+     * created.
+     */
+    public InputStream getStream() {
+        return stream;
+    }
+
+    /**
+     * Returns <code>PropertyType.BINARY</code>.
+     */
+    public int getType() {
+        return PropertyType.BINARY;
+    }
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only an
+     * <code>InputStream</code> is available from this implementation.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public String getString() {
+        throw new IllegalStateException("Stream already retrieved");
+    }
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only an
+     * <code>InputStream</code> is available from this implementation.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public long getLong() {
+        throw new IllegalStateException("Stream already retrieved");
+    }
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only an
+     * <code>InputStream</code> is available from this implementation.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public double getDouble() {
+        throw new IllegalStateException("Stream already retrieved");
+    }
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only an
+     * <code>InputStream</code> is available from this implementation.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public Calendar getDate() {
+        throw new IllegalStateException("Stream already retrieved");
+    }
+
+    /**
+     * Always throws <code>IllegalStateException</code> because only an
+     * <code>InputStream</code> is available from this implementation.
+     * 
+     * @throws IllegalStateException as defined above. 
+     */
+    public boolean getBoolean() {
+        throw new IllegalStateException("Stream already retrieved");
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>BooleanValue</code> class implements the committed value state for
+ * Boolean values as a part of the State design pattern (Gof) used by this
+ * package. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Jukka Zitting
+ * @since 0.16.4.1
+ * 
+ * @see org.apache.jackrabbit.value.SerialValue
+ */
+public class BooleanValue extends BaseNonStreamValue {
+
+    /** The boolean value */
+    private final boolean value;
+
+    /**
+     * Creates an instance for the given boolean <code>value</code>.
+     */
+    protected BooleanValue(boolean value) {
+        this.value = value;
+    }
+
+    /**
+     * Creates an instance for the given string representation of a boolean.
+     * <p>
+     * Calls {@link #toBoolean(String)} to convert the string to a boolean.
+     */
+    protected BooleanValue(String value) {
+        this(toBoolean(value));
+    }
+    
+    /**
+     * Returns the boolean value represented by the string <code>value</code>.
+     * <p>
+     * This implementation uses the <code>Boolean.valueOf(String)</code> method
+     * to convert the string to a boolean.
+     */
+    protected static boolean toBoolean(String value) {
+        return Boolean.valueOf(value).booleanValue();
+    }
+
+    /**
+     * Returns <code>PropertyType.BOOLEAN</code>.
+     */
+    public int getType() {
+        return PropertyType.BOOLEAN;
+    }
+
+    /**
+     * Returns the boolean value.
+     */
+    public boolean getBoolean() {
+        return value;
+    }
+
+    /**
+     * Returns the boolean as a string converted by the
+     * <code>Boolean.toString(boolean)</code>.
+     */
+    public String getString() {
+        return Boolean.toString(value);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BooleanValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>DateValue</code> class implements the committed value state for
+ * Date values as a part of the State design pattern (Gof) used by this
+ * package.
+ * <p>
+ * To convert <code>Calendar</code> instances to and from strings, this class
+ * uses a <code>SimpleDateFormat</code> instance with the pattern
+ * <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code>. The issue with this pattern is that
+ * the era specification as defined in the JCR specification (+/- prefix) as
+ * well as full time zone naming are not supported.
+ * 
+ * @version $Revision$, $Date$
+ * @author Jukka Zitting
+ * @since 0.16.4.1
+ * 
+ * @see org.apache.jackrabbit.value.SerialValue
+ */
+public class DateValue extends BaseNonStreamValue {
+
+    /** The <code>Calendar</code> value */
+    private final Calendar value;
+
+    /**
+     * This should probably actually be a reference to the ISO8601 utility
+     * class.
+     */
+    private static final DateFormat DATE_FORMAT = 
+        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+    
+    /**
+     * Creates an instance for the given <code>Calendar</code> <code>value</code>.
+     */
+    protected DateValue(Calendar value) {
+        this.value = value;
+    }
+
+   /**
+    * Creates an instance for the given string representation of a
+    * <code>Calendar</code>.
+    * <p>
+    * This implementation uses a <code>SimpleDateFormat</code> instance with
+    * the pattern <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code> to parse the string into
+    * a <code>Calendar</code> object. See the class comment for issues regarding
+    * this pattern.
+    */
+    protected DateValue(String value) throws ValueFormatException {
+        this(toCalendar(value));
+    }
+
+    /**
+     * Returns the string <code>value</code> parsed into a
+     * <code>Calendar</code> instance.
+     * 
+     * @param value The string value.
+     * @return The <code>Calendar</code> instance parsed from the string
+     *         value.
+     * @throws ValueFormatException if the string value cannot be parsed into a
+     *             <code>Calendar</code> instance.
+     */
+    protected static Calendar toCalendar(String value) throws ValueFormatException {
+        synchronized (DATE_FORMAT) {
+            try {
+                Calendar time = Calendar.getInstance();
+                time.setTime(DATE_FORMAT.parse(value));
+                return time;
+            } catch (ParseException pe) {
+                throw new ValueFormatException(pe.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Returns <code>PropertyType.DATE</code>.
+     */
+    public int getType() {
+        return PropertyType.DATE;
+    }
+
+    /**
+     * Returns the time represented by this instance as the number of
+     * milliseconds since the epoch (1.1.1970, 0:00, UTC).
+     */
+    public double getDouble() {
+        return value.getTimeInMillis();
+    }
+
+    /**
+     * Returns the string represented of this <code>Calendar</code> value
+     * formatted using a <code>SimpleDateFormatter</code> with the pattern
+     * <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code>. See the class comment for issues
+     * regarding this pattern.
+     */
+    public String getString() {
+        synchronized (DATE_FORMAT) {
+            return DATE_FORMAT.format(value.getTime());
+        }
+    }
+
+    /**
+     * Returns the time represented by this instance as the number of
+     * milliseconds since the epoch (1.1.1970, 0:00, UTC).
+     */
+    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.
+     */
+    public Calendar getDate() {
+        return (Calendar) value.clone();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DateValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>DoubleValue</code> class implements the committed value state for
+ * Double values as a part of the State design pattern (Gof) used by this
+ * package. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Jukka Zitting
+ * @since 0.16.4.1
+ * 
+ * @see org.apache.jackrabbit.value.SerialValue
+ */
+public class DoubleValue extends BaseNonStreamValue {
+
+    /** The double value */
+    private final double value;
+
+    /**
+     * Creates an instance for the given double <code>value</code>.
+     */
+    protected DoubleValue(double value) {
+        this.value = value;
+    }
+
+    /**
+     * Creates an instance for the given string representation of a double.
+     * <p>
+     * This implementation uses the <code>Double.valueOf(String)</code> method
+     * to convert the string to a double.
+     * 
+     * @throws ValueFormatException if the string <code>value</code> cannot be
+     *      parsed to double.
+     */
+    protected DoubleValue(String value) throws ValueFormatException {
+        this(toDouble(value));
+    }
+
+    /**
+     * Returns the double value represented by the string <code>value</code>.
+     * 
+     * @throws ValueFormatException if the string <code>value</code> cannot be
+     *      parsed to double.
+     */
+    protected static double toDouble(String value) throws ValueFormatException {
+        try {
+            return Double.valueOf(value).doubleValue();
+        } catch (NumberFormatException e) {
+            throw new ValueFormatException(e);
+        }
+    }
+
+    /**
+     * Returns <code>PropertyType.DOUBLE</code>.
+     */
+    public int getType() {
+        return PropertyType.DOUBLE;
+    }
+
+    /**
+     * Returns a <code>Calendar</code> instance interpreting the double as the
+     * time in milliseconds since the epoch (1.1.1970, 0:00, UTC). 
+     */
+    public Calendar getDate() throws ValueFormatException {
+        Calendar date = Calendar.getInstance();
+        date.setTimeInMillis((long) value);
+        return date;
+    }
+    
+    /**
+     * Returns the double value.
+     */
+    public double getDouble() {
+        return value;
+    }
+
+    /**
+     * Returns the double as a string converted by the
+     * <code>Double.toString(double)</code>.
+     */
+    public String getString() {
+        return Double.toString(value);
+    }
+
+    /**
+     * Returns the value converted to a long.
+     */
+    public long getLong() {
+        return (long) value;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/DoubleValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+
+/**
+ * Initial value state. This class implements the non-committed
+ * value state as a part of the State design pattern (GoF) used
+ * by this package. The value getters of this class perform the
+ * stream/non-stream state transition by changing the state
+ * reference of the containing {@link SerialValue SerialValue}
+ * instance. Once the state change is complete (and the InitialValue
+ * state is no longer referenced by the SerialValue instance), the
+ * calling SerialValue getter method is restarted to get the actual
+ * underlying value.
+ *
+ * @see SerialValue
+ */
+final class InitialValue implements StatefullValue {
+
+    /** The containing general value instance. */
+    private final SerialValue general;
+
+    /** The underlying concrete value instance. */
+    private final StatefullValue value;
+
+    /**
+     * Creates an initial value state instance.
+     *
+     * @param general containing general value
+     * @param value   underlying concrete value
+     */
+    InitialValue(SerialValue general, StatefullValue value) {
+        this.general = general;
+        this.value = value;
+    }
+
+    /**
+     * Converts the given binary stream to a string. This utility method
+     * is used to convert stream values to non-stream values.
+     * <p>
+     * Note that a RepositoryException is thrown instead of a
+     * ValueFormatException if the stream can not be converted to a string.
+     * This is because the string constructor used does not report encoding
+     * problems.
+     *
+     * @param input binary stream
+     * @return string value
+     * @throws ValueFormatException if a stream decoding problem occurs
+     */
+    private static String toString(InputStream input) throws ValueFormatException, RepositoryException {
+        try {
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            byte[] buffer = new byte[4096];
+            for (int n = input.read(buffer); n != -1; n = input.read(buffer)) {
+                output.write(buffer, 0, n);
+            }
+            return new String(output.toByteArray(), "UTF-8");
+        } catch (IOException e) {
+            // Throwing a RepositoryException instead of a
+            // ValueFormatException because the problem is probably
+            // caused by some IO problem or another similar issue.
+            // The String(byte[], String) constructor does not report
+            // encoding problems. (TODO use a more detailed decoding mechanism)
+            throw new ValueFormatException(
+                    "Failed to convert from binary to string value", e);
+        }
+    }
+
+    /**
+     * Commits the value into the stream state and returns the stream
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return stream value
+     */
+    public InputStream getStream() throws ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() != PropertyType.BINARY) {
+            realValue = SerialValueFactory.getInstance().createBinaryValue(value.getString());
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getStream();
+    }
+
+    /**
+     * Commits the value into the non-stream state and returns the string
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return string value
+     * 
+     * @throws ValueFormatException if conversion to string is not possible
+     * @throws IllegalStateException not thrown by proper instances
+     * @throws RepositoryException if another error occurs
+     * @see Value#getString()
+     */
+    public String getString() throws ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() == PropertyType.BINARY) {
+            realValue = new StringValue(toString(value.getStream()));
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getString();
+    }
+
+    /**
+     * Commits the value into the non-stream state and returns the long
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return long value
+     * @throws ValueFormatException if conversion to long is not possible
+     * @throws IllegalStateException not thrown by proper instances
+     * @throws RepositoryException if another error occurs
+     * @see Value#getLong()
+     */
+    public long getLong() throws ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() == PropertyType.BINARY) {
+            realValue = SerialValueFactory.getInstance().createLongValue(toString(value.getStream()));
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getLong();
+    }
+
+    /**
+     * Commits the value into the non-stream state and returns the double
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return double value
+     * @throws ValueFormatException if conversion to double is not possible
+     * @throws IllegalStateException not thrown by proper instances
+     * @throws RepositoryException if another error occurs
+     * @see Value#getDouble()
+     */
+    public double getDouble() throws ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() == PropertyType.BINARY) {
+            realValue = SerialValueFactory.getInstance().createDoubleValue(toString(value.getStream()));
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getDouble();
+    }
+
+    /**
+     * Commits the value into the non-stream state and returns the date
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return date value
+     * @throws ValueFormatException if conversion to date is not possible
+     * @throws IllegalStateException not thrown by proper instances
+     * @throws RepositoryException if another error occurs
+     * @see Value#getDate()
+     */
+    public Calendar getDate() throws  ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() == PropertyType.BINARY) {
+            realValue = SerialValueFactory.getInstance().createDateValue(toString(value.getStream()));
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getDate();
+    }
+
+    /**
+     * Commits the value into the non-stream state and returns the long
+     * representation of the value. Implemented by changing the state
+     * reference of the containing general value and restarting the
+     * general value getter method.
+     *
+     * @return boolean value
+     * @throws ValueFormatException if conversion to boolean is not possible
+     * @throws IllegalStateException not thrown by proper instances
+     * @throws RepositoryException if another error occurs
+     * @see Value#getBoolean()
+     */
+    public boolean getBoolean() throws ValueFormatException, RepositoryException {
+        StatefullValue realValue;
+        if (getType() == PropertyType.BINARY) {
+            realValue = SerialValueFactory.getInstance().createBooleanValue(toString(value.getStream()));
+        } else {
+            realValue = value;
+        }
+        
+        general.setValue(realValue);
+        return realValue.getBoolean();
+    }
+
+    /**
+     * Returns the type of the underlying concrete value instance.
+     *
+     * @return value type
+     * @see PropertyType
+     * @see Value#getType()
+     */
+    public int getType() {
+        return value.getType();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/InitialValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+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. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Jukka Zitting
+ * @since 0.16.4.1
+ * 
+ * @see org.apache.jackrabbit.value.SerialValue
+ */
+public class LongValue extends BaseNonStreamValue {
+
+    /** The long value */
+    private final long value;
+
+    /**
+     * Creates an instance for the given long <code>value</code>.
+     */
+    protected 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() {
+        return PropertyType.LONG;
+    }
+
+    /**
+     * Returns a <code>Calendar</code> instance interpreting the long as the
+     * time in milliseconds since the epoch (1.1.1970, 0:00, UTC). 
+     */
+    public Calendar getDate() throws ValueFormatException {
+        Calendar date = Calendar.getInstance();
+        date.setTimeInMillis((long) value);
+        return date;
+    }
+    
+    /**
+     * Returns the double value.
+     */
+    public long getLong() {
+        return value;
+    }
+
+    /**
+     * Returns the long as a string converted by the
+     * <code>Long.toString(long)</code>.
+     */
+    public String getString() {
+        return Long.toString(value);
+    }
+
+    /**
+     * Returns the value converted to a double.
+     */
+    public double getDouble() {
+        return value;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/LongValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>NameValue</code> class implements the committed value state for
+ * Name values as a part of the State design pattern (Gof) used by this package. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Felix Meschberger
+ * @since 0.16.4.1
+ */
+public class NameValue extends BaseNonStreamValue {
+
+    /** The name value. */
+    private final String value;
+    
+    /**
+     * Creates an instance for the given name <code>value</code>.
+     */
+    protected NameValue(String value) throws ValueFormatException {
+        this.value = toName(value);
+    }
+    
+    /**
+     * Checks whether the string value adheres to the name syntax.
+     * 
+     * @param value The string to check for synthactical compliance with a
+     *      name value.
+     * 
+     * @return The input value.
+     * 
+     * @throws ValueFormatException if the string <code>value</code> is not a
+     *      synthactically correct name.
+     */
+    protected static String toName(String value) throws ValueFormatException {
+        // TODO: check syntax
+        return value;
+    }
+
+    /**
+     * Returns <code>PropertyType.NAME</code>.
+     */
+    public int getType() {
+        return PropertyType.NAME;
+    }
+
+    /**
+     * Returns the string representation of the Name value.
+     */
+    public String getString() throws ValueFormatException, RepositoryException {
+        return value;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/NameValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>PathValue</code> class implements the committed value state for
+ * Path values as a part of the State design pattern (Gof) used by this package. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Felix Meschberger
+ * @since 0.16.4.1
+ */
+public class PathValue extends BaseNonStreamValue {
+
+    /** The path value. */
+    private final String value;
+    
+    /**
+     * Creates an instance for the given path <code>value</code>.
+     */
+    protected PathValue(String value) throws ValueFormatException {
+        this.value = toPath(value);
+    }
+    
+    /**
+     * Checks whether the string value adheres to the path syntax.
+     * 
+     * @param value The string to check for synthactical compliance with a
+     *      path value.
+     * 
+     * @return The input value.
+     * 
+     * @throws ValueFormatException if the string <code>value</code> is not a
+     *      synthactically correct path.
+     */
+    protected static String toPath(String value) throws ValueFormatException {
+        // TODO: check syntax
+        return value;
+    }
+
+    /**
+     * Returns <code>PropertyType.PATH</code>.
+     */
+    public int getType() {
+        return PropertyType.PATH;
+    }
+
+    /**
+     * Returns the string representation of the path value.
+     */
+    public String getString() throws ValueFormatException, RepositoryException {
+        return value;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/PathValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/ReferenceValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/ReferenceValue.java?rev=169297&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/ReferenceValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/ReferenceValue.java Mon May  9 04:55:17 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.value;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+
+/**
+ * The <code>ReferenceValue</code> class implements the committed value state
+ * for Reference values as a part of the State design pattern (Gof) used by
+ * this package. 
+ * 
+ * @version $Revision$, $Date$
+ * @author Felix Meschberger
+ * @since 0.16.4.1
+ */
+public class ReferenceValue extends BaseNonStreamValue {
+
+    /** The reference value */
+    private final String value;
+    
+    /**
+     * Creates an instance for the given reference <code>value</code>.
+     */
+    protected ReferenceValue(String value) throws ValueFormatException {
+        this.value = toReference(value);
+    }
+    
+    /**
+     * Checks whether the string value adheres to the reference syntax.
+     * 
+     * @param value The string to check for synthactical compliance with a
+     *      reference value.
+     * 
+     * @return The input value.
+     * 
+     * @throws ValueFormatException if the string <code>value</code> is not a
+     *      synthactically correct reference.
+     */
+    protected static String toReference(String value) throws ValueFormatException {
+        // TODO: check syntax
+        return value;
+    }
+
+    /**
+     * Returns <code>PropertyType.REFERENCE</code>.
+     */
+    public int getType() {
+        return PropertyType.REFERENCE;
+    }
+
+    /**
+     * Returns the string representation of the reference value.
+     */
+    public String getString() throws ValueFormatException, RepositoryException {
+        return value;
+    }
+}