diff --git a/xflaim/java/jni/jdb.cpp b/xflaim/java/jni/jdb.cpp index f45421b..8a750d8 100644 --- a/xflaim/java/jni/jdb.cpp +++ b/xflaim/java/jni/jdb.cpp @@ -75,16 +75,250 @@ static jfieldID fid_CheckpointInfo_iWaitTruncateTime = NULL; static jfieldID fid_LockUser_iThreadId = NULL; static jfieldID fid_LockUser_iTime = NULL; -#define THIS_FDB() \ - ((IF_Db *)(FLMUINT)lThis) +#define THIS_FDB() ((IF_Db *)(FLMUINT)lThis) +#define ELEMENT_DEF 1 // Maps to ELM_ELEMENT_TAG +#define ATTRIBUTE_DEF 2 // Maps to ELM_ATTRIBUTE_TAG +#define PREFIX_DEF 3 // Maps to ELM_PREFIX_TAG +#define ENCRYPTION_DEF 4 // Maps to ELM_ENCDEF_TAG +#define COLLECTION_DEF 5 // Maps to ELM_COLLECTION_TAG +#define INDEX_DEF 6 // Maps to ELM_INDEX_TAG + +FSTATIC RCODE mapDictType( + jint iDictType, + FLMUINT * puiDictType); + FSTATIC RCODE getDictName( IF_Db * pDb, - FLMUINT uiDictType, + jint iDictType, FLMUINT uiDictNumber, FLMBOOL bGetNamespace, F_DynaBuf * pDynaBuf); +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT void JNICALL Java_xflaim_CheckpointInfo_initIDs( + JNIEnv * pEnv, + jclass jCheckpointInfoClass) +{ + + // Get the field IDs for the fields in the class. + + if ((fid_CheckpointInfo_bRunning = pEnv->GetFieldID( jCheckpointInfoClass, + "bRunning", "Z")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iRunningTime = pEnv->GetFieldID( jCheckpointInfoClass, + "iRunningTime", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_bForcingCheckpoint = pEnv->GetFieldID( jCheckpointInfoClass, + "bForcingCheckpoint", "Z")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iForceCheckpointRunningTime = pEnv->GetFieldID( jCheckpointInfoClass, + "iForceCheckpointRunningTime", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iForceCheckpointReason = pEnv->GetFieldID( jCheckpointInfoClass, + "iForceCheckpointReason", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_bWritingDataBlocks = pEnv->GetFieldID( jCheckpointInfoClass, + "bWritingDataBlocks", "Z")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iLogBlocksWritten = pEnv->GetFieldID( jCheckpointInfoClass, + "iLogBlocksWritten", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iDataBlocksWritten = pEnv->GetFieldID( jCheckpointInfoClass, + "iDataBlocksWritten", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iDirtyCacheBytes = pEnv->GetFieldID( jCheckpointInfoClass, + "iDirtyCacheBytes", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iBlockSize = pEnv->GetFieldID( jCheckpointInfoClass, + "iBlockSize", "I")) == NULL) + { + goto Exit; + } + if ((fid_CheckpointInfo_iWaitTruncateTime = pEnv->GetFieldID( jCheckpointInfoClass, + "iWaitTruncateTime", "I")) == NULL) + { + goto Exit; + } + +Exit: + + return; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT void JNICALL Java_xflaim_IndexStatus_initIDs( + JNIEnv * pEnv, + jclass jIndexStatusClass) +{ + + // Get the field IDs for the fields in the class. + + if ((fid_IndexStatus_iIndexNum = pEnv->GetFieldID( jIndexStatusClass, + "iIndexNum", "I")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_iState = pEnv->GetFieldID( jIndexStatusClass, + "iState", "I")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_iStartTime = pEnv->GetFieldID( jIndexStatusClass, + "iStartTime", "I")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_lLastDocumentIndexed = pEnv->GetFieldID( jIndexStatusClass, + "lLastDocumentIndexed", "J")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_lKeysProcessed = pEnv->GetFieldID( jIndexStatusClass, + "lKeysProcessed", "J")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_lDocumentsProcessed = pEnv->GetFieldID( jIndexStatusClass, + "lDocumentsProcessed", "J")) == NULL) + { + goto Exit; + } + if ((fid_IndexStatus_lTransactions = pEnv->GetFieldID( jIndexStatusClass, + "lTransactions", "J")) == NULL) + { + goto Exit; + } + +Exit: + + return; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT void JNICALL Java_xflaim_ImportStats_initIDs( + JNIEnv * pEnv, + jclass jImportStatsClass) +{ + + // Get the field IDs for the fields in the class. + + if ((fid_ImportStats_iLines = pEnv->GetFieldID( jImportStatsClass, + "iLines", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iChars = pEnv->GetFieldID( jImportStatsClass, + "iChars", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iAttributes = pEnv->GetFieldID( jImportStatsClass, + "iAttributes", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iElements = pEnv->GetFieldID( jImportStatsClass, + "iElements", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iText = pEnv->GetFieldID( jImportStatsClass, + "iText", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iDocuments = pEnv->GetFieldID( jImportStatsClass, + "iDocuments", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iErrLineNum = pEnv->GetFieldID( jImportStatsClass, + "iErrLineNum", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iErrLineOffset = pEnv->GetFieldID( jImportStatsClass, + "iErrLineOffset", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iErrorType = pEnv->GetFieldID( jImportStatsClass, + "iErrorType", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iErrLineFilePos = pEnv->GetFieldID( jImportStatsClass, + "iErrLineFilePos", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_iErrLineBytes = pEnv->GetFieldID( jImportStatsClass, + "iErrLineBytes", "I")) == NULL) + { + goto Exit; + } + if ((fid_ImportStats_bUTF8Encoding = pEnv->GetFieldID( jImportStatsClass, + "bUTF8Encoding", "Z")) == NULL) + { + goto Exit; + } + +Exit: + + return; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT void JNICALL Java_xflaim_LockUser_initIDs( + JNIEnv * pEnv, + jclass jIndexStatusClass) +{ + + // Get the field IDs for the fields in the class. + + if ((fid_LockUser_iThreadId = pEnv->GetFieldID( jIndexStatusClass, + "iThreadId", "I")) == NULL) + { + goto Exit; + } + if ((fid_LockUser_iTime = pEnv->GetFieldID( jIndexStatusClass, + "iTime", "I")) == NULL) + { + goto Exit; + } + +Exit: + + return; +} + /**************************************************************************** Desc: ****************************************************************************/ @@ -330,8 +564,7 @@ Desc: JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockThreadId( JNIEnv * pEnv, jobject, // jobject - jlong lThis, - jint iPriority) + jlong lThis) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); @@ -341,7 +574,7 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockThreadId( FLMUINT uiNumSharedQueued; FLMUINT uiPriorityCount; - if (RC_BAD( rc = pDb->getLockInfo( (FLMINT)iPriority, &lockType, + if (RC_BAD( rc = pDb->getLockInfo( 0, &lockType, &uiThreadId, &uiNumExclQueued, &uiNumSharedQueued, &uiPriorityCount))) { @@ -360,8 +593,7 @@ Desc: JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumExclQueued( JNIEnv * pEnv, jobject, // jobject - jlong lThis, - jint iPriority) + jlong lThis) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); @@ -371,7 +603,7 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumExclQueued( FLMUINT uiNumSharedQueued; FLMUINT uiPriorityCount; - if (RC_BAD( rc = pDb->getLockInfo( (FLMINT)iPriority, &lockType, + if (RC_BAD( rc = pDb->getLockInfo( 0, &lockType, &uiThreadId, &uiNumExclQueued, &uiNumSharedQueued, &uiPriorityCount))) { @@ -390,8 +622,7 @@ Desc: JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumSharedQueued( JNIEnv * pEnv, jobject, // jobject - jlong lThis, - jint iPriority) + jlong lThis) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); @@ -401,7 +632,7 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumSharedQueued( FLMUINT uiNumSharedQueued; FLMUINT uiPriorityCount; - if (RC_BAD( rc = pDb->getLockInfo( (FLMINT)iPriority, &lockType, + if (RC_BAD( rc = pDb->getLockInfo( 0, &lockType, &uiThreadId, &uiNumExclQueued, &uiNumSharedQueued, &uiPriorityCount))) { @@ -441,7 +672,7 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockPriorityCount( Exit: - return( (jint)uiNumSharedQueued); + return( (jint)uiPriorityCount); } /**************************************************************************** @@ -514,230 +745,6 @@ Exit: return( (jint)uiCurrIndex); } -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_CheckpointInfo_initIDs( - JNIEnv * pEnv, - jclass jCheckpointInfoClass) -{ - - // Get the field IDs for the fields in the class. - - if ((fid_CheckpointInfo_bRunning = pEnv->GetFieldID( jCheckpointInfoClass, - "bRunning", "Z")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iRunningTime = pEnv->GetFieldID( jCheckpointInfoClass, - "iRunningTime", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_bForcingCheckpoint = pEnv->GetFieldID( jCheckpointInfoClass, - "bForcingCheckpoint", "Z")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iForceCheckpointRunningTime = pEnv->GetFieldID( jCheckpointInfoClass, - "iForceCheckpointRunningTime", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iForceCheckpointReason = pEnv->GetFieldID( jCheckpointInfoClass, - "iForceCheckpointReason", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_bWritingDataBlocks = pEnv->GetFieldID( jCheckpointInfoClass, - "bWritingDataBlocks", "Z")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iLogBlocksWritten = pEnv->GetFieldID( jCheckpointInfoClass, - "iLogBlocksWritten", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iDataBlocksWritten = pEnv->GetFieldID( jCheckpointInfoClass, - "iDataBlocksWritten", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iDirtyCacheBytes = pEnv->GetFieldID( jCheckpointInfoClass, - "iDirtyCacheBytes", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iBlockSize = pEnv->GetFieldID( jCheckpointInfoClass, - "iBlockSize", "I")) == NULL) - { - goto Exit; - } - if ((fid_CheckpointInfo_iWaitTruncateTime = pEnv->GetFieldID( jCheckpointInfoClass, - "iWaitTruncateTime", "I")) == NULL) - { - goto Exit; - } - -Exit: - - return; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_IndexStatus_initIDs( - JNIEnv * pEnv, - jclass jIndexStatusClass) -{ - - // Get the field IDs for the fields in the class. - - if ((fid_IndexStatus_iIndexNum = pEnv->GetFieldID( jIndexStatusClass, - "iIndexNum", "I")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_iState = pEnv->GetFieldID( jIndexStatusClass, - "iState", "I")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_iStartTime = pEnv->GetFieldID( jIndexStatusClass, - "iStartTime", "I")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_lLastDocumentIndexed = pEnv->GetFieldID( jIndexStatusClass, - "lLastDocumentIndexed", "J")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_lKeysProcessed = pEnv->GetFieldID( jIndexStatusClass, - "lKeysProcessed", "J")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_lDocumentsProcessed = pEnv->GetFieldID( jIndexStatusClass, - "lDocumentsProcessed", "J")) == NULL) - { - goto Exit; - } - if ((fid_IndexStatus_lTransactions = pEnv->GetFieldID( jIndexStatusClass, - "lTransactions", "J")) == NULL) - { - goto Exit; - } - -Exit: - - return; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_ImportStats_initIDs( - JNIEnv * pEnv, - jclass jImportStatsClass) -{ - - // Get the field IDs for the fields in the class. - - if ((fid_ImportStats_iLines = pEnv->GetFieldID( jImportStatsClass, - "iLines", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iChars = pEnv->GetFieldID( jImportStatsClass, - "iChars", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iAttributes = pEnv->GetFieldID( jImportStatsClass, - "iAttributes", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iElements = pEnv->GetFieldID( jImportStatsClass, - "iElements", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iText = pEnv->GetFieldID( jImportStatsClass, - "iText", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iDocuments = pEnv->GetFieldID( jImportStatsClass, - "iDocuments", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iErrLineNum = pEnv->GetFieldID( jImportStatsClass, - "iErrLineNum", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iErrLineOffset = pEnv->GetFieldID( jImportStatsClass, - "iErrLineOffset", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iErrorType = pEnv->GetFieldID( jImportStatsClass, - "iErrorType", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iErrLineFilePos = pEnv->GetFieldID( jImportStatsClass, - "iErrLineFilePos", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_iErrLineBytes = pEnv->GetFieldID( jImportStatsClass, - "iErrLineBytes", "I")) == NULL) - { - goto Exit; - } - if ((fid_ImportStats_bUTF8Encoding = pEnv->GetFieldID( jImportStatsClass, - "bUTF8Encoding", "Z")) == NULL) - { - goto Exit; - } - -Exit: - - return; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_LockUser_initIDs( - JNIEnv * pEnv, - jclass jIndexStatusClass) -{ - - // Get the field IDs for the fields in the class. - - if ((fid_LockUser_iThreadId = pEnv->GetFieldID( jIndexStatusClass, - "iThreadId", "I")) == NULL) - { - goto Exit; - } - if ((fid_LockUser_iTime = pEnv->GetFieldID( jIndexStatusClass, - "iTime", "I")) == NULL) - { - goto Exit; - } - -Exit: - - return; -} - /**************************************************************************** Desc: ****************************************************************************/ @@ -819,19 +826,22 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getDataType( +JNIEXPORT void JNICALL Java_xflaim_Db__1keyRetrieve( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jint iDictType, - jint iNameId) + jint iIndex, + jlong lSearchKey, + jint iSearchFlags, + jlong lFoundKey) { - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - FLMUINT uiDataType; + RCODE rc = NE_XFLM_OK; + IF_DataVector * pSearchKey = (IF_DataVector *)((FLMUINT)lSearchKey); + IF_DataVector * pFoundKey = (IF_DataVector *)((FLMUINT)lFoundKey); + IF_Db * pDb = THIS_FDB(); - if (RC_BAD( rc = pDb->getDataType( (FLMUINT)iDictType, (FLMUINT)iNameId, - &uiDataType))) + if (RC_BAD( rc = pDb->keyRetrieve( (FLMUINT)iIndex, + pSearchKey, (FLMUINT)iSearchFlags, pFoundKey))) { ThrowError( rc, pEnv); goto Exit; @@ -839,77 +849,57 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getDataType( Exit: - return( (jint)uiDataType); + return; } /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jobject JNICALL Java_xflaim_Db__1import( +JNIEXPORT jlong JNICALL Java_xflaim_Db__1createDocument( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jlong lIStream, - jint iCollection, - jlong lNodeToLinkTo, - jint iInsertLoc) + jint iCollection) { - RCODE rc = NE_XFLM_OK; - IF_IStream * pIStream = (IF_IStream *)((FLMUINT)lIStream); - IF_DOMNode * pNodeToLinkTo = (IF_DOMNode *)((FLMUINT)lNodeToLinkTo); - IF_Db * pDb = THIS_FDB(); - XFLM_IMPORT_STATS importStats; - jclass jImportStatsClass = NULL; - jobject jImportStats = NULL; + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + IF_DOMNode * pNewNode = NULL; - if (!pIStream) - { - ThrowError( NE_XFLM_FAILURE, pEnv); - goto Exit; - } - - if (RC_BAD( rc = pDb->import( pIStream, (FLMUINT)iCollection, - pNodeToLinkTo, (eNodeInsertLoc)iInsertLoc, - &importStats))) + if (RC_BAD( rc = pDb->createDocument((FLMUINT)iCollection, &pNewNode))) { ThrowError( rc, pEnv); goto Exit; } - // Find the ImportStats class - - if ((jImportStatsClass = pEnv->FindClass( "xflaim/ImportStats")) == NULL) - { - goto Exit; - } - - // Allocate an import stats class. - - if ((jImportStats = pEnv->AllocObject( jImportStatsClass)) == NULL) - { - goto Exit; - } - - // Set the fields in the object - - pEnv->SetIntField( jImportStats, fid_ImportStats_iLines, (jint)importStats.uiLines); - pEnv->SetIntField( jImportStats, fid_ImportStats_iChars, (jint)importStats.uiChars); - pEnv->SetIntField( jImportStats, fid_ImportStats_iAttributes, (jint)importStats.uiAttributes); - pEnv->SetIntField( jImportStats, fid_ImportStats_iElements, (jint)importStats.uiElements); - pEnv->SetIntField( jImportStats, fid_ImportStats_iText, (jint)importStats.uiText); - pEnv->SetIntField( jImportStats, fid_ImportStats_iDocuments, (jint)importStats.uiDocuments); - pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineNum, (jint)importStats.uiErrLineNum); - pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineOffset, (jint)importStats.uiErrLineOffset); - pEnv->SetIntField( jImportStats, fid_ImportStats_iErrorType, (jint)importStats.eErrorType); - pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineFilePos, (jint)importStats.uiErrLineFilePos); - pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineBytes, (jint)importStats.uiErrLineBytes); - pEnv->SetBooleanField( jImportStats, fid_ImportStats_bUTF8Encoding, - (jboolean)(importStats.eXMLEncoding == XFLM_XML_UTF8_ENCODING - ? JNI_TRUE - : JNI_FALSE)); Exit: - return( jImportStats); + return( (jlong)((FLMUINT)pNewNode)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1createRootElement( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jint iCollection, + jint iElementNameId) +{ + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + IF_DOMNode * pNewNode = NULL; + + if (RC_BAD( rc = pDb->createRootElement((FLMUINT)iCollection, + (FLMUINT)iElementNameId, &pNewNode))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pNewNode)); } /**************************************************************************** @@ -925,7 +915,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getFirstDocument( RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) : NULL); if (RC_BAD( rc = pDb->getFirstDocument( (FLMUINT)iCollection, &pNewNode))) @@ -936,7 +926,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getFirstDocument( Exit: - return( (jlong)(FLMUINT)pNewNode); + return( (jlong)((FLMUINT)pNewNode)); } /**************************************************************************** @@ -952,7 +942,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getLastDocument( RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) : NULL); if (RC_BAD( rc = pDb->getLastDocument( (FLMUINT)iCollection, &pNewNode))) @@ -963,7 +953,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getLastDocument( Exit: - return( (jlong)(FLMUINT)pNewNode); + return( (jlong)((FLMUINT)pNewNode)); } /**************************************************************************** @@ -974,18 +964,18 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getDocument( jobject, // obj, jlong lThis, jint iCollection, - jint iFlags, + jint iSearchFlags, jlong lDocumentId, jlong lOldNodeRef) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) : NULL); if (RC_BAD( rc = pDb->getDocument( (FLMUINT)iCollection, - (FLMUINT)iFlags, (FLMUINT64)lDocumentId, + (FLMUINT)iSearchFlags, (FLMUINT64)lDocumentId, &pNewNode))) { ThrowError(rc, pEnv); @@ -994,7 +984,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getDocument( Exit: - return( (jlong)(FLMUINT)pNewNode); + return( (jlong)((FLMUINT)pNewNode)); } /**************************************************************************** @@ -1046,197 +1036,6 @@ Exit: return; } -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1getNode( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jint iCollection, - jlong lNodeId, - jlong lOldNodeRef) -{ - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef - : NULL); - - if (RC_BAD( rc = pDb->getNode( (FLMUINT)iCollection, (FLMUINT64)lNodeId, - &pNewNode))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)pNewNode); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1getAttribute( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jint iCollection, - jlong lElementNodeId, - jint iAttrNameId, - jlong lOldNodeRef) -{ - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef - : NULL); - - if (RC_BAD( rc = pDb->getAttribute( (FLMUINT)iCollection, - (FLMUINT64)lElementNodeId, - (FLMUINT)iAttrNameId, &pNewNode))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)pNewNode); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1createDocument( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jint iCollection) -{ - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - IF_DOMNode * ifpNewNode = NULL; - - if (RC_BAD( rc = pDb->createDocument((FLMUINT)iCollection, &ifpNewNode))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)ifpNewNode); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1createRootElement( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jint iCollection, - jint iTag) -{ - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - IF_DOMNode * ifpNewNode = NULL; - - if (RC_BAD( rc = pDb->createRootElement((FLMUINT)iCollection, - (FLMUINT)iTag, &ifpNewNode))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)ifpNewNode); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE getUniString( - JNIEnv * pEnv, - jstring sStr, - F_DynaBuf * pDynaBuf) -{ - RCODE rc = NE_XFLM_OK; - const FLMUNICODE * puzStr = NULL; - FLMUINT uiStrCharCount; - - if (sStr) - { - puzStr = (const FLMUNICODE *)pEnv->GetStringChars( sStr, NULL); - uiStrCharCount = (FLMUINT)pEnv->GetStringLength( sStr); - if (RC_BAD( rc = pDynaBuf->appendData( puzStr, - sizeof( FLMUNICODE) * uiStrCharCount))) - { - goto Exit; - } - if (RC_BAD( rc = pDynaBuf->appendUniChar( 0))) - { - goto Exit; - } - } - else - { - pDynaBuf->truncateData( 0); - } - -Exit: - - if (puzStr) - { - pEnv->ReleaseStringChars( sStr, puzStr); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE getUTF8String( - JNIEnv * pEnv, - jstring sStr, - F_DynaBuf * pDynaBuf) -{ - RCODE rc = NE_XFLM_OK; - const char * pszStr = NULL; - FLMUINT uiStrCharCount; - - if (sStr) - { - pszStr = pEnv->GetStringUTFChars( sStr, NULL); - uiStrCharCount = (FLMUINT)pEnv->GetStringUTFLength( sStr); - if (RC_BAD( rc = pDynaBuf->appendData( pszStr, uiStrCharCount))) - { - goto Exit; - } - } - else - { - pDynaBuf->truncateData( 0); - } - if (RC_BAD( rc = pDynaBuf->appendByte( 0))) - { - goto Exit; - } - -Exit: - - if (pszStr) - { - pEnv->ReleaseStringUTFChars( sStr, pszStr); - } - - return( rc); -} - /**************************************************************************** Desc: ****************************************************************************/ @@ -1286,52 +1085,6 @@ Exit: return( (jint)uiNameId); } -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getElementNameId( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jstring sNamespaceURI, - jstring sElementName) -{ - RCODE rc = NE_XFLM_OK; - IF_Db * pDb = THIS_FDB(); - FLMUINT uiNameId; - FLMBYTE ucNamespaceBuf [200]; - FLMBYTE ucElementNameBuf [200]; - F_DynaBuf namespaceURI( ucNamespaceBuf, sizeof( ucNamespaceBuf)); - F_DynaBuf elementName( ucElementNameBuf, sizeof( ucElementNameBuf)); - - if (sNamespaceURI) - { - if (RC_BAD( rc = getUniString( pEnv, sNamespaceURI, &namespaceURI))) - { - ThrowError( rc, pEnv); - goto Exit; - } - } - - flmAssert( sElementName); - if (RC_BAD( rc = getUniString( pEnv, sElementName, &elementName))) - { - ThrowError( rc, pEnv); - goto Exit; - } - - if (RC_BAD( rc = pDb->getElementNameId( namespaceURI.getUnicodePtr(), - elementName.getUnicodePtr(), &uiNameId))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jint)uiNameId); -} - /**************************************************************************** Desc: ****************************************************************************/ @@ -1380,6 +1133,52 @@ Exit: return( (jint)uiNameId); } +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getElementNameId( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jstring sNamespaceURI, + jstring sElementName) +{ + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + FLMUINT uiNameId; + FLMBYTE ucNamespaceBuf [200]; + FLMBYTE ucElementNameBuf [200]; + F_DynaBuf namespaceURI( ucNamespaceBuf, sizeof( ucNamespaceBuf)); + F_DynaBuf elementName( ucElementNameBuf, sizeof( ucElementNameBuf)); + + if (sNamespaceURI) + { + if (RC_BAD( rc = getUniString( pEnv, sNamespaceURI, &namespaceURI))) + { + ThrowError( rc, pEnv); + goto Exit; + } + } + + flmAssert( sElementName); + if (RC_BAD( rc = getUniString( pEnv, sElementName, &elementName))) + { + ThrowError( rc, pEnv); + goto Exit; + } + + if (RC_BAD( rc = pDb->getElementNameId( namespaceURI.getUnicodePtr(), + elementName.getUnicodePtr(), &uiNameId))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jint)uiNameId); +} + /**************************************************************************** Desc: ****************************************************************************/ @@ -1727,6 +1526,45 @@ Exit: return( (jint)uiNameId); } +/**************************************************************************** +Desc: +****************************************************************************/ +FSTATIC RCODE mapDictType( + jint iDictType, + FLMUINT * puiDictType) +{ + RCODE rc = NE_XFLM_OK; + + switch (iDictType) + { + case ELEMENT_DEF: + *puiDictType = ELM_ELEMENT_TAG; + break; + case ATTRIBUTE_DEF: + *puiDictType = ELM_ATTRIBUTE_TAG; + break; + case PREFIX_DEF: + *puiDictType = ELM_PREFIX_TAG; + break; + case ENCRYPTION_DEF: + *puiDictType = ELM_ENCDEF_TAG; + break; + case COLLECTION_DEF: + *puiDictType = ELM_COLLECTION_TAG; + break; + case INDEX_DEF: + *puiDictType = ELM_INDEX_TAG; + break; + default: + rc = RC_SET( NE_XFLM_INVALID_PARM); + goto Exit; + } + +Exit: + + return( rc); +} + /**************************************************************************** Desc: ****************************************************************************/ @@ -1741,10 +1579,17 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getDictionaryDef( RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef - ? (IF_DOMNode *)(FLMUINT)lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) : NULL); + FLMUINT uiDictType = 0; + + if (RC_BAD( rc = mapDictType( iDictType, &uiDictType))) + { + ThrowError(rc, pEnv); + goto Exit; + } - if (RC_BAD( rc = pDb->getDictionaryDef( (FLMUINT)iDictType, + if (RC_BAD( rc = pDb->getDictionaryDef( uiDictType, (FLMUINT)iDictNumber, &pNewNode))) { ThrowError(rc, pEnv); @@ -1753,7 +1598,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getDictionaryDef( Exit: - return( (jlong)(FLMUINT)pNewNode); + return( (jlong)((FLMUINT)pNewNode)); } /**************************************************************************** @@ -1761,7 +1606,7 @@ Desc: ****************************************************************************/ FSTATIC RCODE getDictName( IF_Db * pDb, - FLMUINT uiDictType, + jint iDictType, FLMUINT uiDictNumber, FLMBOOL bGetNamespace, F_DynaBuf * pDynaBuf) @@ -1769,6 +1614,12 @@ FSTATIC RCODE getDictName( RCODE rc = NE_XFLM_OK; FLMUINT uiNameSize = 0; FLMUNICODE * puzName = NULL; + FLMUINT uiDictType = 0; + + if (RC_BAD( rc = mapDictType( iDictType, &uiDictType))) + { + goto Exit; + } // Determine how much space is needed to get the name. @@ -1845,7 +1696,7 @@ JNIEXPORT jstring JNICALL Java_xflaim_Db__1getDictionaryName( F_DynaBuf nameBuf( ucNameBuf, sizeof( ucNameBuf)); jstring jName = NULL; - if (RC_BAD( rc = getDictName( pDb, (FLMUINT)iDictType, (FLMUINT)iDictNumber, + if (RC_BAD( rc = getDictName( pDb, iDictType, (FLMUINT)iDictNumber, FALSE, &nameBuf))) { ThrowError(rc, pEnv); @@ -1877,7 +1728,7 @@ JNIEXPORT jstring JNICALL Java_xflaim_Db__1getElementNamespace( F_DynaBuf nameBuf( ucNameBuf, sizeof( ucNameBuf)); jstring jName = NULL; - if (RC_BAD( rc = getDictName( pDb, ELM_ELEMENT_TAG, (FLMUINT)iDictNumber, + if (RC_BAD( rc = getDictName( pDb, ELEMENT_DEF, (FLMUINT)iDictNumber, TRUE, &nameBuf))) { ThrowError(rc, pEnv); @@ -1909,7 +1760,7 @@ JNIEXPORT jstring JNICALL Java_xflaim_Db__1getAttributeNamespace( F_DynaBuf nameBuf( ucNameBuf, sizeof( ucNameBuf)); jstring jName = NULL; - if (RC_BAD( rc = getDictName( pDb, ELM_ATTRIBUTE_TAG, (FLMUINT)iDictNumber, + if (RC_BAD( rc = getDictName( pDb, ATTRIBUTE_DEF, (FLMUINT)iDictNumber, TRUE, &nameBuf))) { ThrowError(rc, pEnv); @@ -1926,6 +1777,99 @@ Exit: return( jName); } +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1getNode( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jint iCollection, + jlong lNodeId, + jlong lOldNodeRef) +{ + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) + : NULL); + + if (RC_BAD( rc = pDb->getNode( (FLMUINT)iCollection, (FLMUINT64)lNodeId, + &pNewNode))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pNewNode)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1getAttribute( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jint iCollection, + jlong lElementNodeId, + jint iAttrNameId, + jlong lOldNodeRef) +{ + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + IF_DOMNode * pNewNode = (IF_DOMNode *)(lOldNodeRef + ? (IF_DOMNode *)((FLMUINT)lOldNodeRef) + : NULL); + + if (RC_BAD( rc = pDb->getAttribute( (FLMUINT)iCollection, + (FLMUINT64)lElementNodeId, + (FLMUINT)iAttrNameId, &pNewNode))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pNewNode)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getDataType( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jint iDictType, + jint iDictNumber) +{ + RCODE rc = NE_XFLM_OK; + IF_Db * pDb = THIS_FDB(); + FLMUINT uiDataType; + FLMUINT uiDictType = 0; + + if (RC_BAD( rc = mapDictType( iDictType, &uiDictType))) + { + ThrowError( rc, pEnv); + goto Exit; + } + + if (RC_BAD( rc = pDb->getDataType( uiDictType, (FLMUINT)iDictNumber, + &uiDataType))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jint)uiDataType); +} + /**************************************************************************** Desc: ****************************************************************************/ @@ -1933,22 +1877,19 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1backupBegin( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jint eBackupType, - jint eTransType, + jint iBackupType, + jint iTransType, jint iMaxLockWait, jlong lReusedRef) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); - IF_Backup * ifpBackup = NULL; + IF_Backup * pBackup = lReusedRef + ? (IF_Backup *)((FLMUINT)lReusedRef) + : NULL; - if (lReusedRef) - { - ifpBackup = (IF_Backup *)(FLMUINT)lReusedRef; - } - - if (RC_BAD( rc = pDb->backupBegin( (eDbBackupType)eBackupType, - (eDbTransType)eTransType, (FLMUINT)iMaxLockWait, &ifpBackup))) + if (RC_BAD( rc = pDb->backupBegin( (eDbBackupType)iBackupType, + (eDbTransType)iTransType, (FLMUINT)iMaxLockWait, &pBackup))) { ThrowError( rc, pEnv); goto Exit; @@ -1956,37 +1897,77 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1backupBegin( Exit: - return( (jlong)(FLMUINT)ifpBackup); + return( (jlong)((FLMUINT)pBackup)); } /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_Db__1keyRetrieve( +JNIEXPORT jobject JNICALL Java_xflaim_Db__1import( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jint iIndex, - jlong lKey, - jint iFlags, - jlong lFoundKey) + jlong lIStream, + jint iCollection, + jlong lNodeToLinkTo, + jint iInsertLoc) { - RCODE rc = NE_XFLM_OK; - IF_DataVector * pSearchKey = (IF_DataVector *)(FLMUINT)lKey; - IF_DataVector * pFoundKey = (IF_DataVector *)(FLMUINT)lFoundKey; - IF_Db * pDb = THIS_FDB(); - FLMUINT uiIndex = (FLMUINT)iIndex; - FLMUINT uiFlags = (FLMUINT)iFlags; + RCODE rc = NE_XFLM_OK; + IF_IStream * pIStream = (IF_IStream *)((FLMUINT)lIStream); + IF_DOMNode * pNodeToLinkTo = (IF_DOMNode *)((FLMUINT)lNodeToLinkTo); + IF_Db * pDb = THIS_FDB(); + XFLM_IMPORT_STATS importStats; + jclass jImportStatsClass = NULL; + jobject jImportStats = NULL; - if (RC_BAD( rc = pDb->keyRetrieve( uiIndex, pSearchKey, uiFlags, pFoundKey))) + if (!pIStream) + { + ThrowError( NE_XFLM_FAILURE, pEnv); + goto Exit; + } + + if (RC_BAD( rc = pDb->import( pIStream, (FLMUINT)iCollection, + pNodeToLinkTo, (eNodeInsertLoc)iInsertLoc, + &importStats))) { ThrowError( rc, pEnv); goto Exit; } + + // Find the ImportStats class + + if ((jImportStatsClass = pEnv->FindClass( "xflaim/ImportStats")) == NULL) + { + goto Exit; + } + + // Allocate an import stats class. + if ((jImportStats = pEnv->AllocObject( jImportStatsClass)) == NULL) + { + goto Exit; + } + + // Set the fields in the object + + pEnv->SetIntField( jImportStats, fid_ImportStats_iLines, (jint)importStats.uiLines); + pEnv->SetIntField( jImportStats, fid_ImportStats_iChars, (jint)importStats.uiChars); + pEnv->SetIntField( jImportStats, fid_ImportStats_iAttributes, (jint)importStats.uiAttributes); + pEnv->SetIntField( jImportStats, fid_ImportStats_iElements, (jint)importStats.uiElements); + pEnv->SetIntField( jImportStats, fid_ImportStats_iText, (jint)importStats.uiText); + pEnv->SetIntField( jImportStats, fid_ImportStats_iDocuments, (jint)importStats.uiDocuments); + pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineNum, (jint)importStats.uiErrLineNum); + pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineOffset, (jint)importStats.uiErrLineOffset); + pEnv->SetIntField( jImportStats, fid_ImportStats_iErrorType, (jint)importStats.eErrorType); + pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineFilePos, (jint)importStats.uiErrLineFilePos); + pEnv->SetIntField( jImportStats, fid_ImportStats_iErrLineBytes, (jint)importStats.uiErrLineBytes); + pEnv->SetBooleanField( jImportStats, fid_ImportStats_bUTF8Encoding, + (jboolean)(importStats.eXMLEncoding == XFLM_XML_UTF8_ENCODING + ? JNI_TRUE + : JNI_FALSE)); Exit: - return; + return( jImportStats); } /**************************************************************************** @@ -2004,6 +1985,13 @@ JNIEXPORT void JNICALL Java_xflaim_Db__1changeItemState( IF_Db * pDb = THIS_FDB(); FLMBYTE ucState [80]; F_DynaBuf stateBuf( ucState, sizeof( ucState)); + FLMUINT uiDictType = 0; + + if (RC_BAD( rc = mapDictType( iDictType, &uiDictType))) + { + ThrowError( rc, pEnv); + goto Exit; + } if (RC_BAD( rc = getUTF8String( pEnv, sState, &stateBuf))) { @@ -2011,8 +1999,7 @@ JNIEXPORT void JNICALL Java_xflaim_Db__1changeItemState( goto Exit; } - if (RC_BAD( rc = pDb->changeItemState( (FLMUINT)iDictType, - (FLMUINT)iDictNum, + if (RC_BAD( rc = pDb->changeItemState( uiDictType, (FLMUINT)iDictNum, (const char *)stateBuf.getBufferPtr()))) { ThrowError( rc, pEnv); @@ -2077,13 +2064,19 @@ JNIEXPORT void JNICALL Java_xflaim_Db__1setNextDictNum( jobject, // obj, jlong lThis, jint iDictType, - jint iDictNumber) + jint iNextDictNumber) { RCODE rc = NE_XFLM_OK; IF_Db * pDb = THIS_FDB(); + FLMUINT uiDictType = 0; - if (RC_BAD( rc = pDb->setNextDictNum( (FLMUINT)iDictType, - (FLMUINT)iDictNumber))) + if (RC_BAD( rc = mapDictType( iDictType, &uiDictType))) + { + ThrowError( rc, pEnv); + goto Exit; + } + + if (RC_BAD( rc = pDb->setNextDictNum( uiDictType, (FLMUINT)iNextDictNumber))) { ThrowError( rc, pEnv); goto Exit; diff --git a/xflaim/java/jni/jniftk.cpp b/xflaim/java/jni/jniftk.cpp index 5786f58..1954226 100644 --- a/xflaim/java/jni/jniftk.cpp +++ b/xflaim/java/jni/jniftk.cpp @@ -50,3 +50,85 @@ void ThrowError( pEnv->Throw( reinterpret_cast(Exception)); } + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE getUniString( + JNIEnv * pEnv, + jstring sStr, + F_DynaBuf * pDynaBuf) +{ + RCODE rc = NE_XFLM_OK; + const FLMUNICODE * puzStr = NULL; + FLMUINT uiStrCharCount; + + if (sStr) + { + puzStr = (const FLMUNICODE *)pEnv->GetStringChars( sStr, NULL); + uiStrCharCount = (FLMUINT)pEnv->GetStringLength( sStr); + if (RC_BAD( rc = pDynaBuf->appendData( puzStr, + sizeof( FLMUNICODE) * uiStrCharCount))) + { + goto Exit; + } + if (RC_BAD( rc = pDynaBuf->appendUniChar( 0))) + { + goto Exit; + } + } + else + { + pDynaBuf->truncateData( 0); + } + +Exit: + + if (puzStr) + { + pEnv->ReleaseStringChars( sStr, puzStr); + } + + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE getUTF8String( + JNIEnv * pEnv, + jstring sStr, + F_DynaBuf * pDynaBuf) +{ + RCODE rc = NE_XFLM_OK; + const char * pszStr = NULL; + FLMUINT uiStrCharCount; + + if (sStr) + { + pszStr = pEnv->GetStringUTFChars( sStr, NULL); + uiStrCharCount = (FLMUINT)pEnv->GetStringUTFLength( sStr); + if (RC_BAD( rc = pDynaBuf->appendData( pszStr, uiStrCharCount))) + { + goto Exit; + } + } + else + { + pDynaBuf->truncateData( 0); + } + if (RC_BAD( rc = pDynaBuf->appendByte( 0))) + { + goto Exit; + } + +Exit: + + if (pszStr) + { + pEnv->ReleaseStringUTFChars( sStr, pszStr); + } + + return( rc); +} + diff --git a/xflaim/java/jni/xflaim_Db.h b/xflaim/java/jni/xflaim_Db.h index 66a8c19..aeff146 100644 --- a/xflaim/java/jni/xflaim_Db.h +++ b/xflaim/java/jni/xflaim_Db.h @@ -7,126 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: xflaim_Db - * Method: _dbLock - * Signature: (JIII)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1dbLock - (JNIEnv *, jobject, jlong, jint, jint, jint); - -/* - * Class: xflaim_Db - * Method: _dbUnlock - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1dbUnlock - (JNIEnv *, jobject, jlong); - -/* - * Class: xflaim_Db - * Method: _getLockType - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockType - (JNIEnv *, jobject, jlong); - -/* - * Class: xflaim_Db - * Method: _getLockImplicit - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_xflaim_Db__1getLockImplicit - (JNIEnv *, jobject, jlong); - -/* - * Class: xflaim_Db - * Method: _getLockThreadId - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockThreadId - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _getLockNumExclQueued - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumExclQueued - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _getLockNumSharedQueued - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumSharedQueued - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _getLockPriorityCount - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockPriorityCount - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _indexSuspend - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1indexSuspend - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _indexResume - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1indexResume - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _indexGetNext - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1indexGetNext - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _indexStatus - * Signature: (JI)Lxflaim/IndexStatus; - */ -JNIEXPORT jobject JNICALL Java_xflaim_Db__1indexStatus - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _reduceSize - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1reduceSize - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _documentDone - * Signature: (JIJ)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1documentDone__JIJ - (JNIEnv *, jobject, jlong, jint, jlong); - -/* - * Class: xflaim_Db - * Method: _documentDone - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL Java_xflaim_Db__1documentDone__JJ - (JNIEnv *, jobject, jlong, jlong); - /* * Class: xflaim_Db * Method: _release @@ -185,11 +65,131 @@ JNIEXPORT void JNICALL Java_xflaim_Db__1doCheckpoint /* * Class: xflaim_Db - * Method: _import - * Signature: (JJIJI)Lxflaim/ImportStats; + * Method: _dbLock + * Signature: (JIII)V */ -JNIEXPORT jobject JNICALL Java_xflaim_Db__1import - (JNIEnv *, jobject, jlong, jlong, jint, jlong, jint); +JNIEXPORT void JNICALL Java_xflaim_Db__1dbLock + (JNIEnv *, jobject, jlong, jint, jint, jint); + +/* + * Class: xflaim_Db + * Method: _dbUnlock + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_xflaim_Db__1dbUnlock + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockType + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockType + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockImplicit + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_xflaim_Db__1getLockImplicit + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockThreadId + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockThreadId + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockNumExclQueued + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumExclQueued + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockNumSharedQueued + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockNumSharedQueued + (JNIEnv *, jobject, jlong); + +/* + * Class: xflaim_Db + * Method: _getLockPriorityCount + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getLockPriorityCount + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _indexSuspend + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_xflaim_Db__1indexSuspend + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _indexResume + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_xflaim_Db__1indexResume + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _indexGetNext + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1indexGetNext + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _indexStatus + * Signature: (JI)Lxflaim/IndexStatus; + */ +JNIEXPORT jobject JNICALL Java_xflaim_Db__1indexStatus + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _reduceSize + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1reduceSize + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _keyRetrieve + * Signature: (JIJIJ)V + */ +JNIEXPORT void JNICALL Java_xflaim_Db__1keyRetrieve + (JNIEnv *, jobject, jlong, jint, jlong, jint, jlong); + +/* + * Class: xflaim_Db + * Method: _createDocument + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1createDocument + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: xflaim_Db + * Method: _createRootElement + * Signature: (JII)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1createRootElement + (JNIEnv *, jobject, jlong, jint, jint); /* * Class: xflaim_Db @@ -217,35 +217,19 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1getDocument /* * Class: xflaim_Db - * Method: _getNode - * Signature: (JIJJ)J + * Method: _documentDone + * Signature: (JIJ)V */ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1getNode - (JNIEnv *, jobject, jlong, jint, jlong, jlong); +JNIEXPORT void JNICALL Java_xflaim_Db__1documentDone__JIJ + (JNIEnv *, jobject, jlong, jint, jlong); /* * Class: xflaim_Db - * Method: _getAttribute - * Signature: (JIJIJ)J + * Method: _documentDone + * Signature: (JJ)V */ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1getAttribute - (JNIEnv *, jobject, jlong, jint, jlong, jint, jlong); - -/* - * Class: xflaim_Db - * Method: _createDocument - * Signature: (JI)J - */ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1createDocument - (JNIEnv *, jobject, jlong, jint); - -/* - * Class: xflaim_Db - * Method: _createRootElement - * Signature: (JII)J - */ -JNIEXPORT jlong JNICALL Java_xflaim_Db__1createRootElement - (JNIEnv *, jobject, jlong, jint, jint); +JNIEXPORT void JNICALL Java_xflaim_Db__1documentDone__JJ + (JNIEnv *, jobject, jlong, jlong); /* * Class: xflaim_Db @@ -255,14 +239,6 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1createRootElement JNIEXPORT jint JNICALL Java_xflaim_Db__1createElementDef (JNIEnv *, jobject, jlong, jstring, jstring, jint, jint); -/* - * Class: xflaim_Db - * Method: _getElementNameId - * Signature: (JLjava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_xflaim_Db__1getElementNameId - (JNIEnv *, jobject, jlong, jstring, jstring); - /* * Class: xflaim_Db * Method: _createUniqueElmDef @@ -271,6 +247,14 @@ JNIEXPORT jint JNICALL Java_xflaim_Db__1getElementNameId JNIEXPORT jint JNICALL Java_xflaim_Db__1createUniqueElmDef (JNIEnv *, jobject, jlong, jstring, jstring, jint); +/* + * Class: xflaim_Db + * Method: _getElementNameId + * Signature: (JLjava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_xflaim_Db__1getElementNameId + (JNIEnv *, jobject, jlong, jstring, jstring); + /* * Class: xflaim_Db * Method: _createAttributeDef @@ -375,6 +359,22 @@ JNIEXPORT jstring JNICALL Java_xflaim_Db__1getElementNamespace JNIEXPORT jstring JNICALL Java_xflaim_Db__1getAttributeNamespace (JNIEnv *, jobject, jlong, jint); +/* + * Class: xflaim_Db + * Method: _getNode + * Signature: (JIJJ)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1getNode + (JNIEnv *, jobject, jlong, jint, jlong, jlong); + +/* + * Class: xflaim_Db + * Method: _getAttribute + * Signature: (JIJIJ)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_Db__1getAttribute + (JNIEnv *, jobject, jlong, jint, jlong, jint, jlong); + /* * Class: xflaim_Db * Method: _getDataType @@ -393,11 +393,11 @@ JNIEXPORT jlong JNICALL Java_xflaim_Db__1backupBegin /* * Class: xflaim_Db - * Method: _keyRetrieve - * Signature: (JIJIJ)V + * Method: _import + * Signature: (JJIJI)Lxflaim/ImportStats; */ -JNIEXPORT void JNICALL Java_xflaim_Db__1keyRetrieve - (JNIEnv *, jobject, jlong, jint, jlong, jint, jlong); +JNIEXPORT jobject JNICALL Java_xflaim_Db__1import + (JNIEnv *, jobject, jlong, jlong, jint, jlong, jint); /* * Class: xflaim_Db diff --git a/xflaim/java/jni/xflaim_DictType.h b/xflaim/java/jni/xflaim_DictType.h new file mode 100644 index 0000000..3171c4e --- /dev/null +++ b/xflaim/java/jni/xflaim_DictType.h @@ -0,0 +1,25 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class xflaim_DictType */ + +#ifndef _Included_xflaim_DictType +#define _Included_xflaim_DictType +#ifdef __cplusplus +extern "C" { +#endif +#undef xflaim_DictType_ELEMENT_DEF +#define xflaim_DictType_ELEMENT_DEF 1L +#undef xflaim_DictType_ATTRIBUTE_DEF +#define xflaim_DictType_ATTRIBUTE_DEF 2L +#undef xflaim_DictType_PREFIX_DEF +#define xflaim_DictType_PREFIX_DEF 3L +#undef xflaim_DictType_ENCRYPTION_DEF +#define xflaim_DictType_ENCRYPTION_DEF 4L +#undef xflaim_DictType_COLLECTION_DEF +#define xflaim_DictType_COLLECTION_DEF 5L +#undef xflaim_DictType_INDEX_DEF +#define xflaim_DictType_INDEX_DEF 6L +#ifdef __cplusplus +} +#endif +#endif diff --git a/xflaim/java/jni/xflaim_LockType.h b/xflaim/java/jni/xflaim_LockType.h new file mode 100644 index 0000000..d1944a6 --- /dev/null +++ b/xflaim/java/jni/xflaim_LockType.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class xflaim_LockType */ + +#ifndef _Included_xflaim_LockType +#define _Included_xflaim_LockType +#ifdef __cplusplus +extern "C" { +#endif +#undef xflaim_LockType_FLM_LOCK_NONE +#define xflaim_LockType_FLM_LOCK_NONE 0L +#undef xflaim_LockType_FLM_LOCK_EXCLUSIVE +#define xflaim_LockType_FLM_LOCK_EXCLUSIVE 1L +#undef xflaim_LockType_FLM_LOCK_SHARED +#define xflaim_LockType_FLM_LOCK_SHARED 2L +#ifdef __cplusplus +} +#endif +#endif diff --git a/xflaim/java/xflaim/Db.java b/xflaim/java/xflaim/Db.java index 40fdf87..07b15f4 100644 --- a/xflaim/java/xflaim/Db.java +++ b/xflaim/java/xflaim/Db.java @@ -90,26 +90,34 @@ public class Db /** * Starts a transaction. * - * @param eTransactionType The type of transaction to start (read or + * @param iTransactionType The type of transaction to start (read or * write). Should be one of the members of {@link * xflaim.TransactionType TransactionType}. * @param iMaxLockWait Maximum lock wait time. Specifies the amount of * time to wait for lock requests occuring during the transaction to be * granted. Valid values are 0 through 255 seconds. Zero is used to - * specify no-wait locks. + * specify no-wait locks. 255 specifies that there is no timeout. * @param iFlags Should be a logical OR'd combination of the members of * the memers of {@link xflaim.TransactionFlags * TransactionFlags}. * @throws XFlaimException */ public void transBegin( - int eTransactionType, + int iTransactionType, int iMaxLockWait, int iFlags) throws XFlaimException { - _transBegin( m_this, eTransactionType, iMaxLockWait, iFlags); + _transBegin( m_this, iTransactionType, iMaxLockWait, iFlags); } + /** + * Starts a transaction. Transaction will be of the same type and same + * snapshot as the passed in Db object. The passed in Db object should + * be running a read transaction. + * + * @param Db Database whose transaction is to be copied. + * @throws XFlaimException + */ public void transBegin( Db jdb) throws XFlaimException { @@ -126,42 +134,8 @@ public class Db _transCommit( m_this); } - public int getTransType() throws XFlaimException - { - return( _getTransType( m_this)); - } - - public void doCheckpoint( - int iTimeout) throws XFlaimException - { - _doCheckpoint( m_this, iTimeout); - } - - private native void _dbLock( - long lThis, - int iLockType, - int iPriority, - int iTimeout) throws XFlaimException; - - public void dbLock( - int iLockType, - int iPriority, - int iTimeout) throws XFlaimException - { - _dbLock( m_this, iLockType, iPriority, iTimeout); - } - - private native void _dbUnlock( - long lThis) throws XFlaimException; - - public void dbUnlock() throws XFlaimException - { - _dbUnlock( m_this); - } - /** - * Aborts an existing transaction. If no transaction is running, or the - * transaction commit fails, an XFlaimException exception will be thrown. + * Aborts an existing transaction. * * @throws XFlaimException */ @@ -170,106 +144,190 @@ public class Db _transAbort( m_this); } - private native int _getLockType( - long lThis) throws XFlaimException; + /** + * Get the current transaction type. + * @return Returns the type of transaction. Should be one of + * the members of {@link xflaim.TransactionType TransactionType}. + * @throws XFlaimException + */ + public int getTransType() throws XFlaimException + { + return( _getTransType( m_this)); + } + + /** + * Perform a checkpoint on the database. + * @param iTimeout lock wait time. Specifies the amount of + * time to wait for database lock. Valid values are 0 through 255 seconds. + * Zero is used to specify no-wait locks. 255 is used to specify that there + * is no timeout. + * @param iTimeoutGet the current transaction type. + * @return Returns the type of transaction. Should be one of + * the members of {@link xflaim.TransactionType TransactionType}. + * @throws XFlaimException + */ + public void doCheckpoint( + int iTimeout) throws XFlaimException + { + _doCheckpoint( m_this, iTimeout); + } + /** + * Lock the database. + * @param iLockType Type of lock being requested. Should be one of the + * values in {@link xflaim.LockType LockType}. + * @param iPriority Priority of lock being requested. + * @param iTimeout lock wait time. Specifies the amount of + * time to wait for database lock. Valid values are 0 through 255 seconds. + * Zero is used to specify no-wait locks. 255 is used to specify that there + * is no timeout. + * @throws XFlaimException + */ + public void dbLock( + int iLockType, + int iPriority, + int iTimeout) throws XFlaimException + { + _dbLock( m_this, iLockType, iPriority, iTimeout); + } + + /** + * Unlock the database. + * @throws XFlaimException + */ + public void dbUnlock() throws XFlaimException + { + _dbUnlock( m_this); + } + + /** + * Get the type of database lock current held. + * @return Returns type of database lock currently held. Should be one of the + * values in {@link xflaim.LockType LockType}. + * @throws XFlaimException + */ public int getLockType() throws XFlaimException { return( _getLockType( m_this)); } - private native boolean _getLockImplicit( - long lThis) throws XFlaimException; - + /** + * Determine if the database lock was implicitly obtained (i.e., obtained + * when transBegin was called as opposed to dbLock). + * @return Returns whether lock was obtained implicitly or explicitly. + * @throws XFlaimException + */ public boolean getLockImplicit() throws XFlaimException { return( _getLockImplicit( m_this)); } - private native int _getLockThreadId( - long lThis, - int iPriority) throws XFlaimException; - - public int getLockThreadId( - int iPriority) throws XFlaimException + /** + * Returns the thread id of the thread that currently holds the database + * lock at the specified priority. + * @return Returns thread ID. + * @throws XFlaimException + */ + public int getLockThreadId() throws XFlaimException { - return( _getLockThreadId( m_this, iPriority)); + return( _getLockThreadId( m_this)); } - private native int _getLockNumExclQueued( - long lThis, - int iPriority) throws XFlaimException; - - public int getLockNumExclQueued( - int iPriority) throws XFlaimException + /** + * Returns the number of threads that are currently waiting to obtain + * an exclusive database lock. + * @return Returns number of threads waiting for exclusive lock. + * @throws XFlaimException + */ + public int getLockNumExclQueued() throws XFlaimException { - return( _getLockNumExclQueued( m_this, iPriority)); + return( _getLockNumExclQueued( m_this)); } - private native int _getLockNumSharedQueued( - long lThis, - int iPriority) throws XFlaimException; - - public int getLockNumSharedQueued( - int iPriority) throws XFlaimException + /** + * Returns the number of threads that are currently waiting to obtain + * a shared database lock. + * @return Returns number of threads waiting for shared lock. + * @throws XFlaimException + */ + public int getLockNumSharedQueued() throws XFlaimException { - return( _getLockNumSharedQueued( m_this, iPriority)); + return( _getLockNumSharedQueued( m_this)); } - private native int _getLockPriorityCount( - long lThis, - int iPriority) throws XFlaimException; - + /** + * Returns the number of threads that are currently waiting to obtain + * a database lock whose priority is >= iPriority. + * @param iPriority Priority to look for - a count of all waiting threads with a + * lock priority greater than or equal to this will be returned. + * @return Returns number of threads waiting for a database lock whose + * priority is >= iPriority. + * @throws XFlaimException + */ public int getLockPriorityCount( int iPriority) throws XFlaimException { return( _getLockPriorityCount( m_this, iPriority)); } - private native void _indexSuspend( - long lThis, - int iIndex) throws XFlaimException; - + /** + * Suspend indexing on the specified index. + * @param iIndex Index to be suspended. + * @throws XFlaimException + */ public void indexSuspend( int iIndex) throws XFlaimException { _indexSuspend( m_this, iIndex); } - private native void _indexResume( - long lThis, - int iIndex) throws XFlaimException; - + /** + * Resume indexing on the specified index. + * @param iIndex Index to be resumed. + * @throws XFlaimException + */ public void indexResume( int iIndex) throws XFlaimException { _indexResume( m_this, iIndex); } - private native int _indexGetNext( - long lThis, - int iCurrIndex) throws XFlaimException; - + /** + * This method provides a way to iterate through all of the indexes in the + * database. It returns the index ID of the index that comes after the + * passed in index number. The first index can be obtained by passing in a + * zero. + * @param iCurrIndex Current index number. Index that comes after this one + * will be returned. + * @return Returns the index ID of the index that comes after iCurrIndex. + * @throws XFlaimException + */ public int indexGetNext( int iCurrIndex) throws XFlaimException { return( _indexGetNext( m_this, iCurrIndex)); } - private native IndexStatus _indexStatus( - long lThis, - int iIndex) throws XFlaimException; - + /** + * Returns status information on an index in an {@link xflaim.IndexStatus IndexStatus} + * object. + * @param iIndex Index whose status is to be returned. + * @return Returns an {@link xflaim.IndexStatus IndexStatus} object. + * @throws XFlaimException + */ public IndexStatus indexStatus( int iIndex) throws XFlaimException { return( _indexStatus( m_this, iIndex)); } - private native int _reduceSize( - long lThis, - int iCount) throws XFlaimException; - + /** + * Return unused blocks back to the file system. + * @param iCount Maximum number of blocks to be returned. + * @return Returns the number of blocks that were actually returned to the + * file system. + * @throws XFlaimException + */ public int reduceSize( int iCount) throws XFlaimException { @@ -277,38 +335,38 @@ public class Db } /** - * Uses the jSearchKey to retrieve the next key from the specified - * index. - * - * @param iIndex The index that is being searched - * @param jSearchKey The DataVector search key - * @param iFlags The search flags that direct how the next key will + * Lookup/retrieve keys in an index. + * @param iIndex The index that is being searched. + * @param searchKey The search key that is to be looked up. NOTE: This + * parameter may be ignored, depending on the iFlags parameter. See + * {@link xflaim.DataVector DataVector} for information on the DataVector class. + * @param iSearchFlags The search flags that direct how the next key will * be determined. This should be values from * {@link xflaim.SearchFlags SearchFlags} that are ORed together. - * @param jFoundKey This parameter is used during subsequent calls - * to keyRetrieve. The returned DataVector is passed in as this - * parameter so that it may be reused, thus preventing the unnecessary - * accumulation of IF_DataVector objects in the C++ environment. + * @param foundKey Key that was found is returned here. This parameter may be + * used during subsequent calls to keyRetrieve. The returned DataVector + * is passed in as this parameter so that it may be reused, thus preventing + * the unnecessary accumulation of IF_DataVector objects in the C++ environment. + * @throws XFlaimException */ public void keyRetrieve( int iIndex, - DataVector jSearchKey, - int iFlags, - DataVector jFoundKey) throws XFlaimException + DataVector searchKey, + int iSearchFlags, + DataVector foundKey) throws XFlaimException { - long lKey = jSearchKey.m_this; - long lFoundKey = (jFoundKey == null ? 0 : jFoundKey.m_this); + long lSearchKey = (searchKey == null ? 0 : searchKey.m_this); + long lFoundKey = (foundKey == null ? 0 : foundKey.m_this); - _keyRetrieve( m_this, iIndex, lKey, iFlags, lFoundKey); + _keyRetrieve( m_this, iIndex, lSearchKey, iSearchFlags, lFoundKey); } /** * Creates a new document node. * @param iCollection The collection to store the new document in. - * @return Returns the DOMNode representing the new document. + * @return Returns the (@link xflaim.DOMNode DOMNode} representing the new document. * @throws XFlaimException */ - public DOMNode createDocument( int iCollection) throws XFlaimException { @@ -328,14 +386,15 @@ public class Db /** * Creates a new root element node. This is the root node of a document * in the XFlaim database. - * @param iCollection - * @param iTag - * @return + * @param iCollection The collection to store the new node in. + * @param iElementNameId Name of the element to be created. + * @return Returns the (@link xflaim.DOMNode DOMNode} representing the + * root element node. * @throws XFlaimException */ public DOMNode createRootElement( int iCollection, - int iTag) throws XFlaimException + int iElementNameId) throws XFlaimException { long lNewDocRef; @@ -344,28 +403,28 @@ public class Db synchronized( this) { - lNewDocRef = _createRootElement( m_this, iCollection, iTag); + lNewDocRef = _createRootElement( m_this, iCollection, iElementNameId); } return (new DOMNode( lNewDocRef, this)); } /** - * Method to retrieve the first document in a specified collection. + * Retrieve the first document in a specified collection. * @param iCollection - The collection from which to retrieve the * first document - * @param jDOMNode - If this parameter is non-null, it will be assumed - * that it is no longer needed and will be rendered unusable upon - * returning from this method. - * @return - Returns a DOMNode which is the root node of the requested - * document. + * @param ReusedNode An existing {@link xflaim.DOMNode DOMNode} object + * can optionally be passed in, and it will be reused instead of a new + * object being allocated. + * @return - Returns a {@link xflaim.DOMNode DOMNode) which is the root node + * of the requested document. * @throws XFlaimException */ public DOMNode getFirstDocument( int iCollection, DOMNode ReusedNode) throws XFlaimException { - DOMNode jNode = null; + DOMNode newNode = null; long lNewNodeRef = 0; long lReusedNodeRef = 0; @@ -390,33 +449,33 @@ public class Db if (ReusedNode != null) { ReusedNode.setRef( lNewNodeRef, this); - jNode = ReusedNode; + newNode = ReusedNode; } else { - jNode = new DOMNode( lNewNodeRef, this); + newNode = new DOMNode( lNewNodeRef, this); } } - return( jNode); + return( newNode); } /** - * Method to retrieve the last document in a specified collection. + * Retrieve the last document in a specified collection. * @param iCollection - The collection from which to retrieve the - * last document - * @param jDOMNode - If this parameter is non-null, it will be assumed - * that it is no longer needed and will be rendered unusable upon - * returning from this method. - * @return - Returns a DOMNode which is the root node of the requested - * document. + * last document. + * @param ReusedNode An existing {@link xflaim.DOMNode DOMNode} object + * can optionally be passed in, and it will be reused instead of a new + * object being allocated. + * @return - Returns a {@link xflaim.DOMNode DOMNode) which is the root node + * of the requested document. * @throws XFlaimException */ public DOMNode getLastDocument( int iCollection, DOMNode ReusedNode) throws XFlaimException { - DOMNode jNode = null; + DOMNode newNode = null; long lNewNodeRef = 0; long lReusedNodeRef = 0; @@ -441,24 +500,39 @@ public class Db if (ReusedNode != null) { ReusedNode.setRef( lNewNodeRef, this); - jNode = ReusedNode; + newNode = ReusedNode; } else { - jNode = new DOMNode( lNewNodeRef, this); + newNode = new DOMNode( lNewNodeRef, this); } } - return( jNode); + return( newNode); } + /** + * Retrieve a document based on document ID. + * @param iCollection The collection from which to retrieve the + * last document. + * @param iSearchFlags Flags that determine what document should be + * returned. Should be ORed flags from {@link xflaim.SearchFlags SearchFlags}. + * @param lDocumentId Document ID to search for. iSearchFlags determines + * how this parameter is to be used. + * @param ReusedNode An existing {@link xflaim.DOMNode DOMNode} object + * can optionally be passed in, and it will be reused instead of a new + * object being allocated. + * @return - Returns a {@link xflaim.DOMNode DOMNode) which is the root node + * of the requested document. + * @throws XFlaimException + */ public DOMNode getDocument( int iCollection, - int iFlags, + int iSearchFlags, long lDocumentId, DOMNode ReusedNode) throws XFlaimException { - DOMNode jNode = null; + DOMNode newNode = null; long lNewNodeRef = 0; long lReusedNodeRef = 0; @@ -472,7 +546,8 @@ public class Db synchronized( this) { - lNewNodeRef = _getDocument( m_this, iCollection, iFlags, lDocumentId, lReusedNodeRef); + lNewNodeRef = _getDocument( m_this, iCollection, iSearchFlags, + lDocumentId, lReusedNodeRef); } // If we got a reference to a native DOMNode back, let's @@ -483,22 +558,24 @@ public class Db if (ReusedNode != null) { ReusedNode.setRef( lNewNodeRef, this); - jNode = ReusedNode; + newNode = ReusedNode; } else { - jNode = new DOMNode( lNewNodeRef, this); + newNode = new DOMNode( lNewNodeRef, this); } } - return( jNode); + return( newNode); } - private native void _documentDone( - long lThis, - int iCollection, - long lDocumentId) throws XFlaimException; - + /** + * Indicate that modifications to a document are "done". This allows + * XFLAIM to process the document as needed. + * @param iCollection The collection the document belongs to. + * @param lDocumentId Document ID of document that is "done". + * @throws XFlaimException + */ public void documentDone( int iCollection, long lDocumentId) throws XFlaimException @@ -506,24 +583,26 @@ public class Db _documentDone( m_this, iCollection, lDocumentId); } - private native void _documentDone( - long lThis, - long lNode) throws XFlaimException; - - public void _documentDone( - DOMNode jDOMNode) throws XFlaimException + /** + * Indicate that modifications to a document are "done". This allows + * XFLAIM to process the document as needed. + * @param domNode The {@link xflaim.DOMNode DOM node} that is the root node + * of the document that is "done". + * @throws XFlaimException + */ + public void documentDone( + DOMNode domNode) throws XFlaimException { - _documentDone( m_this, jDOMNode.getThis()); + _documentDone( m_this, domNode.getThis()); } /** * Creates a new element definition in the dictionary. * @param sNamespaceURI The namespace URI that this definition should be * created in. If null, the default namespace will be used. - * @param sElementName The name of the definition. - * @param iDataType The type of node this definition will represent. - * Should be one of the constants listed in - * {@link xflaim.FlmDataType FlmDataType}. + * @param sElementName The name of the element. + * @param iDataType The data type for instances of this element. Should be + * one of the constants listed in {@link xflaim.FlmDataType FlmDataType}. * @param iRequestedId If non-zero, then xflaim will try to use this * number as the name ID of the new definition. * @return Returns the name ID of the new definition. @@ -551,6 +630,36 @@ public class Db return( iNewNameId); } + /** + * Create a "unique" element definition - i.e., an element definition whose + * child elements must all be unique. + * @param sNamespaceURI The namespace URI for the element. + * @param sElementName The name of the element. + * @param iRequestedId If non-zero, then xflaim will try to use this + * number as the name ID of the new definition. + * @return Returns the name ID of the element. + * @throws XFlaimException + */ + public int createUniqueElmDef( + String sNamespaceURI, + String sElementName, + int iRequestedId) throws XFlaimException + + { + int iNewNameId; + + // See the comments in the DOMNode::finalize() function for an + // explanation of this call synchronized call + + synchronized( this) + { + iNewNameId = _createUniqueElmDef( m_this, sNamespaceURI, + sElementName, iRequestedId); + } + + return( iNewNameId); + } + /** * Gets the name id for a particular element name. * @param sNamespaceURI The namespace URI for the element. @@ -576,34 +685,13 @@ public class Db return( iNameId); } - public int createUniqueElmDef( - String sNamespaceURI, - String sElementName, - int iRequestedId) throws XFlaimException - - { - int iNewNameId; - - // See the comments in the DOMNode::finalize() function for an - // explanation of this call synchronized call - - synchronized( this) - { - iNewNameId = _createUniqueElmDef( m_this, sNamespaceURI, - sElementName, iRequestedId); - } - - return( iNewNameId); - } - /** * Creates a new attribute definition in the dictionary. * @param sNamespaceURI The namespace URI that this definition should be * created in. If null, the default namespace will be used. * @param sAttributeName The name of the attribute. - * @param iDataType The type of node this definition will represent. - * Should be one of the constants listed in - * {@link xflaim.FlmDataType FlmDataType}. + * @param iDataType The data type for instances of this attribute. Should be + * one of the constants listed in {@link xflaim.FlmDataType FlmDataType}. * @param iRequestedId If non-zero, then xflaim will try to use this * number as the name ID of the new definition. * @return Returns the name ID of the new definition. @@ -831,6 +919,19 @@ public class Db return( iNameId); } + /** + * Retrieve a dictionary definition document. If found, the root node of + * the document is returned. + * @param iDictType The type of dictionary definition being retrieved. It + * should be one of a {@link xflaim.DictType DictType}. + * @param iDictNumber The number the dictionary definition being retrieved. + * @param ReusedNode An existing {@link xflaim.DOMNode DOMNode} object + * can optionally be passed in, and it will be reused instead of a new + * object being allocated. + * @return Returns the root {@link xflaim.DOMNode DOM node} of the dictionary + * definition document. + * @throws XFlaimException + */ public DOMNode getDictionaryDef( int iDictType, int iDictNumber, @@ -873,6 +974,14 @@ public class Db return( jNode); } + /** + * Get a dictionary definition's name. + * @param iDictType The type of dictionary definition whose name is to be + * returned. It should be one of a {@link xflaim.DictType DictType}. + * @param iDictNumber The number of the dictionary definition. + * @return Returns the name of the dictionary definition. + * @throws XFlaimException + */ public String getDictionaryName( int iDictType, int iDictNumber) throws XFlaimException @@ -880,12 +989,24 @@ public class Db return( _getDictionaryName( m_this, iDictType, iDictNumber)); } + /** + * Get an element definition's namespace. + * @param iDictNumber The number of the element definition. + * @return Returns the namespace for the element definition. + * @throws XFlaimException + */ public String getElementNamespace( int iDictNumber) throws XFlaimException { return( _getElementNamespace( m_this, iDictNumber)); } + /** + * Get an attribute definition's namespace. + * @param iDictNumber The number of the attribute definition. + * @return Returns the namespace for the attribute definition. + * @throws XFlaimException + */ public String getAttributeNamespace( int iDictNumber) throws XFlaimException { @@ -893,13 +1014,13 @@ public class Db } /** - * Retrieves the specified node from the specified collection + * Retrieves the specified node from the specified collection. * @param iCollection The collection where the node is stored. - * @param lNodeId The ID number of the node to be retrieved - * @param ReusedNode Optional. An existing instance of DOMNode who's + * @param lNodeId The ID number of the node to be retrieved. + * @param ReusedNode An existing instance of {@link xflaim.DOMNode DOMNode} who's * contents will be replaced with that of the new node. If null, a * new instance will be allocated. - * @return Returns a DOMNode representing the retrieved node. + * @return Returns a {@link xflaim.DOMNode DOMNode} representing the retrieved node. * @throws XFlaimException */ public DOMNode getNode( @@ -942,15 +1063,15 @@ public class Db } /** - * Retrieves the specified attribute node from the specified collection + * Retrieves the specified attribute node from the specified collection. * @param iCollection The collection where the attribute is stored. * @param lElementNodeId The ID number of the element node that contains * the attribute to be retrieved. * @param iAttrNameId The attribute id of the attribute to be retrieved. - * @param ReusedNode Optional. An existing instance of DOMNode who's + * @param ReusedNode An existing instance of {@link xflaim.DOMNode DOMNode} who's * contents will be replaced with that of the new node. If null, a * new instance will be allocated. - * @return Returns a DOMNode representing the retrieved node. + * @return Returns a {@link xflaim.DOMNode DOMNode} representing the retrieved node. * @throws XFlaimException */ public DOMNode getAttribute( @@ -993,35 +1114,44 @@ public class Db return( NewNode); } + /** + * Returns the data type that was specified for a particular dictionary + * definition. NOTE: This really only applies to element and attribute + * definitions. + * @param iDictType The type of dictionary definition whose data type is to be + * returned. It should be one of a {@link xflaim.DictType DictType}. + * @param iDictNumber The number of the dictionary definition. + * @return Returns the dictionary definition's data type. + * @throws XFlaimException + */ public int getDataType( int iDictType, - int iNameId) throws XFlaimException + int iDictNumber) throws XFlaimException { - return( _getDataType( m_this, iDictType, iNameId)); + return( _getDataType( m_this, iDictType, iDictNumber)); } /** * Sets up XFlaim to perform a backup operation - * @param eBackupType The type of backup to perform. Must be one of the - * members of {@link xflaim.FlmBackupType - * FlmBackupType}. - * @param eTransType The type of transaction in which the backup operation + * @param iBackupType The type of backup to perform. Must be one of the + * members of {@link xflaim.FlmBackupType FlmBackupType}. + * @param iTransType The type of transaction in which the backup operation * will take place. Must be one of the members of * {@link xflaim.TransactionType TransactionType}. * @param iMaxLockWait Maximum lock wait time. Specifies the amount of * time to wait for lock requests occuring during the backup operation to * be granted. Valid values are 0 through 255 seconds. Zero is used to - * specify no-wait locks. - * @param ReusedBackup Optional. An existing instance of Backup that - * will be reset with the new settings. If null, a new instance will - * be allocated. - * @return Returns an instance of Backup configured to perform the - * requested backup operation + * specify no-wait locks. 255 specifies no timeout. + * @param ReusedBackup Optional. An existing instance of + * {@link xflaim.Backup Backup} that will be reset with the new settings. + * If null, a new instance will be allocated. + * @return Returns an instance of {@link xflaim.Backup Backup} configured to + * perform the requested backup operation. * @throws XFlaimException */ public Backup backupBegin( - int eBackupType, - int eTransType, + int iBackupType, + int iTransType, int iMaxLockWait, Backup ReusedBackup) throws XFlaimException { @@ -1039,7 +1169,7 @@ public class Db synchronized( this) { - lNewRef = _backupBegin( m_this, eBackupType, eTransType, + lNewRef = _backupBegin( m_this, iBackupType, iTransType, iMaxLockWait, lReusedRef); } @@ -1058,48 +1188,68 @@ public class Db /** * Imports an XML document into the XFlaim database. The import requires - * an update transaction (TransactionType.UPDATE_TRANS). If the document - * cannot be imported, an XFlaimEXception exception will be thrown. - * @param jIStream - * @param iCollection + * an update transaction ({@link xflaim.TransactionType TransactionType}.UPDATE_TRANS). + * If the document cannot be imported, an XFlaimEXception exception will be thrown. + * @param istream Input stream for importing the document. Could represent + * a file or a buffer. + * @param iCollection Collection the document is to be imported into. * @throws XFlaimException */ public ImportStats Import( - IStream jIStream, + IStream istream, int iCollection) throws XFlaimException { - return( _import( m_this, jIStream.getThis(), iCollection, 0, + return( _import( m_this, istream.getThis(), iCollection, 0, InsertLoc.XFLM_LAST_CHILD)); } /** * Imports an XML document into the XFlaim database. The import requires - * an update transaction (TransactionType.UPDATE_TRANS). If the document - * cannot be imported, an XFlaimEXception exception will be thrown. - * @param jIStream - * @param iCollection - * @param NodeToLinkTo - * @param iInsertLoc. Should be one of the members of {@link + * an update transaction ({@link xflaim.TransactionType TransactionType}.UPDATE_TRANS). + * If the document cannot be imported, an XFlaimEXception exception will be thrown. + * @param istream Input stream for importing the document. Could represent + * a file or a buffer. + * @param iCollection Collection the document is to be imported into. + * @param nodeToLinkTo Node the imported XML should be linked to. + * @param iInsertLoc Specifies how the imported document should be linked to + * the nodeToLinkTo. Should be one of the members of {@link * xflaim.InsertLoc InsertLoc}. + * @return Returns an {@link xflaim.ImportStats ImportStats} object which holds + * statistics about what was imported. * @throws XFlaimException */ public ImportStats Import( - IStream jIStream, + IStream istream, int iCollection, - DOMNode NodeToLinkTo, + DOMNode nodeToLinkTo, int iInsertLoc) throws XFlaimException { - if (NodeToLinkTo == null) + if (nodeToLinkTo == null) { - return( _import( m_this, jIStream.getThis(), iCollection, 0, iInsertLoc)); + return( _import( m_this, istream.getThis(), iCollection, 0, iInsertLoc)); } else { - return( _import( m_this, jIStream.getThis(), iCollection, - NodeToLinkTo.getThis(), iInsertLoc)); + return( _import( m_this, istream.getThis(), iCollection, + nodeToLinkTo.getThis(), iInsertLoc)); } } + /** + * Change a dictionary definition's state. This routine is used to determine if + * the dictionary item can be deleted. It may also be used to force the + * definition to be deleted - once the database has determined that the + * definition is not in use anywhere. This should only be used for + * element definitions and attribute definitions definitions. + * @param iDictType Type of dictionary definition whose state is being + * changed. Should be either {@link DictType DictType}.ELEMENT_DEF or + * {@link DictType DictType}.ATTRIBUTE_DEF. + * @param iDictNum Number of element or attribute definition whose state + * is to be changed. + * @param sState. State the definition is to be changed to. Must be + * "checking", "purge", or "active". + * @throws XFlaimException + */ public void changeItemState( int iDictType, int iDictNum, @@ -1108,6 +1258,15 @@ public class Db _changeItemState( m_this, iDictType, iDictNum, sState); } + /** + * Get the name of a roll-forward log file. + * @param iFileNum Roll-forward log file number whose name is to be + * returned. + * @param bBaseOnly If true, only the base name of the file will be returned. + * Otherwise, the entire path will be returned. + * @return Name of the file. + * @throws XFlaimException + */ public String getRflFileName( int iFileNum, boolean bBaseOnly) throws XFlaimException @@ -1115,6 +1274,15 @@ public class Db return( _getRflFileName( m_this, iFileNum, bBaseOnly)); } + /** + * Set the next node ID for a collection. This will be the node ID for + * the next node that is created in the collection. NOTE: The node ID must + * be greater than or equal to the current next node ID that is already + * set for the collection. Otherwise, it is ignored. + * @param iCollection Collection whose next node ID is to be set. + * @param lNextNodeId Next node ID for the collection. + * @throws XFlaimException + */ public void setNextNodeId( int iCollection, long lNextNodeId) throws XFlaimException @@ -1122,197 +1290,437 @@ public class Db _setNextNodeId( m_this, iCollection, lNextNodeId); } + /** + * Set the next dictionary number that is to be assigned for a particular + * type if dictionary definition. The specified "next dictionary number" + * must be greater than the current "next dictionary number". Otherwise, + * no action is taken. + * @param iDictType Type of dictionary definition whose "next dictionary + * number" is to be changed. Should be a valid {@link xflaim.DictType DictType}. + * @param iDictNumber Next dictionary number. + * @throws XFlaimException + */ public void setNextDictNum( - int iDictType, - int iDictNumber) throws XFlaimException + int iDictType, + int iNextDictNumber) throws XFlaimException { - _setNextDictNum( m_this, iDictType, iDictNumber); + _setNextDictNum( m_this, iDictType, iNextDictNumber); } + /** + * Specify whether the roll-forward log should keep or not keep RFL files. + * @param bKeep Flag specifying whether to keep or not keep RFL files. + * @throws XFlaimException + */ public void setRflKeepFilesFlag( - boolean bKeep) throws XFlaimException + boolean bKeep) throws XFlaimException { _setRflKeepFilesFlag( m_this, bKeep); } + /** + * Determine whether or not the roll-forward log files are being kept. + * @return Returns true if RFL files are being kept, false otherwise. + * @throws XFlaimException + */ public boolean getRflKeepFlag() throws XFlaimException { return( _getRflKeepFlag( m_this)); } + /** + * Set the RFL directory. + * @param sRflDir Name of RFL directory. + * @throws XFlaimException + */ public void setRflDir( - String sRflDir) throws XFlaimException + String sRflDir) throws XFlaimException { _setRflDir( m_this, sRflDir); } + /** + * Get the current RFL directory. + * @return Returns the current RFL directory name. + * @throws XFlaimException + */ public String getRflDir() throws XFlaimException { return( _getRflDir( m_this)); } + /** + * Get the current RFL file number. + * @return Returns the current RFL file number. + * @throws XFlaimException + */ public int getRflFileNum() throws XFlaimException { return( _getRflFileNum( m_this)); } + /** + * Get the highest RFL file number that is no longer in use by XFLAIM. + * This RFL file can be removed from the system if needed. + * @return Returns the highest RFL file number that is no longer in use. + * @throws XFlaimException + */ public int getHighestNotUsedRflFileNum() throws XFlaimException { return( _getHighestNotUsedRflFileNum( m_this)); } + /** + * Set size limits for RFL files. + * @param iMinRflSize Minimum RFL file size. Database will roll to the + * next RFL file when the current RFL file reaches this size. If possible + * it will complete the current transaction before rolling to the next file. + * @param iMaxRflSize Maximum RFL file size. Database will not allow an + * RFL file to exceed this size. Even if it is in the middle of a + * transaction, it will roll to the next RFL file before this size is allowed + * to be exceeded. Thus, the database first looks for an opportunity to + * roll to the next file when the RFL file exceeds iMinRflSize. If it can + * fit the current transaction in without exceeded iMaxRflSize, it will do + * so and then roll to the next file. Otherwise, it will roll to the next + * file before iMaxRflSize is exceeded. + * @throws XFlaimException + */ public void setRflFileSizeLimits( - int iMinRflSize, - int iMaxRflSize) throws XFlaimException + int iMinRflSize, + int iMaxRflSize) throws XFlaimException { _setRflFileSizeLimits( m_this, iMinRflSize, iMaxRflSize); } + /** + * Get the minimum RFL file size. This is the minimum size an RFL file + * must reach before rolling to the next RFL file. + * @return Returns minimum RFL file size. + * @throws XFlaimException + */ public int getMinRflFileSize() throws XFlaimException { return( _getMinRflFileSize( m_this)); } + /** + * Get the maximum RFL file size. This is the maximum size an RFL file + * is allowed to grow to. When the current RFL file exceeds the minimum + * RFL file size, the database will attempt to fit the rest of the + * transaction in the current file. If the transaction completes before + * the current RFL file grows larger than the maximum RFL file size, + * the database will roll to the next RFL file. However, if the current transaction + * would cause the RFL file to grow larger than the maximum RFL file size, + * the database will roll to the next file before the transaction completes, + * and the transaction will be split across multiple RFL files. + * @return Returns maximum RFL file size. + * @throws XFlaimException + */ public int getMaxRflFileSize() throws XFlaimException { return( _getMaxRflFileSize( m_this)); } + /** + * Force the database to roll to the next RFL file. + * @throws XFlaimException + */ public void rflRollToNextFile() throws XFlaimException { _rflRollToNextFile( m_this); } + /** + * Specify whether the roll-forward log should keep or not keep aborted + * transactions. + * @param bKeep Flag specifying whether to keep or not keep aborted + * transactions. + * @throws XFlaimException + */ public void setKeepAbortedTransInRflFlag( - boolean bKeep) throws XFlaimException + boolean bKeep) throws XFlaimException { _setKeepAbortedTransInRflFlag( m_this, bKeep); } + /** + * Determine whether or not the roll-forward log is keeping aborted + * transactions. + * @return Returns true if aborted transactions are being kept, false otherwise. + * @throws XFlaimException + */ public boolean getKeepAbortedTransInRflFlag() throws XFlaimException { return( _getKeepAbortedTransInRflFlag( m_this)); } + /** + * Specify whether the roll-forward log should automatically turn off the + * keeping of RFL files if the RFL volume fills up. + * @param bAutoTurnOff Flag specifying whether to automatically turn off the + * keeping of RFL files if the RFL volume fills up. + * @throws XFlaimException + */ public void setAutoTurnOffKeepRflFlag( - boolean bAutoTurnOff) throws XFlaimException + boolean bAutoTurnOff) throws XFlaimException { _setAutoTurnOffKeepRflFlag( m_this, bAutoTurnOff); } + /** + * Determine whether or not keeping of RFL files will automatically be + * turned off if the RFL volume fills up. + * @return Returns true if the keeping of RFL files will automatically be + * turned off when the RFL volume fills up, false otherwise. + * @throws XFlaimException + */ public boolean getAutoTurnOffKeepRflFlag() throws XFlaimException { return( _getAutoTurnOffKeepRflFlag( m_this)); } + /** + * Set the file extend size for the database. This size specifies how much + * to extend a database file when it needs to be extended. + * @param iFileExtendSize File extend size. + * @throws XFlaimException + */ public void setFileExtendSize( - int iFileExtendSize) throws XFlaimException + int iFileExtendSize) throws XFlaimException { _setFileExtendSize( m_this, iFileExtendSize); } + /** + * Get the file extend size for the database. + * @return Returns file extend size. + * @throws XFlaimException + */ public int getFileExtendSize() throws XFlaimException { return( _getFileExtendSize( m_this)); } + /** + * Get the database version for the database. This is the version of the + * database, not the code. + * @return Returns database version. + * @throws XFlaimException + */ public int getDbVersion() throws XFlaimException { return( _getDbVersion( m_this)); } + /** + * Get the database block size. + * @return Returns database block size. + * @throws XFlaimException + */ public int getBlockSize() throws XFlaimException { return( _getBlockSize( m_this)); } + /** + * Get the database default language. + * @return Returns database default language. + * @throws XFlaimException + */ public int getDefaultLanguage() throws XFlaimException { return( _getDefaultLanguage( m_this)); } + /** + * Get the database's current transaction ID. If no transaction is + * currently running, but this Db object has an exclusive lock on the database, + * the transaction ID of the last committed transaction will be returned. + * If no transaction is running, and this Db object does not have an + * exclusive lock on the database, zero is returned. + * @return Returns transaction ID. + * @throws XFlaimException + */ public long getTransID() throws XFlaimException { return( _getTransID( m_this)); } + /** + * Get the name of the database's control file (e.g. mystuff.db). + * @return Returns control file name. + * @throws XFlaimException + */ public String getDbControlFileName() throws XFlaimException { return( _getDbControlFileName( m_this)); } + /** + * Get the transaction ID of the last backup that was taken on the database. + * @return Returns last backup transaction ID. + * @throws XFlaimException + */ public long getLastBackupTransID() throws XFlaimException { return( _getLastBackupTransID( m_this)); } + /** + * Get the number of blocks that have changed since the last backup was + * taken. + * @return Returns number of blocks that have changed. + * @throws XFlaimException + */ public int getBlocksChangedSinceBackup() throws XFlaimException { return( _getBlocksChangedSinceBackup( m_this)); } + /** + * Get the next incremental backup sequence number for the database. + * @return Returns next incremental backup sequence number. + * @throws XFlaimException + */ public int getNextIncBackupSequenceNum() throws XFlaimException { return( _getNextIncBackupSequenceNum( m_this)); } + /** + * Get the amount of disk space currently being used by data files. + * @return Returns disc space used by data files. + * @throws XFlaimException + */ public long getDiskSpaceDataSize()throws XFlaimException { return( _getDiskSpaceDataSize( m_this)); } + /** + * Get the amount of disk space currently being used by rollback files. + * @return Returns disc space used by rollback files. + * @throws XFlaimException + */ public long getDiskSpaceRollbackSize() throws XFlaimException { return( _getDiskSpaceRollbackSize( m_this)); } + /** + * Get the amount of disk space currently being used by RFL files. + * @return Returns disc space used by RFL files. + * @throws XFlaimException + */ public long getDiskSpaceRflSize() throws XFlaimException { return( _getDiskSpaceRflSize( m_this)); } + /** + * Get the amount of disk space currently being used by all types of + * database files. This includes the total of data files plus rollback + * files plus RFL files. + * @return Returns total disc space used by database files of all types. + * @throws XFlaimException + */ public long getDiskSpaceTotalSize() throws XFlaimException { return( _getDiskSpaceTotalSize( m_this)); } + /** + * Get error code that caused the database to force itself to close. This should + * be one of the values in {@link xflaim.RCODE RCODE}. + * @return Returns error code that caused the database to force itself to close. + * @throws XFlaimException + */ public int getMustCloseRC() throws XFlaimException { return( _getMustCloseRC( m_this)); } + /** + * Get error code that caused the current transaction to require an abort. + * This may be one of the values in {@link xflaim.RCODE RCODE}, but not + * necessarily. + * @return Returns error code that caused the current transaction to require + * itself to abort. + * @throws XFlaimException + */ public int getAbortRC() throws XFlaimException { return( _getAbortRC( m_this)); } + /** + * Force the current transaction to abort. This method should be called + * when the code should not be the code that aborts the transation, but + * wants to require that the transaction be aborted by whatever module has + * the authority to abort or commit the transaction. An error code may be + * set to indicate what error condition is causing the transaction to be + * aborted. + * @param iRc Error code that indicates why the transaction is aborting. + * @throws XFlaimException + */ public void setMustAbortTrans( - int iRc) throws XFlaimException + int iRc) throws XFlaimException { _setMustAbortTrans( m_this, iRc); } + /** + * Enable encryption for this database. + * @throws XFlaimException + */ public void enableEncryption() throws XFlaimException { _enableEncryption( m_this); } + /** + * Wrap the database key in a password. This method is called when it is + * desirable to move the database to a different machine. Normally, the + * database key is wrapped in the local NICI storage key - which means that + * the database can only be opened and accessed on that machine. -- Once + * the database key is wrapped in a password, the password must be + * supplied to the dbOpen method to open the database. + * @param sPassword Password the database key should be wrapped in. + * @throws XFlaimException + */ public void wrapKey( - String sPassword) throws XFlaimException + String sPassword) throws XFlaimException { _wrapKey( m_this, sPassword); } + /** + * Generate a new database key. All encryption definition keys will be + * re-wrapped in the new database key. + * @throws XFlaimException + */ public void rollOverDbKey() throws XFlaimException { _rollOverDbKey( m_this); } + /** + * Get the database serial number. + * @return Byte array containing the database serial number. This number + * is generated and stored in the database when the database is created. + * @throws XFlaimException + */ public byte[] getSerialNumber() throws XFlaimException { return( _getSerialNumber( m_this)); } + /** + * Get information about the checkpoint thread's current state. + * @return Checkpoint thread state information is returned in a + * {@link xflaim.CheckpointInfo CheckpointInfo} object. + * @throws XFlaimException + */ public CheckpointInfo getCheckpointInfo() throws XFlaimException { return( _getCheckpointInfo( m_this)); @@ -1320,7 +1728,6 @@ public class Db /** * Export XML to a text file. - * * @param startNode The node in the XML document to export. All of its * sub-tree will be exported. * @param sFileName File the XML is to be exported to. File will be @@ -1339,7 +1746,6 @@ public class Db /** * Export XML to a string. - * * @param startNode The node in the XML document to export. All of its * sub-tree will be exported. * @param iFormat Formatting to use when exporting. Should be one of @@ -1353,41 +1759,92 @@ public class Db return( _exportXML( m_this, startNode.getThis(), iFormat)); } + /** + * Get the list of threads that are holding the database lock as well as + * the threads that are waiting to obtain the database lock. + * @return Returns an array of {@link xflaim.LockUser LockUser} objects. The + * zeroeth element in the array is the current holder of the database lock. + * All other elements of the array are threads that are waiting to obtain + * the lock. + * @throws XFlaimException + */ public LockUser[] getLockWaiters() throws XFlaimException { return( _getLockWaiters( m_this)); } + /** + * Set a callback object that will report the progress of an index or + * collection deletion operation. This object's methods are called only if + * the index or collection is deleted in the foreground. The delete operation + * must be performed in the same thread where this method is called. + * @param deleteStatusObj An object that implements the {@link xflaim.DeleteStatus + * DeleteStatus} interface. + * @throws XFlaimException + */ public void setDeleteStatusObject( DeleteStatus deleteStatusObj) throws XFlaimException { _setDeleteStatusObject( m_this, deleteStatusObj); } + /** + * Set a callback object that will report each document that is being indexed when + * an index definition object is added. This object's methods are called only if + * the index is added in the foreground. The index definition must be added + * in the same thread that sets this object. + * @param ixClientObj An object that implements the {@link xflaim.IxClient + * IxClient} interface. + * @throws XFlaimException + */ public void setIndexingClientObject( IxClient ixClientObj) throws XFlaimException { _setIndexingClientObject( m_this, ixClientObj); } + /** + * Set a callback object that will report indexing progress when + * an index definition object is added. This object's methods are called only if + * the index is added in the foreground. The index definition must be added + * in the same thread that sets this object. + * @param ixStatusObj An object that implements the {@link xflaim.IxStatus + * IxStatus} interface. + * @throws XFlaimException + */ public void setIndexingStatusObject( IxStatus ixStatusObj) throws XFlaimException { _setIndexingStatusObject( m_this, ixStatusObj); } + /** + * Set a callback object that will be called after a transaction commit + * has safely saved all transaction data to disk, but before the database + * is unlocked. This allows an application to do anything it may need to do + * after a commit but before the database is unlocked. The thread that + * performs the commit must be the thread that sets this object. + * @param commitClientObj An object that implements the {@link xflaim.CommitClient + * CommitClient} interface. + * @throws XFlaimException + */ public void setCommitClientObject( CommitClient commitClientObj) throws XFlaimException { _setCommitClientObject( m_this, commitClientObj); } + /** + * Upgrade the database to the most current database version. + * @throws XFlaimException + */ public void upgrade() throws XFlaimException { _upgrade( m_this); } - +// PRIVATE METHODS + private native void _release( long lThis); @@ -1414,13 +1871,70 @@ public class Db long lThis, int iTimeout) throws XFlaimException; - private native ImportStats _import( - long lThis, - long lIStream, - int iCollection, - long lNodeToLinkTo, - int iInsertLoc) throws XFlaimException; + private native void _dbLock( + long lThis, + int iLockType, + int iPriority, + int iTimeout) throws XFlaimException; + + private native void _dbUnlock( + long lThis) throws XFlaimException; + private native int _getLockType( + long lThis) throws XFlaimException; + + private native boolean _getLockImplicit( + long lThis) throws XFlaimException; + + private native int _getLockThreadId( + long lThis) throws XFlaimException; + + private native int _getLockNumExclQueued( + long lThis) throws XFlaimException; + + private native int _getLockNumSharedQueued( + long lThis) throws XFlaimException; + + private native int _getLockPriorityCount( + long lThis, + int iPriority) throws XFlaimException; + + private native void _indexSuspend( + long lThis, + int iIndex) throws XFlaimException; + + private native void _indexResume( + long lThis, + int iIndex) throws XFlaimException; + + private native int _indexGetNext( + long lThis, + int iCurrIndex) throws XFlaimException; + + private native IndexStatus _indexStatus( + long lThis, + int iIndex) throws XFlaimException; + + private native int _reduceSize( + long lThis, + int iCount) throws XFlaimException; + + private native void _keyRetrieve( + long lThis, + int iIndex, + long lSearchKey, + int iSearchFlags, + long lFoundKey) throws XFlaimException; + + private native long _createDocument( + long lThis, + int iCollection) throws XFlaimException; + + private native long _createRootElement( + long lThis, + int iCollection, + int iElementNameId) throws XFlaimException; + private native long _getFirstDocument( long lThis, int iCollection, @@ -1434,32 +1948,19 @@ public class Db private native long _getDocument( long lThis, int iCollection, - int iFlags, + int iSearchFlags, long lDocumentId, long lOldNodeRef) throws XFlaimException; - private native long _getNode( - long lThis, - int iCollection, - long lNodeId, - long lOldNodeRef) throws XFlaimException; - - private native long _getAttribute( + private native void _documentDone( long lThis, int iCollection, - long lElementNodeId, - int iAttrNameId, - long lOldNodeRef) throws XFlaimException; - - private native long _createDocument( - long lThis, - int iCollection) throws XFlaimException; + long lDocumentId) throws XFlaimException; + + private native void _documentDone( + long lThis, + long lNode) throws XFlaimException; - private native long _createRootElement( - long lThis, - int iCollection, - int iTag) throws XFlaimException; - private native int _createElementDef( long lThis, String sNamespaceURI, @@ -1467,17 +1968,17 @@ public class Db int iDataType, int iRequestedId) throws XFlaimException; - private native int _getElementNameId( - long lThis, - String sNamespaceURI, - String sElementName) throws XFlaimException; - private native int _createUniqueElmDef( long lThis, String sNamespaceURI, String sElementName, int iRequestedId) throws XFlaimException; + private native int _getElementNameId( + long lThis, + String sNamespaceURI, + String sElementName) throws XFlaimException; + private native int _createAttributeDef( long lThis, String sNamespaceURI, @@ -1543,25 +2044,38 @@ public class Db long lThis, int iDictNumber) throws XFlaimException; + private native long _getNode( + long lThis, + int iCollection, + long lNodeId, + long lOldNodeRef) throws XFlaimException; + + private native long _getAttribute( + long lThis, + int iCollection, + long lElementNodeId, + int iAttrNameId, + long lOldNodeRef) throws XFlaimException; + private native int _getDataType( long lThis, int iDictType, - int iNameId) throws XFlaimException; + int iDictNumber) throws XFlaimException; private native long _backupBegin( long lThis, - int eBackupType, - int eTransType, + int iBackupType, + int iTransType, int iMaxLockWait, long lReusedRef) throws XFlaimException; - private native void _keyRetrieve( + private native ImportStats _import( long lThis, - int iIndex, - long lKey, - int iFlags, - long lFoundKey) throws XFlaimException; - + long lIStream, + int iCollection, + long lNodeToLinkTo, + int iInsertLoc) throws XFlaimException; + private native void _changeItemState( long lThis, int iDictType, @@ -1581,7 +2095,7 @@ public class Db private native void _setNextDictNum( long lThis, int iDictType, - int iDictNumber) throws XFlaimException; + int iNextDictNumber) throws XFlaimException; private native void _setRflKeepFilesFlag( long lThis, diff --git a/xflaim/java/xflaim/DictType.java b/xflaim/java/xflaim/DictType.java new file mode 100644 index 0000000..00e0e53 --- /dev/null +++ b/xflaim/java/xflaim/DictType.java @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------------ +// Desc: Types of items in the dictionary. +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +package xflaim; + +/** + * Static class representing lock types. + */ +public class DictType +{ + public static final int ELEMENT_DEF = 1; + public static final int ATTRIBUTE_DEF = 2; + public static final int PREFIX_DEF = 3; + public static final int ENCRYPTION_DEF = 4; + public static final int COLLECTION_DEF = 5; + public static final int INDEX_DEF = 6; +} + diff --git a/xflaim/java/xflaim/LockType.java b/xflaim/java/xflaim/LockType.java new file mode 100644 index 0000000..b900cd8 --- /dev/null +++ b/xflaim/java/xflaim/LockType.java @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// Desc: Lock Types +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +package xflaim; + +/** + * Static class representing lock types. + */ +public class LockType +{ + public static final int FLM_LOCK_NONE = 0; + public static final int FLM_LOCK_EXCLUSIVE = 1; + public static final int FLM_LOCK_SHARED = 2; +} +