[[[
    JavaHL: Added support for creating of svn_string_t from JNIByteArray

    [ in subversion/bindings/javahl/native ]

    * JNIByteArray.cpp, JNIByteArray.h
      (getLength): Mark as const as the function does not alter class data
and can be used by other const functions
      (getSvnString): New function to convert JNI byte array to svn_string_t
]]]
Index: subversion/bindings/javahl/native/JNIByteArray.h
===================================================================
--- subversion/bindings/javahl/native/JNIByteArray.h    (revision 1328758)
+++ subversion/bindings/javahl/native/JNIByteArray.h    (working copy)
@@ -28,6 +28,8 @@
 #define JNIBYTEARRAY_H
 
 #include <jni.h>
+#include "Pool.h"
+#include "svn_string.h"
 
 /**
  * This class holds a Java byte array to give easy access to its
@@ -54,7 +56,8 @@ class JNIByteArray
  public:
   bool isNull() const;
   const signed char *getBytes() const;
-  int getLength();
+  const svn_string_t *getSvnString(SVN::Pool pool) const;
+  int getLength() const;
   JNIByteArray(jbyteArray jba, bool deleteByteArray = false);
   ~JNIByteArray();
 };
Index: subversion/bindings/javahl/native/JNIByteArray.cpp
===================================================================
--- subversion/bindings/javahl/native/JNIByteArray.cpp  (revision 1328758)
+++ subversion/bindings/javahl/native/JNIByteArray.cpp  (working copy)
@@ -66,7 +66,7 @@ JNIByteArray::~JNIByteArray()
  * Returns the number of bytes in the byte array.
  * @return the number of bytes
  */
-int JNIByteArray::getLength()
+int JNIByteArray::getLength() const
 {
   if (m_data == NULL)
     return 0;
@@ -91,3 +91,15 @@ bool JNIByteArray::isNull() const
 {
   return m_data == NULL;
 }
+
+const svn_string_t *JNIByteArray::getSvnString(SVN::Pool pool) const
+{
+  if (isNull())
+    {
+      return NULL;
+    }
+
+  svn_string_t * val = svn_string_ncreate((const char *)getBytes(), 
getLength(), pool.getPool());
+
+  return val;
+}

Reply via email to