Author: brane
Date: Tue Aug  6 11:33:44 2013
New Revision: 1510909

URL: http://svn.apache.org/r1510909
Log:
Add callback-based variants of the svn_ra_get_location_segments and
svn_ra_get_file_revs wrappers to JavaHL.

[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* callback/RemoteFileRevisionsCallback.java,
  callback/RemoteLocationSegmentsCallback.java: New interfaces.
* ISVNRemote.java (getLocationSegments, getFileRevisions): Added new
   overloads that drive their respective callbacks.
* remote/RemoteSession.java (getLocationSegments, getFileRevisions):
   Made the new overloads native, and implement the list-based ones in
   terms of the callback-based ones.

[in subversion/bindings/javahl/native]
* org_apache_subversion_javahl_remote_RemoteSession.cpp
  (Java_org_apache_subversion_javahl_remote_RemoteSession_getLocationSegments,
   Java_org_apache_subversion_javahl_remote_RemoteSession_getFileRevisions):
   Updated signatures and implementation of JNI wrappers.
* RemoteSession.h (getLocationSegments, getFileRevisions): Update prototypes.
* RemoteSession.cpp (getLocationSegments, getFileRevisions,
   LocationSegmentHandler, FileRevisionHandler): Update implementation.

Added:
    
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteFileRevisionsCallback.java
    
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteLocationSegmentsCallback.java
Modified:
    subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h
    
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
    
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
    
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java

Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1510909&r1=1510908&r2=1510909&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp 
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp Tue 
Aug  6 11:33:44 2013
@@ -1084,37 +1084,30 @@ public:
     {
       LocationSegmentHandler* const self =
         static_cast<LocationSegmentHandler*>(baton);
-      SVN_ERR_ASSERT(self->m_jresult_list != NULL);
-      self->add(segment);
+      SVN_ERR_ASSERT(self->m_jcallback != NULL);
+      self->call(segment);
       SVN_ERR(JNIUtil::checkJavaException(SVN_ERR_BASE));
       return SVN_NO_ERROR;
     }
 
-  LocationSegmentHandler()
-    : m_jresult_list(NULL)
+  LocationSegmentHandler(jobject jcallback)
+    : m_jcallback(jcallback),
+      m_call_mid(0)
     {
       JNIEnv* env = JNIUtil::getEnv();
-      jclass cls = env->FindClass("java/util/ArrayList");
+      jclass cls = env->GetObjectClass(jcallback);
       if (JNIUtil::isJavaExceptionThrown())
         return;
 
-      static jmethodID mid = 0;
-      if (mid == 0)
-        {
-          mid = env->GetMethodID(cls, "<init>", "()V");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-        }
-
-      jobject jresult_list = env->NewObject(cls, mid);
-      if (!JNIUtil::isJavaExceptionThrown() && jresult_list)
-        m_jresult_list = jresult_list;
+      m_call_mid = env->GetMethodID(cls, "doSegment",
+                                    "(L"JAVA_PACKAGE"/callback/"
+                                    "RemoteLocationSegmentCallback;)V");
+        if (JNIUtil::isJavaExceptionThrown())
+          return;
     }
 
-  jobject get() const { return m_jresult_list; }
-
 private:
-  void add(svn_location_segment_t* segment)
+  void call(svn_location_segment_t* segment)
     {
       JNIEnv* env = JNIUtil::getEnv();
       jclass cls = env->FindClass(JAVA_PACKAGE"/ISVNRemote$LocationSegment");
@@ -1130,57 +1123,45 @@ private:
             return;
         }
 
-      static jmethodID mid_add = 0;
-      if (mid_add == 0)
-        {
-          jclass list_cls = env->FindClass("java/util/ArrayList");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-          mid_add = env->GetMethodID(list_cls, "add",
-                                     "(Ljava/lang/Object;)Z");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-        }
-
       jstring jpath = JNIUtil::makeJString(segment->path);
       if (JNIUtil::isJavaExceptionThrown())
         return;
 
-      env->CallBooleanMethod(m_jresult_list, mid_add,
-                             env->NewObject(cls, mid, jpath,
-                                            jlong(segment->range_start),
-                                            jlong(segment->range_end)));
+      env->CallVoidMethod(m_jcallback, m_call_mid,
+                          env->NewObject(cls, mid, jpath,
+                                         jlong(segment->range_start),
+                                         jlong(segment->range_end)));
       if (JNIUtil::isJavaExceptionThrown())
         return;
       env->DeleteLocalRef(jpath);
     }
 
