]> git.argeo.org Git - gpl/argeo-jcr.git/blobdiff - org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java
Document JCRX API
[gpl/argeo-jcr.git] / org.argeo.cms.jcr / src / org / argeo / jcr / Jcr.java
index 49b008d70751e24e4f362c9e5e2b9caab66f06cc..88f534503d5a142e5a4d87d4deec57a0e5c24979 100644 (file)
@@ -49,11 +49,15 @@ public class Jcr {
        /**
         * The name of a node which will be serialized as XML text, as per section 7.3.1
         * of the JCR 2.0 specifications.
+        * 
+        * @see Workspace#NAME_JCR_XMLTEXT
         */
        public final static String JCR_XMLTEXT = "jcr:xmltext";
        /**
         * The name of a property which will be serialized as XML text, as per section
         * 7.3.1 of the JCR 2.0 specifications.
+        * 
+        * @see Workspace#NAME_JCR_XMLCHARACTERS
         */
        public final static String JCR_XMLCHARACTERS = "jcr:xmlcharacters";
        /**
@@ -609,6 +613,23 @@ public class Jcr {
                }
        }
 
+       /**
+        * Retrieve a {@link PropertyType#DATE} property as an {@link Instant}.
+        * 
+        * @return the property value, or <code>null</code> if not found.
+        */
+       public static Instant getAsInstant(Node node, String property) {
+               try {
+                       if (!node.hasProperty(property))
+                               return null;
+                       Calendar calendar = node.getProperty(property).getDate();
+                       return calendar.getTime().toInstant();
+               } catch (RepositoryException e) {
+                       throw new JcrException("Cannot get property " + property + " of " + node + " as an instant.", e);
+               }
+
+       }
+
        /**
         * Get a multiple property as a list, doing a best effort to cast it as the
         * target list.