JNIEXPORT jlong JNICALL Java_nitf_MemorySource_getSize (JNIEnv *env, jobject self) { nitf_BandSource *source = _GetObj(env, self); nitf_Error error; nitf_Off size; if (0 > (size = source->iface->getSize(source->data, &error))) { _ThrowNITFException(env, error.message); return -1; } return (jlong)size; }
/* * Class: nitf_BandInfo * Method: getLookupTable * Signature: ()Lnitf/LookupTable; */ JNIEXPORT jobject JNICALL Java_nitf_BandInfo_getLookupTable (JNIEnv * env, jobject self) { nitf_BandInfo *info = _GetObj(env, self); jobject lut = NULL; if (info->lut) { lut = _NewObject(env, (jlong)info->lut, "nitf/LookupTable"); /* tell Java not to manage it */ _ManageObject(env, (jlong)info->lut, JNI_FALSE); } return lut; }
JNIEXPORT jlong JNICALL Java_nitf_NativeIOInterface_getSize(JNIEnv *env, jobject self) { nitf_Error error; nitf_Off size; nitf_IOInterface *interface = _GetObj(env, self); size = interface->iface->getSize(interface->data, &error); if (size == (nitf_Off)NITF_INVALID_HANDLE_VALUE) { _ThrowNITFException(env, error.message); return -1; } return (jlong)size; }
/* * Class: nitf_Record * Method: getHeader * Signature: ()Lnitf/FileHeader; */ JNIEXPORT jobject JNICALL Java_nitf_Record_getHeader (JNIEnv * env, jobject self) { nitf_Record *record = _GetObj(env, self); jclass fileHeaderClass = (*env)->FindClass(env, "nitf/FileHeader"); jmethodID methodID = (*env)->GetMethodID(env, fileHeaderClass, "<init>", "(J)V"); jobject header = (*env)->NewObject(env, fileHeaderClass, methodID, (jlong) record->header); return header; }
JNIEXPORT jobject JNICALL Java_nitf_TRE_00024TREIterator_next (JNIEnv *env, jobject self) { nitf_TREEnumerator *enumerator = _GetObj(env, self); nitf_Pair *pair = NULL; jclass fieldClass, fieldPairClass; jmethodID fieldInitMethod, fieldPairInitMethod; jfieldID nameFieldID, fieldFieldID; jobject jField, jFieldPair; jstring jFieldName; nitf_Error error; if (!enumerator) return NULL; /* get the next value */ pair = enumerator->next(enumerator, &error); if (!pair) { _ThrowNITFException(env, "NULL pair"); return NULL; } fieldClass = (*env)->FindClass(env, "nitf/Field"); fieldPairClass = (*env)->FindClass(env, "nitf/TRE$FieldPair"); nameFieldID = (*env)->GetFieldID(env, fieldPairClass, "name", "Ljava/lang/String;"); fieldFieldID = (*env)->GetFieldID(env, fieldPairClass, "field", "Lnitf/Field;"); fieldInitMethod = (*env)->GetMethodID(env, fieldClass, "<init>", "(J)V"); fieldPairInitMethod = (*env)->GetMethodID(env, fieldPairClass, "<init>", "()V"); jField = (*env)->NewObject(env, fieldClass, fieldInitMethod, (jlong) pair->data); jFieldName = (*env)->NewStringUTF(env, pair->key); jFieldPair = (*env)->NewObject(env, fieldPairClass, fieldPairInitMethod); (*env)->SetObjectField(env, jFieldPair, nameFieldID, jFieldName); (*env)->SetObjectField(env, jFieldPair, fieldFieldID, jField); return jFieldPair; }
/* * Class: nitf_LookupTable * Method: getData * Signature: ()[B */ JNIEXPORT jbyteArray JNICALL Java_nitf_LookupTable_getData(JNIEnv * env, jobject self) { nitf_LookupTable *lut = _GetObj(env, self); jint length; jbyteArray byteArray; if (lut->table) { length = lut->entries * lut->tables; byteArray = (*env)->NewByteArray(env, length); (*env)->SetByteArrayRegion(env, byteArray, 0, length, lut->table); return byteArray; } return NULL; }
/* * Class: nitf_Record * Method: getGraphics * Signature: ()[Lnitf/GraphicSegment; */ JNIEXPORT jobjectArray JNICALL Java_nitf_Record_getGraphics (JNIEnv * env, jobject self) { nitf_Record *record = _GetObj(env, self); jclass segmentClass = (*env)->FindClass(env, "nitf/GraphicSegment"); jobjectArray graphics; jobject segment; jint count = 0; nitf_GraphicSegment *graphicSegment; nitf_ListIterator iter, end; /* get the initial count */ iter = nitf_List_begin(record->graphics); end = nitf_List_end(record->graphics); while (nitf_ListIterator_notEqualTo(&iter, &end)) { count++; nitf_ListIterator_increment(&iter); } /* make the array */ graphics = (*env)->NewObjectArray(env, count, segmentClass, NULL); iter = nitf_List_begin(record->graphics); end = nitf_List_end(record->graphics); count = 0; while (nitf_ListIterator_notEqualTo(&iter, &end)) { jmethodID methodID = (*env)->GetMethodID(env, segmentClass, "<init>", "(J)V"); /* Get the image segment as its proper object */ graphicSegment = (nitf_GraphicSegment *) nitf_ListIterator_get(&iter); segment = (*env)->NewObject(env, segmentClass, methodID, (jlong) graphicSegment); (*env)->SetObjectArrayElement(env, graphics, count, segment); count++; /* Increment the iterator so we can continue */ nitf_ListIterator_increment(&iter); } return graphics; }
/* * Class: nitf_SubWindow * Method: getBandList * Signature: ()[I */ JNIEXPORT jintArray JNICALL Java_nitf_SubWindow_getBandList (JNIEnv * env, jobject self) { nitf_SubWindow *subWindow = _GetObj(env, self); jintArray array; if (subWindow->bandList && subWindow->numBands > 0) { array = (*env)->NewIntArray(env, subWindow->numBands); (*env)->SetIntArrayRegion(env, array, 0, subWindow->numBands, subWindow->bandList); return array; } else { return (*env)->NewIntArray(env, 0); } }
JNIEXPORT jobject JNICALL Java_nitf_DESubheader_setSubheaderFields (JNIEnv *env, jobject self, jobject subheaderFields) { nitf_DESubheader *header = _GetObj(env, self); jobject tre = NULL; jmethodID initMethod = NULL, addressMethod = NULL; nitf_TRE *newTRE = NULL, *clonedTRE = NULL; jclass treClass = (*env)->FindClass(env, "nitf/TRE"); nitf_Error error; if (subheaderFields != NULL) { initMethod = (*env)->GetMethodID(env, treClass, "<init>", "(J)V"); addressMethod = (*env)->GetMethodID(env, treClass, "getAddress", "()J"); /* get the address of the new one passed in */ newTRE = (nitf_TRE*) (*env)->CallLongMethod(env, subheaderFields, addressMethod); /* clone it */ clonedTRE = nitf_TRE_clone(newTRE, &error); if (!clonedTRE) { _ThrowNITFException(env, error.message); return NULL; } } /* get the current TRE object, and tell Java we're done with it */ if (header->subheaderFields) { _ManageObject(env, (jlong)header->subheaderFields, JNI_TRUE); } /* set the cloned one to the subheaderFields */ header->subheaderFields = clonedTRE; if (clonedTRE != NULL) { /* create a new Java TRE from the clone and tell Java not to manage it */ tre = _NewObject(env, (jlong)header->subheaderFields, "nitf/TRE"); _ManageObject(env, (jlong)header->subheaderFields, JNI_FALSE); } return tre; }
JNIEXPORT jstring JNICALL Java_nitf_TRE_00024TREIterator_getFieldDescription (JNIEnv *env, jobject self) { nitf_TREEnumerator *enumerator = _GetObj(env, self); nitf_Error error; jstring string = NULL; if (enumerator) { const char* desc = enumerator->getFieldDescription(enumerator, &error); if (desc) { /* get the string */ string = (*env)->NewStringUTF(env, desc); } } return string; }
/* * Class: nitf_Record * Method: getImages * Signature: ()[Lnitf/ImageSegment; */ JNIEXPORT jobjectArray JNICALL Java_nitf_Record_getImages (JNIEnv * env, jobject self) { nitf_Record *record = _GetObj(env, self); jclass segmentClass = (*env)->FindClass(env, "nitf/ImageSegment"); jobjectArray images; jobject segment; jint count = 0; nitf_ImageSegment *imageSegment; nitf_ListIterator iter, end; /* get the initial count */ iter = nitf_List_begin(record->images); end = nitf_List_end(record->images); while (nitf_ListIterator_notEqualTo(&iter, &end)) { count++; nitf_ListIterator_increment(&iter); } /* make the array */ images = (*env)->NewObjectArray(env, count, segmentClass, NULL); iter = nitf_List_begin(record->images); end = nitf_List_end(record->images); count = 0; while (nitf_ListIterator_notEqualTo(&iter, &end)) { jmethodID methodID = (*env)->GetMethodID(env, segmentClass, "<init>", "(J)V"); imageSegment = (nitf_ImageSegment *) nitf_ListIterator_get(&iter); segment = (*env)->NewObject(env, segmentClass, methodID, (jlong) imageSegment); (*env)->SetObjectArrayElement(env, images, count, segment); count++; nitf_ListIterator_increment(&iter); } return images; }
/* * Class: nitf_SubWindow * Method: getDownSampler * Signature: ()Lnitf/DownSampler; */ JNIEXPORT jobject JNICALL Java_nitf_SubWindow_getDownSampler (JNIEnv * env, jobject self) { nitf_SubWindow *subWindow = _GetObj(env, self); jobject downSampler; jmethodID methodID; jclass downSamplerClass = (*env)->FindClass(env, "nitf/DownSampler"); if (subWindow->downsampler) { methodID = (*env)->GetMethodID(env, downSamplerClass, "<init>", "(J)V"); downSampler = (*env)->NewObject(env, downSamplerClass, methodID, subWindow->downsampler); return downSampler; } /* otherwise, return NULL */ return NULL; }
JNIEXPORT void JNICALL Java_nitf_NativeIOInterface_write (JNIEnv *env, jobject self, jbyteArray buf, jint size) { nitf_Error error; nitf_Off tell; jbyte *array = NULL; nitf_IOInterface *interface = _GetObj(env, self); array = (*env)->GetByteArrayElements(env, buf, 0); if (!array) { _ThrowNITFException(env, "Out of memory!"); return; } if (!(interface->iface->write(interface->data, array, size, &error))) { _ThrowNITFException(env, error.message); } (*env)->ReleaseByteArrayElements(env, buf, array, 0); }
/* * Class: nitf_SegmentWriter * Method: attachSource * Signature: (Lnitf/SegmentSource;)Z */ JNIEXPORT jboolean JNICALL Java_nitf_SegmentWriter_attachSource (JNIEnv *env, jobject self, jobject segmentSource) { nitf_SegmentWriter *writer = _GetObj(env, self); jclass segmentSourceClass = (*env)->FindClass(env, "nitf/SegmentSource"); nitf_Error error; nitf_SegmentSource *source; jmethodID methodID = (*env)->GetMethodID(env, segmentSourceClass, "getAddress", "()J"); source = (nitf_SegmentSource *) (*env)->CallLongMethod(env, segmentSource, methodID); if (!nitf_SegmentWriter_attachSource(writer, source, &error)) { _ThrowNITFException(env, error.message); return JNI_FALSE; } return JNI_TRUE; }
/* * Class: nitf_ImageSubheader * Method: getImageComments * Signature: ()[Lnitf/Field; */ JNIEXPORT jobjectArray JNICALL Java_nitf_ImageSubheader_getImageComments (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); nitf_Uint32 numComments; nitf_Error error; jint i; jobjectArray array; jobject fieldObj; nitf_ListIterator iter, end; jclass fieldClass = (*env)->FindClass(env, "nitf/Field"); NITF_TRY_GET_UINT32(header->numImageComments, &numComments, &error); if (numComments > 0) { array = (*env)->NewObjectArray(env, numComments, fieldClass, NULL); iter = nitf_List_begin(header->imageComments); end = nitf_List_end(header->imageComments); for (i = 0; nitf_ListIterator_notEqualTo(&iter, &end); ++i) { fieldObj = _GetFieldObj(env, (nitf_Field*) nitf_ListIterator_get(&iter)); (*env)->SetObjectArrayElement(env, array, i, fieldObj); nitf_ListIterator_increment(&iter); } } else { array = (*env)->NewObjectArray(env, 0, fieldClass, NULL); } return array; CATCH_ERROR: _ThrowNITFException(env, error.message); return NULL; }
/* * Class: nitf_MemorySource * Method: read * Signature: ([BI)V */ JNIEXPORT void JNICALL Java_nitf_MemorySource_read (JNIEnv * env, jobject self, jbyteArray buf, jint size) { nitf_BandSource *source = _GetObj(env, self); jbyte *byteBuf; nitf_Error error; byteBuf = (*env)->GetByteArrayElements(env, buf, 0); if (!byteBuf) { _ThrowNITFException(env, "ERROR getting data from array"); return; } if (!source->iface->read(source->data, (char *) byteBuf, size, &error)) { _ThrowNITFException(env, error.message); return; } (*env)->ReleaseByteArrayElements(env, buf, byteBuf, 0); return; }
/* * Class: nitf_ImageSubheader * Method: insertImageComment * Signature: (Ljava/lang/String;I)I */ JNIEXPORT jint JNICALL Java_nitf_ImageSubheader_insertImageComment (JNIEnv * env, jobject self, jstring comment, jint index) { nitf_ImageSubheader *header = _GetObj(env, self); nitf_Error error; const jbyte *comBuf = NULL; jint indexUsed; if (comment != NULL) comBuf = (*env)->GetStringUTFChars(env, comment, 0); indexUsed = nitf_ImageSubheader_insertImageComment( header, comBuf, index, &error); if (indexUsed < 0) { _ThrowNITFException(env, error.message); } if (comment != NULL) (*env)->ReleaseStringUTFChars(env, comment, comBuf); return indexUsed; }
/* * Class: nitf_ImageSubheader * Method: getImageRepresentation * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getImageRepresentation (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->imageRepresentation); }
/* * Class: nitf_ImageSubheader * Method: getCornerCoordinates * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getCornerCoordinates (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->cornerCoordinates); }
/* * Class: nitf_ImageSubheader * Method: getCompressionRate * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getCompressionRate (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->compressionRate); }
/* * Class: nitf_ImageSubheader * Method: getUserDefinedOverflow * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getUserDefinedOverflow (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->userDefinedOverflow); }
/* * Class: nitf_ImageSubheader * Method: getTargetId * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getTargetId (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->targetId); }
/* * Class: nitf_ImageSubheader * Method: getPixelValueType * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getPixelValueType (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->pixelValueType); }
/* * Class: nitf_ImageSubheader * Method: getPixelJustification * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getPixelJustification (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->pixelJustification); }
/* * Class: nitf_ImageSubheader * Method: getNumRows * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getNumRows (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->numRows); }
/* * Class: nitf_ImageSubheader * Method: getNumPixelsPerVertBlock * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getNumPixelsPerVertBlock (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->numPixelsPerVertBlock); }
/* * Class: nitf_ImageSubheader * Method: getImageAttachmentLevel * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getImageAttachmentLevel (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->imageAttachmentLevel); }
/* * Class: nitf_ImageSubheader * Method: getImageCoordinateSystem * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getImageCoordinateSystem (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->imageCoordinateSystem); }
/* * Class: nitf_ImageSubheader * Method: getActualBitsPerPixel * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getActualBitsPerPixel (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->actualBitsPerPixel); }
/* * Class: nitf_ImageSubheader * Method: getImageSyncCode * Signature: ()Lnitf/Field; */ JNIEXPORT jobject JNICALL Java_nitf_ImageSubheader_getImageSyncCode (JNIEnv * env, jobject self) { nitf_ImageSubheader *header = _GetObj(env, self); return _GetFieldObj(env, header->imageSyncCode); }