incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r290782 - /incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
Date Wed, 21 Sep 2005 18:43:10 GMT
Author: clombart
Date: Wed Sep 21 11:43:06 2005
New Revision: 290782

URL: http://svn.apache.org/viewcvs?rev=290782&view=rev
Log:
Add TimeStampTypeConverter

Modified:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java?rev=290782&r1=290781&r2=290782&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
Wed Sep 21 11:43:06 2005
@@ -17,6 +17,7 @@
 package org.apache.portals.graffito.jcr.persistence.atomictypeconverter;
 
 import java.io.InputStream;
+import java.sql.Timestamp;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
@@ -300,6 +301,43 @@
             return javaTypes;
         }
     };
+    
+    private AtomicTypeConverter timeStampTypeConverter = new AtomicTypeConverter()
+    {
+        public String getPropertyType()
+        {
+            return PropertyType.TYPENAME_LONG;
+        }
+
+        public Value getJcrValueFromJavaObject(Object propValue)
+        {
+            if (propValue == null)
+                return null;
+            long value = ((Timestamp) propValue).getTime();
+            return this.getValueFactory().createValue(value);
+        }
+
+        public Object getJavaObjectFromJcr(Node node, String jcrPropName) throws ValueFormatException,
PathNotFoundException,
+                RepositoryException
+        {
+            if (node.hasProperty(jcrPropName) == true)
+            {
+                long beanPropValue = node.getProperty(jcrPropName).getLong();
+                return new Timestamp(beanPropValue);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        public Class[] getJavaTypes()
+        {
+            Class[] javaTypes = { Timestamp.class };
+            return javaTypes;
+        }
+    };
+    
 
     private AtomicTypeConverter booleanTypeConverter = new AtomicTypeConverter()
     {
@@ -393,6 +431,7 @@
         this.registerTypeConverter(calendarTypeConverter);
         this.registerTypeConverter(utilDateTypeConverter);
         this.registerTypeConverter(byteArrayConverter);
+        this.registerTypeConverter(timeStampTypeConverter);
     }
 
     public void registerTypeConverter(AtomicTypeConverter converter)



Mime
View raw message