Start integrating GCR and JCR (not yet working)
[lgpl/argeo-commons.git] / org.argeo.cms.jcr / src / org / argeo / jcr / Jcr.java
index 72e325d35a40c40ad22a712ae7561fd33ae6ed87..bf5de1260f93e11bb2b7d47baa31ea3e3eb8460b 100644 (file)
@@ -598,6 +598,16 @@ public class Jcr {
                        throw new JcrException("Cannot retrieve property " + property + " from " + node, e);
                }
        }
+       
+       public static <T> T getAs(Node node, String property, Class<T> clss) {
+               if(String.class.isAssignableFrom(clss)) {
+                       return (T)get(node,property);
+               }       else    if(Long.class.isAssignableFrom(clss)) {
+                       return (T)get(node,property);
+               }else {
+                       throw new IllegalArgumentException("Unsupported format "+clss);
+               }
+       }
 
        /**
         * Get a multiple property as a list, doing a best effort to cast it as the