jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r497035 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
Date Wed, 17 Jan 2007 15:02:33 GMT
Author: angela
Date: Wed Jan 17 07:02:32 2007
New Revision: 497035

URL: http://svn.apache.org/viewvc?view=rev&rev=497035
Log:
work in progress

- minor improvement. add utility that allows to logout Status in human readable form


Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java?view=diff&rev=497035&r1=497034&r2=497035
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
Wed Jan 17 07:02:32 2007
@@ -16,7 +16,7 @@
 /**
  * <code>Status</code>...
  */
-public class Status {
+public final class Status {
 
     /**
      * A state once read from persistent storage has been set to invalid. This
@@ -64,6 +64,18 @@
      */
     public static final int REMOVED = 8;
 
+    private static final String[] STATUS_NAMES = new String[] {
+        "INVALIDATED",
+        "EXISTING",
+        "EXISTING_MODIFIED",
+        "EXISTING_REMOVED",
+        "NEW",
+        "STALE_MODIFIED",
+        "STALE_DESTROYED",
+        "MODIFIED",
+        "REMOVED"
+    };
+
     /**
      * Returns <code>true</code> if the given status is a terminal status, i.e.
      * the given status one of:
@@ -202,5 +214,16 @@
             }
         }
         return isValid;
+    }
+
+    /**
+     * @param status A valid status constant.
+     * @return Human readable status name for the given int.
+     */
+    public static String getName(int status) {
+        if (status < 0 || status >= STATUS_NAMES.length) {
+            throw new IllegalArgumentException("Invalid status " + status);
+        }
+        return STATUS_NAMES[status];
     }
 }



Mime
View raw message