-  jobject m_jresult_list;
+  jobject m_jcallback;
+  jmethodID m_call_mid;
 };
 } // anonymous namespace
 
-jobject
+void
 RemoteSession::getLocationSegments(jstring jpath, jlong jpeg_revision,
-                                   jlong jstart_revision, jlong jend_revision)
+                                   jlong jstart_revision, jlong jend_revision,
+                                   jobject jcallback)
 {
   SVN::Pool subPool(pool);
   Relpath path(jpath, subPool);
   if (JNIUtil::isExceptionThrown())
-    return NULL;
-  SVN_JNI_ERR(path.error_occurred(), NULL);
+    return;
+  SVN_JNI_ERR(path.error_occurred(), );
 
-  LocationSegmentHandler handler;
+  LocationSegmentHandler handler(jcallback);
   if (JNIUtil::isExceptionThrown())
-    return NULL;
+    return ;
 
   SVN_JNI_ERR(svn_ra_get_location_segments(m_session, path.c_str(),
                                            svn_revnum_t(jpeg_revision),
                                            svn_revnum_t(jstart_revision),
                                            svn_revnum_t(jend_revision),
                                            handler.callback, &handler,
-                                           subPool.getPool()),
-              NULL);
-  return handler.get();
+                                           subPool.getPool()),);
 }
 
 namespace {
@@ -1199,38 +1180,31 @@ public:
     {
       FileRevisionHandler* const self =
         static_cast<FileRevisionHandler*>(baton);
-      SVN_ERR_ASSERT(self->m_jresult_list != NULL);
-      self->add(path, revision, revision_props,
+      SVN_ERR_ASSERT(self->m_jcallback != NULL);
+      self->call(path, revision, revision_props,
                 result_of_merge, prop_diffs, scratch_pool);
       SVN_ERR(JNIUtil::checkJavaException(SVN_ERR_BASE));
       return SVN_NO_ERROR;
     }
 
-  FileRevisionHandler()
-    : m_jresult_list(NULL)
+  FileRevisionHandler(jobject jcallback)
+    : m_jcallback(jcallback),
+      m_call_mid(0)
     {
       JNIEnv* env = JNIUtil::getEnv();
-      jclass cls = env->FindClass("java/util/ArrayList");
+      jclass cls = env->GetObjectClass(jcallback);
       if (JNIUtil::isJavaExceptionThrown())
         return;
 
-      static jmethodID mid = 0;
-      if (mid == 0)
-        {
-          mid = env->GetMethodID(cls, "<init>", "()V");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-        }
-
-      jobject jresult_list = env->NewObject(cls, mid);
-      if (!JNIUtil::isJavaExceptionThrown() && jresult_list)
-        m_jresult_list = jresult_list;
+      m_call_mid = env->GetMethodID(cls, "doRevision",
+                                    "(L"JAVA_PACKAGE"/callback/"
+                                    "RemoteFileRevisionsCallback;)V");
+        if (JNIUtil::isJavaExceptionThrown())
+          return;
     }
 
-  jobject get() const { return m_jresult_list; }
-
 private:
-  void add(const char* path, svn_revnum_t revision,
+  void call(const char* path, svn_revnum_t revision,
            apr_hash_t* revision_props,
            svn_boolean_t result_of_merge,
            apr_array_header_t* prop_diffs,
@@ -1251,18 +1225,6 @@ private:
             return;
         }
 
-      static jmethodID mid_add = 0;
-      if (mid_add == 0)
-        {
-          jclass list_cls = env->FindClass("java/util/ArrayList");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-          mid_add = env->GetMethodID(list_cls, "add",
-                                     "(Ljava/lang/Object;)Z");
-          if (JNIUtil::isJavaExceptionThrown())
-            return;
-        }
-
       jstring jpath = JNIUtil::makeJString(path);
       if (JNIUtil::isJavaExceptionThrown())
         return;
@@ -1273,10 +1235,10 @@ private:
       if (JNIUtil::isJavaExceptionThrown())
         return;
 
-      env->CallBooleanMethod(m_jresult_list, mid_add,
-                             env->NewObject(cls, mid, jpath, jlong(revision),
-                                            jboolean(result_of_merge),
-                                            jrevprops, jpropdelta));
+      env->CallVoidMethod(m_jcallback, m_call_mid,
+                          env->NewObject(cls, mid, jpath, jlong(revision),
+                                         jboolean(result_of_merge),
+                                         jrevprops, jpropdelta));
       if (JNIUtil::isJavaExceptionThrown())
         return;
       env->DeleteLocalRef(jpath);
@@ -1284,33 +1246,33 @@ private:
       env->DeleteLocalRef(jpropdelta);
     }
 
-  jobject m_jresult_list;
+  jobject m_jcallback;
+  jmethodID m_call_mid;
 };
 } // anonymous namespace
 
