tailieunhanh - Professional Java JDK 6 Edition 2007 phần 7

dữ liệu trong ứng dụng của bạn, bạn sẽ phải chuyển đổi nó đến và đi từ các mô hình dữ liệu . Nó không phải là một nhiệm vụ khó khăn, nhưng phải được thực hiện cho những thứ như màu sắc và điểm quan đại diện có bất kỳ ý nghĩa cho các ứng dụng của bạn. | Part II A Broad Understanding of Java APIs Tools and Techniques column in the table. The NativeType is replaced with the exact name of the native data type from column three in the table. For example to create a new integer array you use the function NewlntArray that returns jintArray. Name of Primitive Data Type Array Type For Use in C C Code Primitive Type For Use in C C Code boolean jbooleanArray jboolean byte jbyteArray jbyte char jcharArray jchar short jshortArray jshort int jintArray jint long jlongArray jlong float jfloatArray jfloat double jdoubleArray jdouble The NewArray function returns a newly created Java array that is length elements in size ArrayType New Type Array jsize length The GetArrayElements function returns a pointer to an array of the native type that corresponds to the Java data type NativeType Get Type ArrayElements ArrayType array jboolean isCopy The parameter isCopy is set to JNI_TRUE if the memory returned is a copy of the array from the Java code or JNI_FALSE if the memory is not a copy. The ReleaseArrayElements function releases the memory obtained from the call to Get Type ArrayElements void Release Type ArrayElements ArrayType array NativeType elems jint mode If the native array is not a copy the mode parameter can be used to optionally copy memory from the native array back to the Java array. The values of mode and their effects are listed in the following table. Value of Mode Description 0 Copies the memory from the native array to the Java array and deallocates the memory used by the native array. JNI_COMMIT Copies the memory from the native array to the Java array but does not deallocate the memory used by the native array. JNI_ABORT Does not copy memory from the native array to the Java array. The memory used by the native array is still deallocated. 438 Chapter 9 Interacting with C C Using Java Native Interface The GetArrayRegion function operates much like Get Type ArrayElements. However this is used to copy only a subset of