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/22 16:53:51 UTC

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

Author: hwright
Date: Mon Mar 22 15:53:51 2010
New Revision: 926148

URL: http://svn.apache.org/viewvc?rev=926148&view=rev
Log:
JavaHL: Enum'ify the ScheduleKind class (used in the Info2 class).

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java:
  Update tests to use the Info2.ScheduleKind enum.

* native/CreateJ.cpp
  (Info, Info2): Update constructor references, and use the enum mapper to
    create the proper Java object.

* native/EnumMapper.h,
  native/EnumMapper.cpp
  (mapScheduleKind): Reimplement to return the correct java enum object.

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

* src/org/apache/subversion/javahl/Info2.java
  (schedule, Info2, getSchedule): Update schedule types.
  (ScheduleKind): New.

* src/org/apache/subversion/javahl/Info.java
  (schedule, Info, getSchedule): Update schedule types.

* src/org/tigris/subversion/javahl/Info2.java
  (Info2): Update wrapper.

* src/org/tigris/subversion/javahl/Info.java
  (Info): Same.

Removed:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ScheduleKind.java
Modified:
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info2.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info2.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Mon Mar 22 15:53:51 2010
@@ -191,7 +191,8 @@ CreateJ::Info(const svn_wc_entry_t *entr
     {
         mid = env->GetMethodID(clazz, "<init>",
                                "(Ljava/lang/String;Ljava/lang/String;"
-                               "Ljava/lang/String;Ljava/lang/String;I"
+                               "Ljava/lang/String;Ljava/lang/String;"
+                               "L"JAVA_PACKAGE"/Info2$ScheduleKind;"
                                "L"JAVA_PACKAGE"/NodeKind;"
                                "Ljava/lang/String;JJLjava/util/Date;"
                                "Ljava/util/Date;Ljava/util/Date;"
@@ -212,7 +213,9 @@ CreateJ::Info(const svn_wc_entry_t *entr
   jstring jRepository = JNIUtil::makeJString(entry->repos);
   if (JNIUtil::isJavaExceptionThrown())
     POP_AND_RETURN_NULL;
-  jint jSchedule = EnumMapper::mapScheduleKind(entry->schedule);
+  jobject jSchedule = EnumMapper::mapScheduleKind(entry->schedule);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
   jobject jNodeKind = EnumMapper::mapNodeKind(entry->kind);
   if (JNIUtil::isJavaExceptionThrown())
     POP_AND_RETURN_NULL;
@@ -273,8 +276,9 @@ CreateJ::Info2(const char *path, const s
                              "L"JAVA_PACKAGE"/NodeKind;"
                              "Ljava/lang/String;Ljava/lang/String;"
                              "JJLjava/lang/String;"
-                             "L"JAVA_PACKAGE"/Lock;"
-                             "ZILjava/lang/String;JJJ"
+                             "L"JAVA_PACKAGE"/Lock;Z"
+                             "L"JAVA_PACKAGE"/Info2$ScheduleKind;"
+                             "Ljava/lang/String;JJJ"
                              "Ljava/lang/String;Ljava/lang/String;"
                              "Ljava/lang/String;Ljava/lang/String;"
                              "Ljava/lang/String;Ljava/lang/String;JJ"
@@ -345,6 +349,10 @@ CreateJ::Info2(const char *path, const s
   if (JNIUtil::isJavaExceptionThrown())
     POP_AND_RETURN_NULL;
 
+  jobject jscheduleKind = EnumMapper::mapScheduleKind(info->schedule);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
   jlong jworkingSize = info->working_size == SVN_INFO_SIZE_UNKNOWN
     ? -1 : (jlong) info->working_size;
   jlong jreposSize = info->size == SVN_INFO_SIZE_UNKNOWN
@@ -356,8 +364,8 @@ CreateJ::Info2(const char *path, const s
                                   (jlong) info->last_changed_date,
                                   jlastChangedAuthor, jlock,
                                   info->has_wc_info ? JNI_TRUE : JNI_FALSE,
-                                  EnumMapper::mapScheduleKind(info->schedule),
-                                  jcopyFromUrl, (jlong) info->copyfrom_rev,
+                                  jscheduleKind, jcopyFromUrl,
+                                  (jlong) info->copyfrom_rev,
                                   (jlong) info->text_time,
                                   (jlong) info->prop_time, jchecksum,
                                   jconflictOld, jconflictNew, jconflictWrk,

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp Mon Mar 22 15:53:51 2010
@@ -33,7 +33,6 @@
 #include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
 #include "../include/org_apache_subversion_javahl_Operation.h"
 #include "../include/org_apache_subversion_javahl_Revision.h"
-#include "../include/org_apache_subversion_javahl_ScheduleKind.h"
 
 /**
  * Map a C commit state flag constant to the Java constant.
@@ -99,32 +98,11 @@ jobject EnumMapper::mapNotifyLockState(s
 
 /**
  * Map a C wc schedule constant to the Java constant.
- * @param state     the C wc schedule constant
- * @returns the Java constant
  */
-jint EnumMapper::mapScheduleKind(svn_wc_schedule_t schedule)
+jobject EnumMapper::mapScheduleKind(svn_wc_schedule_t schedule)
 {
-  switch(schedule)
-    {
-      /** Nothing special here */
-    case svn_wc_schedule_normal:
-      return org_apache_subversion_javahl_ScheduleKind_normal;
-
-      /** Slated for addition */
-    case svn_wc_schedule_add:
-      return org_apache_subversion_javahl_ScheduleKind_add;
-
-      /** Slated for deletion */
-    case svn_wc_schedule_delete:
-      return org_apache_subversion_javahl_ScheduleKind_delete;
-
-      /** Slated for replacement (delete + add) */
-    case svn_wc_schedule_replace:
-      return org_apache_subversion_javahl_ScheduleKind_replace;
-
-    default:
-      return org_apache_subversion_javahl_ScheduleKind_normal;
-    }
+  // We're assuming a valid value for the C enum above
+  return mapEnum(JAVA_PACKAGE"/Info2$ScheduleKind", (int) schedule);
 }
 
 /**

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h Mon Mar 22 15:53:51 2010
@@ -54,7 +54,7 @@ class EnumMapper
   static jobject mapNodeKind(svn_node_kind_t nodeKind);
   static jobject mapNotifyLockState(svn_wc_notify_lock_state_t state);
   static jobject mapStatusKind(svn_wc_status_kind svnKind);
-  static jint mapScheduleKind(svn_wc_schedule_t schedule);
+  static jobject mapScheduleKind(svn_wc_schedule_t schedule);
   static jobject mapConflictKind(svn_wc_conflict_kind_t kind);
   static jobject mapConflictAction(svn_wc_conflict_action_t action);
   static jobject mapConflictReason(svn_wc_conflict_reason_t reason);

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info.java?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info.java Mon Mar 22 15:53:51 2010
@@ -53,7 +53,7 @@ public class Info implements java.io.Ser
     private String repository;
 
     /** the schedule on the next commit (see NodeKind) */
-    private int schedule;
+    private Info2.ScheduleKind schedule;
 
     /** the kind of node (file or directory or unknown */
     private NodeKind nodeKind;
@@ -114,8 +114,8 @@ public class Info implements java.io.Ser
      * @param copyUrl               copy source url
      */
     public Info(String name, String url, String uuid, String repository,
-         int schedule, NodeKind nodeKind, String author, long revision,
-         long lastChangedRevision, Date lastChangedDate,
+         Info2.ScheduleKind schedule, NodeKind nodeKind, String author,
+         long revision, long lastChangedRevision, Date lastChangedDate,
          Date lastDateTextUpdate, Date lastDatePropsUpdate, boolean copied,
          boolean deleted, boolean absent, boolean incomplete, long copyRev,
          String copyUrl)
@@ -180,7 +180,7 @@ public class Info implements java.io.Ser
      * Retrieves the schedule of the next commit
      * @return schedule of the next commit
      */
-    public int getSchedule()
+    public Info2.ScheduleKind getSchedule()
     {
         return schedule;
     }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info2.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info2.java?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info2.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Info2.java Mon Mar 22 15:53:51 2010
@@ -97,9 +97,9 @@ public class Info2 implements java.io.Se
     private boolean hasWcInfo;
 
     /**
-     * the scheduled operation at next commit (see ScheduleKind)
+     * the scheduled operation at next commit
      */
-    private int schedule;
+    private ScheduleKind schedule;
 
     /**
      * if the item was copied, the source url
@@ -213,11 +213,11 @@ public class Info2 implements java.io.Se
     public Info2(String path, String url, long rev, NodeKind kind,
           String reposRootUrl, String reposUUID, long lastChangedRev,
           long lastChangedDate, String lastChangedAuthor, Lock lock,
-          boolean hasWcInfo, int schedule, String copyFromUrl, long copyFromRev,
-          long textTime, long propTime, String checksum, String conflictOld,
-          String conflictNew, String conflictWrk, String prejfile,
-          String changelistName, long workingSize, long reposSize, Depth depth,
-          ConflictDescriptor treeConflict)
+          boolean hasWcInfo, ScheduleKind schedule, String copyFromUrl,
+          long copyFromRev, long textTime, long propTime, String checksum,
+          String conflictOld, String conflictNew, String conflictWrk,
+          String prejfile, String changelistName, long workingSize,
+          long reposSize, Depth depth, ConflictDescriptor treeConflict)
     {
         this.path = path;
         this.url = url;
@@ -341,7 +341,7 @@ public class Info2 implements java.io.Se
     /**
      * return the scheduled operation at next commit (see ScheduleKind)
      */
-    public int getSchedule()
+    public ScheduleKind getSchedule()
     {
         return schedule;
     }
@@ -484,4 +484,19 @@ public class Info2 implements java.io.Se
     {
         return getUrl();
     }
+
+    public enum ScheduleKind
+    {
+        /** exists, but uninteresting */
+        normal,
+
+        /** Slated for addition */
+        add,
+
+        /** Slated for deletion */
+        delete,
+
+        /** Slated for replacement (delete + add) */
+        replace;
+    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info.java?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info.java Mon Mar 22 15:53:51 2010
@@ -146,7 +146,7 @@ public class Info implements java.io.Ser
     public Info(org.apache.subversion.javahl.Info aInfo)
     {
         this(aInfo.getName(), aInfo.getUrl(), aInfo.getUuid(),
-             aInfo.getRepository(), aInfo.getSchedule(),
+             aInfo.getRepository(), aInfo.getSchedule().ordinal(),
              NodeKind.fromApache(aInfo.getNodeKind()),
              aInfo.getAuthor(), aInfo.getRevision(),
              aInfo.getLastChangedRevision(), aInfo.getLastChangedDate(),

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info2.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info2.java?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info2.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Info2.java Mon Mar 22 15:53:51 2010
@@ -260,8 +260,8 @@ public class Info2 implements java.io.Se
                 : aInfo.getLastChangedDate().getTime() * 1000,
              aInfo.getLastChangedAuthor(),
              aInfo.getLock() == null ? null : new Lock(aInfo.getLock()),
-             aInfo.isHasWcInfo(), aInfo.getSchedule(), aInfo.getCopyFromUrl(),
-             aInfo.getCopyFromRev(),
+             aInfo.isHasWcInfo(), aInfo.getSchedule().ordinal(),
+             aInfo.getCopyFromUrl(), aInfo.getCopyFromRev(),
              aInfo.getTextTime() == null ? 0
                 : aInfo.getTextTime().getTime() * 1000,
              aInfo.getPropTime() == null ? 0

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=926148&r1=926147&r2=926148&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java (original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java Mon Mar 22 15:53:51 2010
@@ -2099,8 +2099,8 @@ public class BasicTests extends SVNTests
                                   Depth.empty, null)[0];
         assertEquals("wrong revision from info", 1,
                      info.getLastChangedRev());
-        assertEquals("wrong schedule kind from info", ScheduleKind.normal,
-                     info.getSchedule());
+        assertEquals("wrong schedule kind from info",
+                     Info2.ScheduleKind.normal, info.getSchedule());
         assertEquals("wrong node kind from info", NodeKind.file,
                      info.getKind());
     }