-jobject
+void
 RemoteSession::getFileRevisions(jstring jpath,
                                 jlong jstart_revision, jlong jend_revision,
-                                jboolean jinclude_merged_revisions)
+                                jboolean jinclude_merged_revisions,
+                                jobject jcallback)
 {
   SVN::Pool subPool(pool);
   Relpath path(jpath, subPool);
   if (JNIUtil::isExceptionThrown())
-    return NULL;
-  SVN_JNI_ERR(path.error_occurred(), NULL);
+    return;
+  SVN_JNI_ERR(path.error_occurred(), );
 
-  FileRevisionHandler handler;
+  FileRevisionHandler handler(jcallback);
   if (JNIUtil::isExceptionThrown())
-    return NULL;
+    return;
 
   SVN_JNI_ERR(svn_ra_get_file_revs2(m_session, path.c_str(),
                                     svn_revnum_t(jstart_revision),
                                     svn_revnum_t(jend_revision),
                                     bool(jinclude_merged_revisions),
                                     handler.callback, &handler,
-                                    subPool.getPool()),
-              NULL);
-  return handler.get();
+                                    subPool.getPool()),);
 }
 
 // TODO: lock

Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h?rev=1510909&r1=1510908&r2=1510909&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h 
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h Tue Aug  
6 11:33:44 2013
@@ -95,11 +95,13 @@ class RemoteSession : public SVNBase
     jobject stat(jstring jpath, jlong jrevision);
     jobject getLocations(jstring jpath, jlong jpeg_revision,
                          jobject jlocation_revisions);
-    jobject getLocationSegments(jstring jpath, jlong jpeg_revision,
-                                jlong jstart_revision, jlong jend_revision);
-    jobject getFileRevisions(jstring jpath,
+    void getLocationSegments(jstring jpath, jlong jpeg_revision,
                              jlong jstart_revision, jlong jend_revision,
-                             jboolean jinclude_merged_revisions);
+                             jobject jcallback);
+    void getFileRevisions(jstring jpath,
+                          jlong jstart_revision, jlong jend_revision,
+                          jboolean jinclude_merged_revisions,
+                          jobject jcallback);
     // TODO: getFileRevisions
     // TODO: lock
     // TODO: unlock

Modified: 
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp?rev=1510909&r1=1510908&r2=1510909&view=diff
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
 (original)
+++ 
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
 Tue Aug  6 11:33:44 2013
@@ -295,31 +295,36 @@ Java_org_apache_subversion_javahl_remote
   return ras->getLocations(jpath, jpeg_revision, jlocation_revisions);
 }
 
-JNIEXPORT jobject JNICALL
+JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_remote_RemoteSession_getLocationSegments(
     JNIEnv *env, jobject jthis, jstring jpath, jlong jpeg_revision,
-    jlong jstart_revision, jlong jend_revision)
+    jlong jstart_revision, jlong jend_revision, jobject jcallback)
 {
   JNIEntry(SVNReposAccess, getLocationSegments);
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
-  CPPADDR_NULL_PTR(ras, NULL);
+  CPPADDR_NULL_PTR(ras, );
 
-  return ras->getLocationSegments(jpath, jpeg_revision,
-                                  jstart_revision, jend_revision);
+  if (jcallback == NULL)
+    JNIUtil::throwNullPointerException("handler");
+  ras->getLocationSegments(jpath, jpeg_revision,
+                           jstart_revision, jend_revision,
+                           jcallback);
 }
 
