/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be * converted * @param transferData an empty <code>TransferData</code> object that will be * filled in on return with the platform specific format of the data * @see Transfer#nativeToJava */ public void javaToNative( Object object, TransferData transferData ) { if( !checkByteArray( object ) || !isSupportedType( transferData ) ) { DND.error( DND.ERROR_INVALID_DATA ); } byte[] data = ( byte[] )object; transferData.data = new byte[ data.length ]; System.arraycopy( data, 0, transferData.data, 0, data.length ); transferData.result = 1; }
/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data * * @see Transfer#nativeToJava */ protected void javaToNative (Object object, TransferData transferData) { if (!checkByteArray(object) && !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } byte[] orig = (byte[])object; NSData data = NSData.dataWithBytes(orig, orig.length); transferData.data = data; }
/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data * * @see Transfer#nativeToJava */ @Override protected void javaToNative (Object object, TransferData transferData) { transferData.result = 0; if (!checkByteArray(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } byte[] buffer = (byte[])object; if (buffer.length == 0) return; int /*long*/ pValue = OS.g_malloc(buffer.length); if (pValue == 0) return; OS.memmove(pValue, buffer, buffer.length); transferData.length = buffer.length; transferData.format = 8; transferData.pValue = pValue; transferData.result = 1; }
/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data * * @see Transfer#nativeToJava */ @Override protected void javaToNative (Object object, TransferData transferData) { transferData.result = 0; if (!checkByteArray(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } byte[] buffer = (byte[])object; if (buffer.length == 0) return; int /*long*/ pValue = OS.g_malloc(buffer.length); if (pValue == 0) return; OS.memmove(pValue, buffer, buffer.length); transferData.length = buffer.length; transferData.format = 8; transferData.pValue = pValue; transferData.result = 1; }
/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data * * @see Transfer#nativeToJava */ @Override protected void javaToNative (Object object, TransferData transferData) { transferData.result = 0; if (!checkByteArray(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } byte[] buffer = (byte[])object; if (buffer.length == 0) return; long /*int*/ pValue = OS.g_malloc(buffer.length); if (pValue == 0) return; OS.memmove(pValue, buffer, buffer.length); transferData.length = buffer.length; transferData.format = 8; transferData.pValue = pValue; transferData.result = 1; }
/** * This implementation of <code>javaToNative</code> converts a java * <code>byte[]</code> to a platform specific representation. * * @param object a java <code>byte[]</code> containing the data to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data * * @see Transfer#nativeToJava */ @Override protected void javaToNative (Object object, TransferData transferData) { if (!checkByteArray(object) || !isSupportedType(transferData)) { DND.error(DND.ERROR_INVALID_DATA); } // Allocate the memory because the caller (DropTarget) has not handed it in // The caller of this method must release the data when it is done with it. byte[] data = (byte[])object; int size = data.length; int /*long*/ newPtr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, size); OS.MoveMemory(newPtr, data, size); transferData.stgmedium = new STGMEDIUM(); transferData.stgmedium.tymed = COM.TYMED_HGLOBAL; transferData.stgmedium.unionField = newPtr; transferData.stgmedium.pUnkForRelease = 0; transferData.result = COM.S_OK; }