Author: tmortagne
Date: 2007-10-15 16:07:26 +0200 (Mon, 15 Oct 2007)
New Revision: 5394

Modified:
   
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
Log:
- Add get/setIntValue to DefaultSuperDocument
- Add get/setBooleanValue to DefaultSuperDocument that take care of 
int->Boolean conversions : 1=Boolean.TRUE, 0=Boolean.FALSE and anything 
else=null

Modified: 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
===================================================================
--- 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
     2007-10-15 13:30:18 UTC (rev 5393)
+++ 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
     2007-10-15 14:07:26 UTC (rev 5394)
@@ -41,6 +41,21 @@
 public class DefaultSuperDocument extends Document implements SuperDocument
 {
     /**
+     * Value in int for [EMAIL PROTECTED] Boolean#TRUE}.
+     */
+    private static final int BOOLEANFIELD_TRUE = 1;
+
+    /**
+     * Value in int for [EMAIL PROTECTED] Boolean#FALSE}.
+     */
+    private static final int BOOLEANFIELD_FALSE = 0;
+    
+    /**
+     * Value in int for [EMAIL PROTECTED] Boolean} = null.
+     */
+    private static final int BOOLEANFIELD_MAYBE = 2;
+
+    /**
      * The class manager for this document.
      */
     protected SuperClass sclass;
@@ -270,4 +285,64 @@
     {
         getDoc().setStringListValue(this.sclass.getClassFullName(), fieldName, 
value);
     }
+
+    /**
+     * Get the value of the field <code>fieldName</code> of the class 
"XWikiApplicationClass".
+     * 
+     * @param fieldName the name of the field from the class 
"XWikiApplicationClass" where to find
+     *            the value.
+     * @return the value in int of the field <code>fieldName</code> of the 
class
+     *         "XWikiApplicationClass".
+     * @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String)
+     */
+    public int getIntValue(String fieldName)
+    {
+        return this.doc.getIntValue(this.sclass.getClassFullName(), fieldName);
+    }
+
+    /**
+     * Modify the value of the field <code>fieldName</code> of the class 
"XWikiApplicationClass".
+     * 
+     * @param fieldName the name of the field from the class 
"XWikiApplicationClass" where to find
+     *            the value.
+     * @param value the new value of the field <code>fieldName</code> of the 
class
+     *            "XWikiApplicationClass".
+     * @see com.xpn.xwiki.doc.XWikiDocument#setIntValue(String, String, int)
+     */
+    public void setIntValue(String fieldName, int value)
+    {
+        getDoc().setIntValue(this.sclass.getClassFullName(), fieldName, value);
+    }
+
+    /**
+     * Get the value of the field <code>fieldName</code> of the class 
"XWikiApplicationClass".
+     * 
+     * @param fieldName the name of the field from the class 
"XWikiApplicationClass" where to find
+     *            the value.
+     * @return the value in [EMAIL PROTECTED] Boolean} of the field 
<code>fieldName</code> of the class
+     *         "XWikiApplicationClass".
+     * @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String)
+     */
+    public Boolean getBooleanValue(String fieldName)
+    {
+        int intValue = getIntValue(fieldName);
+
+        return intValue == BOOLEANFIELD_TRUE ? Boolean.TRUE : (intValue == 
BOOLEANFIELD_FALSE
+            ? Boolean.FALSE : null);
+    }
+
+    /**
+     * Modify the value of the field <code>fieldName</code> of the class 
"XWikiApplicationClass".
+     * 
+     * @param fieldName the name of the field from the class 
"XWikiApplicationClass" where to find
+     *            the value.
+     * @param value the new value of the field <code>fieldName</code> of the 
class
+     *            "XWikiApplicationClass".
+     * @see com.xpn.xwiki.doc.XWikiDocument#setIntValue(String, String, int)
+     */
+    public void setBooleanValue(String fieldName, Boolean value)
+    {
+        setIntValue(fieldName, value == null ? BOOLEANFIELD_MAYBE : 
(value.booleanValue()
+            ? BOOLEANFIELD_TRUE : BOOLEANFIELD_FALSE));
+    }
 }

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to