You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/03/18 21:32:10 UTC

svn commit: r924982 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/

Author: hwright
Date: Thu Mar 18 20:32:10 2010
New Revision: 924982

URL: http://svn.apache.org/viewvc?rev=924982&view=rev
Log:
JavaHL: Enum-ize the NotifyStatus type.

[ in subversion/bindings/javahl/ ]
* native/EnumMapper.h,
  native/EnumMapper.cpp
  (mapNotifyState): Update to return the Java object.

* native/NotifyCallback.cpp
  (onNotify): Update the types of the content and prop states when building the
    return object.

* src/org/apache/subversion/javahl/NotifyStatus.java:
  Remove.

* src/org/apache/subversion/javahl/NotifyInformation.java:
  (NotifyInformation): Use the new Status type.
  (Status): New enum type.

* src/org/tigris/subversion/javahl/NotifyInformation.java
  (fromAStatus): New.

Removed:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyStatus.java
Modified:
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
    subversion/trunk/subversion/bindings/javahl/native/NotifyCallback.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyInformation.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NotifyInformation.java

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp?rev=924982&r1=924981&r2=924982&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp Thu Mar 18 20:32:10 2010
@@ -31,7 +31,6 @@
 #include "JNIUtil.h"
 #include "JNIStringHolder.h"
 #include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
-#include "../include/org_apache_subversion_javahl_NotifyStatus.h"
 #include "../include/org_apache_subversion_javahl_Operation.h"
 #include "../include/org_apache_subversion_javahl_LockStatus.h"
 #include "../include/org_apache_subversion_javahl_Revision.h"
@@ -71,34 +70,34 @@ jint EnumMapper::mapCommitMessageStateFl
  * @param state     the C notify state constant
  * @returns the Java constant
  */
-jint EnumMapper::mapNotifyState(svn_wc_notify_state_t state)
+jobject EnumMapper::mapNotifyState(svn_wc_notify_state_t state)
 {
   switch(state)
     {
     default:
     case svn_wc_notify_state_inapplicable:
-      return org_apache_subversion_javahl_NotifyStatus_inapplicable;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "inapplicable");
 
     case svn_wc_notify_state_unknown:
-      return org_apache_subversion_javahl_NotifyStatus_unknown;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "unknown");
 
     case svn_wc_notify_state_unchanged:
-      return org_apache_subversion_javahl_NotifyStatus_unchanged;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "unchanged");
 
     case svn_wc_notify_state_missing:
-      return org_apache_subversion_javahl_NotifyStatus_missing;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "missing");
 
     case svn_wc_notify_state_obstructed:
-      return org_apache_subversion_javahl_NotifyStatus_obstructed;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "obstructed");
 
     case svn_wc_notify_state_changed:
-      return org_apache_subversion_javahl_NotifyStatus_changed;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "changed");
 
     case svn_wc_notify_state_merged:
-      return org_apache_subversion_javahl_NotifyStatus_merged;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "merged");
 
     case svn_wc_notify_state_conflicted:
-      return org_apache_subversion_javahl_NotifyStatus_conflicted;
+      return mapEnum(JAVA_PACKAGE"/NotifyInformation$Status", "conflicted");
     }
 
 }

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h?rev=924982&r1=924981&r2=924982&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h Thu Mar 18 20:32:10 2010
@@ -47,7 +47,7 @@ class EnumMapper
 
   /* Converting from C enum's */
   static jint mapCommitMessageStateFlags(apr_byte_t flags);
-  static jint mapNotifyState(svn_wc_notify_state_t state);
+  static jobject mapNotifyState(svn_wc_notify_state_t state);
   static jobject mapNotifyAction(svn_wc_notify_action_t action);
   static jobject mapNodeKind(svn_node_kind_t nodeKind);
   static jint mapNotifyLockState(svn_wc_notify_lock_state_t state);

Modified: subversion/trunk/subversion/bindings/javahl/native/NotifyCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/NotifyCallback.cpp?rev=924982&r1=924981&r2=924982&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/NotifyCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/NotifyCallback.cpp Thu Mar 18 20:32:10 2010
@@ -147,7 +147,10 @@ NotifyCallback::onNotify(const svn_wc_no
                                "L"JAVA_PACKAGE"/NotifyInformation$Action;"
                                "L"JAVA_PACKAGE"/NodeKind;Ljava/lang/String;"
                                "L"JAVA_PACKAGE"/Lock;"
-                               "Ljava/lang/String;IIIJLjava/lang/String;"
+                               "Ljava/lang/String;"
+                               "L"JAVA_PACKAGE"/NotifyInformation$Status;"
+                               "L"JAVA_PACKAGE"/NotifyInformation$Status;"
+                               "IJLjava/lang/String;"
                                "L"JAVA_PACKAGE"/RevisionRange;"
                                "Ljava/lang/String;)V");
       if (JNIUtil::isJavaExceptionThrown() || midCT == 0)