-JNIEXPORT jobject JNICALL
+JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_remote_RemoteSession_getFileRevisions(
     JNIEnv *env, jobject jthis, jstring jpath,
     jlong jstart_revision, jlong jend_revision,
-    jboolean jinclude_merged_revisions)
+    jboolean jinclude_merged_revisions, jobject jcallback)
 {
   JNIEntry(SVNReposAccess, getFileRevisions);
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
-  CPPADDR_NULL_PTR(ras, NULL);
+  CPPADDR_NULL_PTR(ras, );
 
-  return ras->getFileRevisions(jpath, jstart_revision, jend_revision,
-                               jinclude_merged_revisions);
+  if (jcallback == NULL)
+    JNIUtil::throwNullPointerException("handler");
+  ras->getFileRevisions(jpath, jstart_revision, jend_revision,
+                        jinclude_merged_revisions, jcallback);
 }
 
 // TODO: lock

Modified: 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java?rev=1510909&r1=1510908&r2=1510909&view=diff
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
 (original)
+++ 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
 Tue Aug  6 11:33:44 2013
@@ -512,7 +512,31 @@ public interface ISVNRemote
     }
 
     /**
-     * Return a lost of segments in the location history of <code>path</code>
+     * Call <code>handler</code> for every segment in the location
+     * history of <code>path</code> at <code>pegRevision</code>,
+     * working backwards in time from <code>startRevision</code> to
+     * <code>endRevision</code>.
+     *
+     * @param path A session-relative path.
+     * @param pegRevision The peg revision to find <code>path</code> in.
+     * @param startRevision The upper bound of the revision range. Use
+     * {@link org.apache.subversion.javahl.types.Revision#SVN_INVALID_REVNUM}
+     *        to indicate HEAD.
+     * @param endRevision The lower bound of the revision range. Use
+     * {@link org.apache.subversion.javahl.types.Revision#SVN_INVALID_REVNUM}
+     *        to trace the history of the object to its origin.
+     * @param handler The callback handler.
+     * @throws ClientException
+     */
+    void getLocationSegments(String path,
+                             long pegRevision,
+                             long startRevision,
+                             long endRevision,
+                             RemoteLocationSegmentsCallback handler)
+            throws ClientException;
+
+    /**
+     * Return a list of segments in the location history of <code>path</code>
      * at <code>pegRevision</code>, working backwards in time from
      * <code>startRevision</code> to <code>endRevision</code>.
      *
@@ -599,6 +623,41 @@ public interface ISVNRemote
     }
 
     /**
+     * Call <code>handler</code> for each of a subset of the
+     * interesting revisions of a file <code>path</code> as seen in
+     * revision <code>endRevision</code>.
+     * <p>
+     * If there is an interesting revision of the file that is less
+     * than or equal to <code>startRevision</code>, the iteration will
+     * begin at that revision.  Otherwise the iteration will begin at
+     * the first revision of the file in the repository, which has to
+     * be less than or equal to <code>endRevision</code>.  Note that
+     * if the function succeeds, <code>handler</code> will be called
+     * at least once.
+     * <p>
+     * <b>Note:</b> This functionality is not available in pre-1.1
+     * servers.  If the server doesn't implement it, an alternative
+     * (but much slower) implementation based on {@link #getLog} is
+     * used.
+     * <p>
+     * <b>Note:</b> With Subversion 1.8 and newer servers this
+     * function supports reversion of the revision range for when
+     * <code>includeMergedRevisions</code> is <code>false</code>.
+     *
+     * @param path A path relative to the session URL.
+     * @param startRevision The lower bound of the revision interval.
+     * @param endRevision the upper bound of the revision interval.
+     * @param includeMergedRevisions When <code>true</code>, revisions that
+     *    contributed to a merge are included in the result.
+     * @throws ClientException
+     */
+    void getFileRevisions(String path,
+                          long startRevision, long endRevision,
+                          boolean includeMergedRevisions,
+                          RemoteFileRevisionsCallback handler)
+            throws ClientException;
+
+    /**
      * Retrieve a subset of the interesting revisions of a file
      * <code>path</code> as seen in revision <code>endRevision</code>.
      * <p>

Added: 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteFileRevisionsCallback.java
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteFileRevisionsCallback.java?rev=1510909&view=auto
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteFileRevisionsCallback.java
 (added)
+++ 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteFileRevisionsCallback.java
 Tue Aug  6 11:33:44 2013
@@ -0,0 +1,36 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ * @endcopyright
+ */
+
+package org.apache.subversion.javahl.callback;
+
+import org.apache.subversion.javahl.ISVNRemote;
+
+/**
+ * Called for each location segment returned from
+ * {@link ISVNRemote#getFileRevisions}.
+ */
+
+public interface RemoteFileRevisionsCallback
+{
+    public void doRevision(ISVNRemote.FileRevision fileRevision);
+}

Added: 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteLocationSegmentsCallback.java
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteLocationSegmentsCallback.java?rev=1510909&view=auto
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteLocationSegmentsCallback.java
 (added)
+++ 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/RemoteLocationSegmentsCallback.java
 Tue Aug  6 11:33:44 2013
@@ -0,0 +1,36 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ * @endcopyright
+ */
+
+package org.apache.subversion.javahl.callback;
+
+import org.apache.subversion.javahl.ISVNRemote;
+
+/**
+ * Called for each location segment returned from
+ * {@link ISVNRemote#getLocationSegments}.
+ */
+
+public interface RemoteLocationSegmentsCallback
+{
+    public void doSegment(ISVNRemote.LocationSegment locationSegment);
+}

Modified: 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java?rev=1510909&r1=1510908&r2=1510909&view=diff
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
 (original)
+++ 
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
 Tue Aug  6 11:33:44 2013
@@ -34,6 +34,7 @@ import org.apache.subversion.javahl.Oper
 import org.apache.subversion.javahl.ClientException;
 
 import java.lang.ref.WeakReference;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -207,19 +208,68 @@ public class RemoteSession extends JNIOb
             throws ClientException;
 
     public native
-        List<LocationSegment> getLocationSegments(String path,
-                                                  long pegRevision,
-                                                  long startRevision,
-                                                  long endRevision)
+        void getLocationSegments(String path,
+                                 long pegRevision,
+                                 long startRevision,
+                                 long endRevision,
+                                 RemoteLocationSegmentsCallback handler)
             throws ClientException;
 
+    private static class GetLocationSegmentsHandler
+        implements RemoteLocationSegmentsCallback
+    {
+        public List<LocationSegment> locationSegments = null;
+        public void doSegment(LocationSegment locationSegment)
+        {
+            if (locationSegments == null)
+                locationSegments = new ArrayList<LocationSegment>();
+            locationSegments.add(locationSegment);
+        }
+    }
+
+    public List<LocationSegment> getLocationSegments(String path,
+                                                     long pegRevision,
+                                                     long startRevision,
+                                                     long endRevision)
+            throws ClientException
+    {
+        final GetLocationSegmentsHandler handler = new 
GetLocationSegmentsHandler();
+        getLocationSegments(path, pegRevision, startRevision, endRevision, 
handler);
+        return handler.locationSegments;
+    }
+
     public native
-        List<FileRevision> getFileRevisions(String path,
-                                            long startRevision,
-                                            long endRevision,
-                                            boolean includeMergedRevisions)
+        void getFileRevisions(String path,
+                              long startRevision,
+                              long endRevision,
+                              boolean includeMergedRevisions,
+                              RemoteFileRevisionsCallback handler)
             throws ClientException;
 
+    private static class GetFileRevisionsHandler
+        implements RemoteFileRevisionsCallback
+    {
+        public List<FileRevision> fileRevisions = null;
+        public void doRevision(FileRevision fileRevision)
+        {
+            if (fileRevisions == null)
+                fileRevisions = new ArrayList<FileRevision>();
+            fileRevisions.add(fileRevision);
+        }
+    }
+
+    public List<FileRevision> getFileRevisions(String path,
+                                               long startRevision,
+                                               long endRevision,
+                                               boolean includeMergedRevisions)
+            throws ClientException
+    {
+        final GetFileRevisionsHandler handler = new GetFileRevisionsHandler();
+        getFileRevisions(path, startRevision, endRevision,
+                         includeMergedRevisions, handler);
+        return handler.fileRevisions;
+    }
+
     // TODO: lock
     // TODO: unlock
     // TODO: getLock


Reply via email to