@@ -179,8 +182,14 @@ NotifyCallback::onNotify(const svn_wc_no
   if (JNIUtil::isJavaExceptionThrown())
     return;
 
-  jint jContentState = EnumMapper::mapNotifyState(wcNotify->content_state);
-  jint jPropState = EnumMapper::mapNotifyState(wcNotify->prop_state);
+  jobject jContentState = EnumMapper::mapNotifyState(wcNotify->content_state);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
+  jobject jPropState = EnumMapper::mapNotifyState(wcNotify->prop_state);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
   jint jLockState = EnumMapper::mapNotifyLockState(wcNotify->lock_state);
 
   jstring jChangelistName = JNIUtil::makeJString(wcNotify->changelist_name);
@@ -217,6 +226,14 @@ NotifyCallback::onNotify(const svn_wc_no
   if (JNIUtil::isJavaExceptionThrown())
     return;
 
+  env->DeleteLocalRef(jPropState);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
+  env->DeleteLocalRef(jContentState);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
   env->DeleteLocalRef(jKind);
   if (JNIUtil::isJavaExceptionThrown())
     return;

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyInformation.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyInformation.java?rev=924982&r1=924981&r2=924982&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyInformation.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/NotifyInformation.java Thu Mar 18 20:32:10 2010
@@ -70,12 +70,12 @@ public class NotifyInformation extends E
     /**
      * The {@link NotifyStatus} of the content of the item.
      */
-    private int contentState;
+    private Status contentState;
 
     /**
      * The {@link NotifyStatus} of the properties of the item.
      */
-    private int propState;
+    private Status propState;
 
     /**
      * The {@link LockStatus} of the lock of the item.
@@ -126,9 +126,10 @@ public class NotifyInformation extends E
      */
     public NotifyInformation(String path, Action action, NodeKind kind,
                              String mimeType, Lock lock, String errMsg,
-                             int contentState, int propState, int lockState,
-                             long revision, String changelistName,
-                             RevisionRange mergeRange, String pathPrefix)
+                             Status contentState, Status propState,
+                             int lockState, long revision,
+                             String changelistName, RevisionRange mergeRange,
+                             String pathPrefix)
     {
         super(path == null ? "" : path);
         this.action = action;
@@ -196,7 +197,7 @@ public class NotifyInformation extends E
     /**
      * @return The {@link NotifyStatus} of the content of the item.
      */
-    public int getContentState()
+    public Status getContentState()
     {
         return contentState;
     }
@@ -204,7 +205,7 @@ public class NotifyInformation extends E
     /**
      * @return The {@link NotifyStatus} of the properties of the item.
      */
-    public int getPropState()
+    public Status getPropState()
     {
         return propState;
     }
@@ -450,4 +451,45 @@ public class NotifyInformation extends E
         }
     }
 
+    public enum Status
+    {
+        /** It not applicable*/
+        inapplicable    ("inapplicable"),
+
+        /** Notifier doesn't know or isn't saying. */
+        unknown         ("unknown"),
+
+        /** The state did not change. */
+        unchanged       ("unchanged"),
+
+        /** The item wasn't present. */
+        missing         ("missing"),
+
+        /** An unversioned item obstructed work. */
+        obstructed      ("obstructed"),
+
+        /** Pristine state was modified. */
+        changed         ("changed"),
+
+        /** Modified state had mods merged in. */
+        merged          ("merged"),
+
+        /** Modified state got conflicting mods. */
+        conflicted      ("conflicted");
+
+        /**
+         * The description of the action.
+         */
+        private String description;
+
+        Status(String description)
+        {
+            this.description = description;
+        }
+
+        public String toString()
+        {
+            return description;
+        }
+    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NotifyInformation.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NotifyInformation.java?rev=924982&r1=924981&r2=924982&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NotifyInformation.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/NotifyInformation.java Thu Mar 18 20:32:10 2010
@@ -155,7 +155,8 @@ public class NotifyInformation extends E
              aInfo.getAction() == null ? -1 : aInfo.getAction().ordinal(),
              NodeKind.fromApache(aInfo.getKind()), aInfo.getMimeType(),
              aInfo.getLock() == null ? null : new Lock(aInfo.getLock()),
-             aInfo.getErrMsg(), aInfo.getContentState(), aInfo.getPropState(),
+             aInfo.getErrMsg(), fromAStatus(aInfo.getContentState()),
+             fromAStatus(aInfo.getPropState()),
              aInfo.getLockState(), aInfo.getRevision(),
              aInfo.getChangelistName(),
              aInfo.getMergeRange() == null ? null
@@ -269,4 +270,29 @@ public class NotifyInformation extends E
     {
         return pathPrefix;
     }
+
+    private static int
+    fromAStatus(org.apache.subversion.javahl.NotifyInformation.Status aStatus)
+    {
+        switch(aStatus)
+        {
+        default:
+        case inapplicable:
+            return NotifyStatus.inapplicable;
+        case unknown:
+            return NotifyStatus.unknown;
+        case unchanged:
+            return NotifyStatus.unchanged;
+        case missing:
+            return NotifyStatus.missing;
+        case obstructed:
+            return NotifyStatus.obstructed;
+        case changed:
+            return NotifyStatus.changed;
+        case merged:
+            return NotifyStatus.merged;
+        case conflicted:
+            return NotifyStatus.conflicted;
+        }
+    }
 }