diff --git a/xflaim/java/jni/jdbsystem.cpp b/xflaim/java/jni/jdbsystem.cpp index ca95975..e78be16 100644 --- a/xflaim/java/jni/jdbsystem.cpp +++ b/xflaim/java/jni/jdbsystem.cpp @@ -42,8 +42,7 @@ #include "jnirestore.h" #include "jnistatus.h" -#define THIS_DBSYS() \ - ((F_DbSystem *)(FLMUINT)lThis) +#define THIS_DBSYS() ((IF_DbSystem *)(FLMUINT)lThis) // Field IDs for the CREATEOPTS class. @@ -226,23 +225,6 @@ FSTATIC jobject NewDbStats( jclass jCountTimeStatClass, jclass jLockStatsClass); -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createDbSystem( - JNIEnv * pEnv, - jobject) // obj) -{ - IF_DbSystem * pDbSystem; - - if( RC_BAD( FlmAllocDbSystem( &pDbSystem))) - { - ThrowError( NE_XFLM_MEM, pEnv); - } - - return( (jlong)(FLMUINT)pDbSystem); -} - /**************************************************************************** Desc: ****************************************************************************/ @@ -871,6 +853,39 @@ Exit: return; } +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createDbSystem( + JNIEnv * pEnv, + jobject) // obj) +{ + IF_DbSystem * pDbSystem; + + if( RC_BAD( FlmAllocDbSystem( &pDbSystem))) + { + ThrowError( NE_XFLM_MEM, pEnv); + } + + return( (jlong)((FLMUINT)pDbSystem)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1release( + JNIEnv *, // pEnv, + jobject, // obj, + jlong lThis) +{ + IF_DbSystem * pDbSystem = THIS_DBSYS(); + + if (pDbSystem) + { + pDbSystem->Release(); + } +} + /**************************************************************************** Desc: Get create options from the CREATEOPTS Java object. ****************************************************************************/ @@ -907,7 +922,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCreate( jstring sRflDir, jstring sDictFileName, jstring sDictBuf, - jobject CreateOpts) + jobject createOpts) { RCODE rc = NE_XFLM_OK; F_Db * pDb = NULL; @@ -953,13 +968,13 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCreate( goto Exit; } - if (!CreateOpts) + if (!createOpts) { pOpts = NULL; } else { - getCreateOpts( pEnv, CreateOpts, &Opts); + getCreateOpts( pEnv, createOpts, &Opts); pOpts = &Opts; } @@ -1231,28 +1246,28 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRename( +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCheck( JNIEnv * pEnv, jobject, // obj, jlong lThis, jstring sDbPath, jstring sDataDir, jstring sRflDir, - jstring sNewDbName, - jboolean bOverwriteDestOk, - jobject Status) + jstring sPassword, + jint iFlags, + jobject checkStatus) { - RCODE rc = NE_XFLM_OK; - JavaVM * pJvm; - JNIRenameStatus * pStatus = NULL; - FLMBYTE ucDbPath [F_PATH_MAX_SIZE]; - F_DynaBuf dbPathBuf( ucDbPath, sizeof( ucDbPath)); - FLMBYTE ucDataDir [F_PATH_MAX_SIZE]; - F_DynaBuf dataDirBuf( ucDataDir, sizeof( ucDataDir)); - FLMBYTE ucRflDir [F_PATH_MAX_SIZE]; - F_DynaBuf rflDirBuf( ucRflDir, sizeof( ucRflDir)); - FLMBYTE ucNewDbName [F_PATH_MAX_SIZE]; - F_DynaBuf newDbNameBuf( ucNewDbName, sizeof( ucNewDbName)); + RCODE rc = NE_XFLM_OK; + JNICheckStatus * pStatus = NULL; + F_DbInfo * pDbInfo = NULL; + FLMBYTE ucDbPath [F_PATH_MAX_SIZE]; + F_DynaBuf dbPathBuf( ucDbPath, sizeof( ucDbPath)); + FLMBYTE ucDataDir [F_PATH_MAX_SIZE]; + F_DynaBuf dataDirBuf( ucDataDir, sizeof( ucDataDir)); + FLMBYTE ucRflDir [F_PATH_MAX_SIZE]; + F_DynaBuf rflDirBuf( ucRflDir, sizeof( ucRflDir)); + FLMBYTE ucPassword [100]; + F_DynaBuf passwordBuf( ucPassword, sizeof( ucPassword)); // Get all of the string parameters into buffers. @@ -1272,24 +1287,26 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRename( ThrowError( rc, pEnv); goto Exit; } - flmAssert( sNewDbName); - if (RC_BAD( rc = getUTF8String( pEnv, sNewDbName, &newDbNameBuf))) + if (RC_BAD( rc = getUTF8String( pEnv, sPassword, &passwordBuf))) { ThrowError( rc, pEnv); goto Exit; } - if (Status != NULL) + if (checkStatus != NULL) { + JavaVM * pJvm = NULL; + pEnv->GetJavaVM( &pJvm); - if ((pStatus = f_new JNIRenameStatus( Status, pJvm)) == NULL) + + if ((pStatus = f_new JNICheckStatus( checkStatus, pJvm)) == NULL) { ThrowError( NE_XFLM_MEM, pEnv); - goto Exit; - } + goto Exit; + } } - - if (RC_BAD(rc = THIS_DBSYS()->dbRename( + + if (RC_BAD( rc = THIS_DBSYS()->dbCheck( (const char *)dbPathBuf.getBufferPtr(), dataDirBuf.getDataLength() > 1 ? (const char *)dataDirBuf.getBufferPtr() @@ -1297,11 +1314,13 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRename( rflDirBuf.getDataLength() > 1 ? (const char *)rflDirBuf.getBufferPtr() : (const char *)NULL, - (const char *)newDbNameBuf.getBufferPtr(), - bOverwriteDestOk ? TRUE : FALSE, pStatus))) + passwordBuf.getDataLength() > 1 + ? (const char *)passwordBuf.getBufferPtr() + : (const char *)NULL, + (FLMUINT)iFlags, (IF_DbInfo **)&pDbInfo, pStatus))) { ThrowError( rc, pEnv); - goto Exit; + goto Exit; } Exit: @@ -1310,7 +1329,8 @@ Exit: { pStatus->Release(); } - return; + + return( (jlong)((FLMUINT)pDbInfo)); } /**************************************************************************** @@ -1326,7 +1346,7 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbCopy( jstring sDestDbName, jstring sDestDataDir, jstring sDestRflDir, - jobject Status) + jobject copyStatus) { RCODE rc = NE_XFLM_OK; JavaVM * pJvm; @@ -1379,10 +1399,10 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbCopy( goto Exit; } - if (Status) + if (copyStatus) { pEnv->GetJavaVM( &pJvm); - if ( (pStatus = f_new JNICopyStatus( Status, pJvm)) == NULL) + if ( (pStatus = f_new JNICopyStatus( copyStatus, pJvm)) == NULL) { ThrowError( NE_XFLM_MEM, pEnv); goto Exit; @@ -1422,28 +1442,28 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCheck( +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRename( JNIEnv * pEnv, jobject, // obj, jlong lThis, jstring sDbPath, jstring sDataDir, jstring sRflDir, - jstring sPassword, - jint iFlags, - jobject Status) + jstring sNewDbName, + jboolean bOverwriteDestOk, + jobject renameStatus) { - RCODE rc = NE_XFLM_OK; - JNICheckStatus * pStatus = NULL; - F_DbInfo * pDbInfo = NULL; - FLMBYTE ucDbPath [F_PATH_MAX_SIZE]; - F_DynaBuf dbPathBuf( ucDbPath, sizeof( ucDbPath)); - FLMBYTE ucDataDir [F_PATH_MAX_SIZE]; - F_DynaBuf dataDirBuf( ucDataDir, sizeof( ucDataDir)); - FLMBYTE ucRflDir [F_PATH_MAX_SIZE]; - F_DynaBuf rflDirBuf( ucRflDir, sizeof( ucRflDir)); - FLMBYTE ucPassword [100]; - F_DynaBuf passwordBuf( ucPassword, sizeof( ucPassword)); + RCODE rc = NE_XFLM_OK; + JavaVM * pJvm; + JNIRenameStatus * pStatus = NULL; + FLMBYTE ucDbPath [F_PATH_MAX_SIZE]; + F_DynaBuf dbPathBuf( ucDbPath, sizeof( ucDbPath)); + FLMBYTE ucDataDir [F_PATH_MAX_SIZE]; + F_DynaBuf dataDirBuf( ucDataDir, sizeof( ucDataDir)); + FLMBYTE ucRflDir [F_PATH_MAX_SIZE]; + F_DynaBuf rflDirBuf( ucRflDir, sizeof( ucRflDir)); + FLMBYTE ucNewDbName [F_PATH_MAX_SIZE]; + F_DynaBuf newDbNameBuf( ucNewDbName, sizeof( ucNewDbName)); // Get all of the string parameters into buffers. @@ -1463,26 +1483,24 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCheck( ThrowError( rc, pEnv); goto Exit; } - if (RC_BAD( rc = getUTF8String( pEnv, sPassword, &passwordBuf))) + flmAssert( sNewDbName); + if (RC_BAD( rc = getUTF8String( pEnv, sNewDbName, &newDbNameBuf))) { ThrowError( rc, pEnv); goto Exit; } - if (Status != NULL) + if (renameStatus != NULL) { - JavaVM * pJvm = NULL; - pEnv->GetJavaVM( &pJvm); - - if ((pStatus = f_new JNICheckStatus( Status, pJvm)) == NULL) + if ((pStatus = f_new JNIRenameStatus( renameStatus, pJvm)) == NULL) { ThrowError( NE_XFLM_MEM, pEnv); - goto Exit; - } + goto Exit; + } } - - if (RC_BAD( rc = THIS_DBSYS()->dbCheck( + + if (RC_BAD(rc = THIS_DBSYS()->dbRename( (const char *)dbPathBuf.getBufferPtr(), dataDirBuf.getDataLength() > 1 ? (const char *)dataDirBuf.getBufferPtr() @@ -1490,13 +1508,11 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCheck( rflDirBuf.getDataLength() > 1 ? (const char *)rflDirBuf.getBufferPtr() : (const char *)NULL, - passwordBuf.getDataLength() > 1 - ? (const char *)passwordBuf.getBufferPtr() - : (const char *)NULL, - (FLMUINT)iFlags, (IF_DbInfo **)&pDbInfo, pStatus))) + (const char *)newDbNameBuf.getBufferPtr(), + bOverwriteDestOk ? TRUE : FALSE, pStatus))) { ThrowError( rc, pEnv); - goto Exit; + goto Exit; } Exit: @@ -1505,125 +1521,7 @@ Exit: { pStatus->Release(); } - - return (jlong)(FLMUINT)pDbInfo; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBufferIStream( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jstring sBuffer) -{ - RCODE rc = NE_XFLM_OK; - const char * pszBuffer = NULL; - FLMUINT uiStrCharCount; - F_BufferIStream * pIStream = NULL; - char * pszAllocBuffer = NULL; - - // Get a pointer to the characters in the string. - - flmAssert( sBuffer); - pszBuffer = pEnv->GetStringUTFChars( sBuffer, NULL); - uiStrCharCount = (FLMUINT)pEnv->GetStringUTFLength( sBuffer); - flmAssert( uiStrCharCount); - - // Create the buffer stream object. - - if ((pIStream = f_new F_BufferIStream) == NULL) - { - rc = RC_SET( NE_FLM_MEM); - ThrowError( rc, pEnv); - goto Exit; - } - - // Call the openStream method so that it will allocate a buffer - // internally. Add one to the size so that we allocate space for - // a null terminating byte - because uiStrCharCount does NOT include - // the null terminating byte. Buffer pointer is returned in pucBuffer. - - if( RC_BAD( rc = pIStream->openStream( NULL, uiStrCharCount + 1, &pszAllocBuffer))) - { - ThrowError( rc, pEnv); - goto Exit; - } - - // Copy the data from the passed in string into pucBuffer, including the NULL. - - f_memcpy( pszAllocBuffer, pszBuffer, uiStrCharCount); - - // NULL terminate the allocated buffer. - - pszAllocBuffer [uiStrCharCount] = 0; - -Exit: - - if (pszBuffer) - { - pEnv->ReleaseStringUTFChars( sBuffer, pszBuffer); - } - - return( (jlong)((FLMUINT)pIStream)); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openFileIStream( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jstring sPath) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucPath [F_PATH_MAX_SIZE]; - F_DynaBuf pathBuf( ucPath, sizeof( ucPath)); - IF_PosIStream * pIStream = NULL; - - // Get all of the string parameters into buffers. - - flmAssert( sPath); - if (RC_BAD( rc = getUTF8String( pEnv, sPath, &pathBuf))) - { - ThrowError( rc, pEnv); - goto Exit; - } - - if (RC_BAD( rc = THIS_DBSYS()->openFileIStream( - (const char *)pathBuf.getBufferPtr(), &pIStream))) - { - ThrowError( rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)pIStream); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createJDataVector( - JNIEnv * pEnv, - jobject, // obj, - jlong lThis) -{ - RCODE rc = NE_XFLM_OK; - IF_DataVector * ifpDataVector = NULL; - - if (RC_BAD( rc = THIS_DBSYS()->createIFDataVector( &ifpDataVector))) - { - ThrowError(rc, pEnv); - goto Exit; - } - -Exit: - - return( (jlong)(FLMUINT)ifpDataVector); + return; } /**************************************************************************** @@ -1726,7 +1624,7 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRebuild( { RCODE rc = NE_XFLM_OK; JavaDbRebuildStatus * pDbRebuildStatusObj = NULL; - F_DbSystem * pDbSystem = THIS_DBSYS(); + IF_DbSystem * pDbSystem = THIS_DBSYS(); XFLM_CREATE_OPTS createOptions; XFLM_CREATE_OPTS * pCreateOptions; FLMUINT64 ui64TotNodes; @@ -1853,69 +1751,88 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1updateIniFile( +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBufferIStream( JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jstring sParamName, - jstring sValue) + jobject, // obj, + jlong lThis, + jstring sBuffer) { - RCODE rc = NE_XFLM_OK; - F_DbSystem * pDbSystem = THIS_DBSYS(); - FLMBYTE ucParamName [80]; - F_DynaBuf paramNameBuf( ucParamName, sizeof( ucParamName)); - FLMBYTE ucValue [80]; - F_DynaBuf valueBuf( ucValue, sizeof( ucValue)); + RCODE rc = NE_XFLM_OK; + const char * pszBuffer = NULL; + FLMUINT uiStrCharCount; + F_BufferIStream * pIStream = NULL; + char * pszAllocBuffer = NULL; - // Get all of the string parameters into buffers. + // Get a pointer to the characters in the string. - if (RC_BAD( rc = getUTF8String( pEnv, sParamName, ¶mNameBuf))) + flmAssert( sBuffer); + pszBuffer = pEnv->GetStringUTFChars( sBuffer, NULL); + uiStrCharCount = (FLMUINT)pEnv->GetStringUTFLength( sBuffer); + flmAssert( uiStrCharCount); + + // Create the buffer stream object. + + if ((pIStream = f_new F_BufferIStream) == NULL) { + rc = RC_SET( NE_FLM_MEM); ThrowError( rc, pEnv); goto Exit; } - if (RC_BAD( rc = getUTF8String( pEnv, sValue, &valueBuf))) + + // Call the openStream method so that it will allocate a buffer + // internally. Add one to the size so that we allocate space for + // a null terminating byte - because uiStrCharCount does NOT include + // the null terminating byte. Buffer pointer is returned in pucBuffer. + + if( RC_BAD( rc = pIStream->openStream( NULL, uiStrCharCount + 1, &pszAllocBuffer))) { ThrowError( rc, pEnv); goto Exit; } - // Call the rebuild function. + // Copy the data from the passed in string into pucBuffer, including the NULL. - if (RC_BAD( rc = pDbSystem->updateIniFile( - (const char *)paramNameBuf.getBufferPtr(), - (const char *)valueBuf.getBufferPtr()))) - { - ThrowError( rc, pEnv); - goto Exit; - } + f_memcpy( pszAllocBuffer, pszBuffer, uiStrCharCount); + + // NULL terminate the allocated buffer. + + pszAllocBuffer [uiStrCharCount] = 0; Exit: - return; + if (pszBuffer) + { + pEnv->ReleaseStringUTFChars( sBuffer, pszBuffer); + } + + return( (jlong)((FLMUINT)pIStream)); } /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbDup( +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openFileIStream( JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jlong lDbToDup) + jobject, // obj, + jlong lThis, + jstring sPath) { - RCODE rc = NE_XFLM_OK; - F_DbSystem * pDbSystem = THIS_DBSYS(); - IF_Db * pDbToDup = (IF_Db *)((FLMUINT)lDbToDup); - IF_Db * pDb = NULL; - - if (!pDbToDup) + RCODE rc = NE_XFLM_OK; + FLMBYTE ucPath [F_PATH_MAX_SIZE]; + F_DynaBuf pathBuf( ucPath, sizeof( ucPath)); + IF_PosIStream * pIStream = NULL; + + // Get all of the string parameters into buffers. + + flmAssert( sPath); + if (RC_BAD( rc = getUTF8String( pEnv, sPath, &pathBuf))) { - rc = RC_SET( NE_XFLM_INVALID_PARM); ThrowError( rc, pEnv); goto Exit; } - if (RC_BAD( rc = pDbSystem->dbDup( pDbToDup, &pDb))) + + if (RC_BAD( rc = THIS_DBSYS()->openFileIStream( + (const char *)pathBuf.getBufferPtr(), &pIStream))) { ThrowError( rc, pEnv); goto Exit; @@ -1923,7 +1840,7 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbDup( Exit: - return( (jlong)((FLMUINT)pDb)); + return( (jlong)(FLMUINT)pIStream); } /**************************************************************************** @@ -2020,6 +1937,56 @@ Exit: return( (jlong)((FLMUINT)pIStream)); } +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Encoder( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jlong lIStream, + jboolean bInsertLineBreaks) +{ + RCODE rc = NE_XFLM_OK; + IF_IStream * pIStream = NULL; + IF_IStream * pInputStream = (IF_IStream *)((FLMUINT)lIStream); + + if (RC_BAD( rc = THIS_DBSYS()->openBase64Encoder( pInputStream, + bInsertLineBreaks ? TRUE : FALSE, &pIStream))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Decoder( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jlong lIStream) +{ + RCODE rc = NE_XFLM_OK; + IF_IStream * pIStream = NULL; + IF_IStream * pInputStream = (IF_IStream *)((FLMUINT)lIStream); + + if (RC_BAD( rc = THIS_DBSYS()->openBase64Decoder( pInputStream, &pIStream))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pIStream)); +} + /**************************************************************************** Desc: ****************************************************************************/ @@ -2223,43 +2190,60 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Encoder( +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createJDataVector( JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jlong lIStream, - jboolean bInsertLineBreaks) + jobject, // obj, + jlong lThis) { RCODE rc = NE_XFLM_OK; - IF_IStream * pIStream = NULL; - IF_IStream * pInputStream = (IF_IStream *)((FLMUINT)lIStream); + IF_DataVector * ifpDataVector = NULL; - if (RC_BAD( rc = THIS_DBSYS()->openBase64Encoder( pInputStream, - bInsertLineBreaks ? TRUE : FALSE, &pIStream))) + if (RC_BAD( rc = THIS_DBSYS()->createIFDataVector( &ifpDataVector))) { - ThrowError( rc, pEnv); + ThrowError(rc, pEnv); goto Exit; } Exit: - return( (jlong)((FLMUINT)pIStream)); + return( (jlong)(FLMUINT)ifpDataVector); } /**************************************************************************** Desc: ****************************************************************************/ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Decoder( +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1updateIniFile( JNIEnv * pEnv, - jobject, // obj, - jlong lThis, - jlong lIStream) + jobject, // obj, + jlong lThis, + jstring sParamName, + jstring sValue) { - RCODE rc = NE_XFLM_OK; - IF_IStream * pIStream = NULL; - IF_IStream * pInputStream = (IF_IStream *)((FLMUINT)lIStream); + RCODE rc = NE_XFLM_OK; + IF_DbSystem * pDbSystem = THIS_DBSYS(); + FLMBYTE ucParamName [80]; + F_DynaBuf paramNameBuf( ucParamName, sizeof( ucParamName)); + FLMBYTE ucValue [80]; + F_DynaBuf valueBuf( ucValue, sizeof( ucValue)); - if (RC_BAD( rc = THIS_DBSYS()->openBase64Decoder( pInputStream, &pIStream))) + // Get all of the string parameters into buffers. + + if (RC_BAD( rc = getUTF8String( pEnv, sParamName, ¶mNameBuf))) + { + ThrowError( rc, pEnv); + goto Exit; + } + if (RC_BAD( rc = getUTF8String( pEnv, sValue, &valueBuf))) + { + ThrowError( rc, pEnv); + goto Exit; + } + + // Call the rebuild function. + + if (RC_BAD( rc = pDbSystem->updateIniFile( + (const char *)paramNameBuf.getBufferPtr(), + (const char *)valueBuf.getBufferPtr()))) { ThrowError( rc, pEnv); goto Exit; @@ -2267,7 +2251,38 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Decoder( Exit: - return( (jlong)((FLMUINT)pIStream)); + return; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbDup( + JNIEnv * pEnv, + jobject, // obj, + jlong lThis, + jlong lDbToDup) +{ + RCODE rc = NE_XFLM_OK; + IF_DbSystem * pDbSystem = THIS_DBSYS(); + IF_Db * pDbToDup = (IF_Db *)((FLMUINT)lDbToDup); + IF_Db * pDb = NULL; + + if (!pDbToDup) + { + rc = RC_SET( NE_XFLM_INVALID_PARM); + ThrowError( rc, pEnv); + goto Exit; + } + if (RC_BAD( rc = pDbSystem->dbDup( pDbToDup, &pDb))) + { + ThrowError( rc, pEnv); + goto Exit; + } + +Exit: + + return( (jlong)((FLMUINT)pDb)); } /**************************************************************************** @@ -3371,31 +3386,31 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1deactivateOpenDb( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jstring sDatabasePath, - jstring sDataFilePath) + jstring sDbFileName, + jstring sDataDir) { RCODE rc = NE_XFLM_OK; - FLMBYTE ucDatabasePath [F_PATH_MAX_SIZE]; - F_DynaBuf databasePathBuf( ucDatabasePath, sizeof( ucDatabasePath)); - FLMBYTE ucDataFilePath [F_PATH_MAX_SIZE]; - F_DynaBuf dataFilePathBuf( ucDataFilePath, sizeof( ucDataFilePath)); + FLMBYTE ucDbFileName [F_PATH_MAX_SIZE]; + F_DynaBuf dbFileNameBuf( ucDbFileName, sizeof( ucDbFileName)); + FLMBYTE ucDataDir [F_PATH_MAX_SIZE]; + F_DynaBuf dataDirBuf( ucDataDir, sizeof( ucDataDir)); // Get the strings. - if (RC_BAD( rc = getUTF8String( pEnv, sDatabasePath, &databasePathBuf))) + if (RC_BAD( rc = getUTF8String( pEnv, sDbFileName, &dbFileNameBuf))) { ThrowError( rc, pEnv); goto Exit; } - if (RC_BAD( rc = getUTF8String( pEnv, sDataFilePath, &dataFilePathBuf))) + if (RC_BAD( rc = getUTF8String( pEnv, sDataDir, &dataDirBuf))) { ThrowError( rc, pEnv); goto Exit; } - THIS_DBSYS()->deactivateOpenDb( (const char *)databasePathBuf.getBufferPtr(), - (const char *)(dataFilePathBuf.getDataLength() > 1 - ? (const char *)dataFilePathBuf.getBufferPtr() + THIS_DBSYS()->deactivateOpenDb( (const char *)dbFileNameBuf.getBufferPtr(), + (const char *)(dataDirBuf.getDataLength() > 1 + ? (const char *)dataDirBuf.getBufferPtr() : (const char *)NULL)); Exit: @@ -3634,21 +3649,21 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1waitToClose( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jstring sDbName) + jstring sDbFileName) { RCODE rc = NE_XFLM_OK; - FLMBYTE ucDbName [F_PATH_MAX_SIZE]; - F_DynaBuf dbNameBuf( ucDbName, sizeof( ucDbName)); + FLMBYTE ucDbFileName [F_PATH_MAX_SIZE]; + F_DynaBuf dbFileNameBuf( ucDbFileName, sizeof( ucDbFileName)); // Get the strings. - if (RC_BAD( rc = getUTF8String( pEnv, sDbName, &dbNameBuf))) + if (RC_BAD( rc = getUTF8String( pEnv, sDbFileName, &dbFileNameBuf))) { ThrowError( rc, pEnv); goto Exit; } if (RC_BAD( rc = THIS_DBSYS()->waitToClose( - (const char *)dbNameBuf.getBufferPtr()))) + (const char *)dbFileNameBuf.getBufferPtr()))) { ThrowError( rc, pEnv); goto Exit; @@ -3666,12 +3681,12 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1clearCache( JNIEnv * pEnv, jobject, // obj, jlong lThis, - jlong lDbToClear) + jlong lDbWithUpdateTrans) { RCODE rc = NE_XFLM_OK; - IF_Db * pDbToClear = (IF_Db *)((FLMUINT)lDbToClear); + IF_Db * pDbWithUpdateTrans = (IF_Db *)((FLMUINT)lDbWithUpdateTrans); - if (RC_BAD( rc = THIS_DBSYS()->clearCache( pDbToClear))) + if (RC_BAD( rc = THIS_DBSYS()->clearCache( pDbWithUpdateTrans))) { ThrowError( rc, pEnv); goto Exit; diff --git a/xflaim/java/jni/xflaim_DbSystem.h b/xflaim/java/jni/xflaim_DbSystem.h index b294c60..7b80ed4 100644 --- a/xflaim/java/jni/xflaim_DbSystem.h +++ b/xflaim/java/jni/xflaim_DbSystem.h @@ -17,18 +17,10 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createDbSystem /* * Class: xflaim_DbSystem - * Method: _init + * Method: _release * Signature: (J)V */ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1init - (JNIEnv *, jobject, jlong); - -/* - * Class: xflaim_DbSystem - * Method: _exit - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1exit +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1release (JNIEnv *, jobject, jlong); /* @@ -55,6 +47,14 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbOpen JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRemove (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jboolean); +/* + * Class: xflaim_DbSystem + * Method: _dbRestore + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lxflaim/RestoreClient;Lxflaim/RestoreStatus;)V + */ +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRestore + (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jstring, jobject, jobject); + /* * Class: xflaim_DbSystem * Method: _dbCheck @@ -71,14 +71,6 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbCheck JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbCopy (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jstring, jstring, jobject); -/* - * Class: xflaim_DbSystem - * Method: _dbRestore - * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lxflaim/RestoreClient;Lxflaim/RestoreStatus;)V - */ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRestore - (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jstring, jobject, jobject); - /* * Class: xflaim_DbSystem * Method: _dbRename @@ -87,6 +79,14 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRestore JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRename (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jboolean, jobject); +/* + * Class: xflaim_DbSystem + * Method: _dbRebuild + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lxflaim/CREATEOPTS;Lxflaim/RebuildStatus;)V + */ +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRebuild + (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jobject, jobject); + /* * Class: xflaim_DbSystem * Method: _openBufferIStream @@ -103,38 +103,6 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBufferIStream JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openFileIStream (JNIEnv *, jobject, jlong, jstring); -/* - * Class: xflaim_DbSystem - * Method: _createJDataVector - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createJDataVector - (JNIEnv *, jobject, jlong); - -/* - * Class: xflaim_DbSystem - * Method: _dbRebuild - * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lxflaim/CREATEOPTS;Lxflaim/RebuildStatus;)V - */ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1dbRebuild - (JNIEnv *, jobject, jlong, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jobject, jobject); - -/* - * Class: xflaim_DbSystem - * Method: _updateIniFile - * Signature: (JLjava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_xflaim_DbSystem__1updateIniFile - (JNIEnv *, jobject, jlong, jstring, jstring); - -/* - * Class: xflaim_DbSystem - * Method: _dbDup - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbDup - (JNIEnv *, jobject, jlong, jlong); - /* * Class: xflaim_DbSystem * Method: _openMultiFileIStream @@ -159,6 +127,22 @@ JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBufferedIStream JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openUncompressingIStream (JNIEnv *, jobject, jlong, jlong); +/* + * Class: xflaim_DbSystem + * Method: _openBase64Encoder + * Signature: (JJZ)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Encoder + (JNIEnv *, jobject, jlong, jlong, jboolean); + +/* + * Class: xflaim_DbSystem + * Method: _openBase64Decoder + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Decoder + (JNIEnv *, jobject, jlong, jlong); + /* * Class: xflaim_DbSystem * Method: _openFileOStream @@ -209,18 +193,26 @@ JNIEXPORT void JNICALL Java_xflaim_DbSystem__1writeToOStream /* * Class: xflaim_DbSystem - * Method: _openBase64Encoder - * Signature: (JJZ)J + * Method: _createJDataVector + * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Encoder - (JNIEnv *, jobject, jlong, jlong, jboolean); +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1createJDataVector + (JNIEnv *, jobject, jlong); /* * Class: xflaim_DbSystem - * Method: _openBase64Decoder + * Method: _updateIniFile + * Signature: (JLjava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_xflaim_DbSystem__1updateIniFile + (JNIEnv *, jobject, jlong, jstring, jstring); + +/* + * Class: xflaim_DbSystem + * Method: _dbDup * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1openBase64Decoder +JNIEXPORT jlong JNICALL Java_xflaim_DbSystem__1dbDup (JNIEnv *, jobject, jlong, jlong); /* diff --git a/xflaim/java/xflaim/DbSystem.java b/xflaim/java/xflaim/DbSystem.java index 8123a28..fe4aab8 100644 --- a/xflaim/java/xflaim/DbSystem.java +++ b/xflaim/java/xflaim/DbSystem.java @@ -48,56 +48,68 @@ public class DbSystem { super(); m_this = _createDbSystem(); - _init(m_this); } public void finalize() { - _exit( m_this); + _release( m_this); m_this = 0; } public void dbClose() { - _exit( m_this); + _release( m_this); m_this = 0; } /** * Creates a new XFlaim database. * - * @param sDbFileName The name of the database to create. (Should be a - * filename ending in .db) - * @param sDataDir The directory where the database should be created. - * If null, the current directory will be used. + * @param sDbFileName This is the name of the control file for the database. + * The control file is the primary database name. It may include a full + * or partial directory name, or no directory name. If a partial directory + * name or is included, it is assumed to be relative to the current working + * directory. If no directory is specified, the file will be created in + * the current working directory. + * @param sDataDir The directory where the database data files are stored. + * If null, the data files will be stored in the same directory as the control + * file. * @param sRflDir The directory where the roll forward log files should be - * stored. If null, then they will be stored in a subdirectory under the - * directory containing the main database file. + * stored. If null, this defaults to the same directory where the control file + * exists. Within this directory, XFLAIM expects a subdirectory to exist that + * holds the RFL files. The subdirectory name is derived from the control + * file's base name. If the control file's base name has an extension + * of ".db", the ".db" is replaced with ".rfl". If the control file's base + * name does not have an extension of ".db", an extension of ".rfl" is simply + * appended to the control file's base name. For example, if the control file's + * base name is "MyDatabase.db", the subdirectory will be named "MyDatabase.rfl". + * If the control file's base name is "MyDatabase.xyz", the subdirectory will be + * named "MyDatabase.xyz.rfl". * @param sDictFileName - The name of a file which contains dictionary * definition items. May be null. Ignored if sDictBuf is non-null. * @param sDictBuf - Contains dictionary definitions. If null, * sDictFileName is used. If both sDictFileName and sDictBuf are null, * the database is created with an empty dictionary. - * @param CreateOpts - An object containing several parameters that affect + * @param createOpts - A {@link xflaim.CREATEOPTS CREATEOPTS} object that + * contains several parameters that affect * the creation of the database. (For advanced users.) - * @return Db reference. + * @return Returns an instance of a {@link xflaim.Db Db} object. * @throws XFlaimException */ public Db dbCreate( - String sDbFileName, - String sDataDir, - String sRflDir, - String sDictFileName, - String sDictBuf, - CREATEOPTS CreateOpts) throws XFlaimException + String sDbFileName, + String sDataDir, + String sRflDir, + String sDictFileName, + String sDictBuf, + CREATEOPTS createOpts) throws XFlaimException { Db jDb = null; long jDb_ref; - jDb_ref = _dbCreate( m_this, sDbFileName, sDataDir, sRflDir, - sDictFileName, sDictBuf, CreateOpts); + sDictFileName, sDictBuf, createOpts); if( jDb_ref != 0) { @@ -109,23 +121,25 @@ public class DbSystem /** * Opens an existing XFlaim database. - * @param sDbFileName The name of the database to open. (Should be a - * filename ending in .db) - * @param sDataDir The directory where the database should be created. - * If null, the current directory will be used. - * @param sRflDir The directory where the roll forward log files should be - * stored. If null, then they will be stored in a subdirectory under the - * directory containing the main database file. - * @return Returns an instance of Db. + * @param sDbFileName The name of the control file of the database to open. + * For more explanation see documentation for dbCreate. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @param sRflDir The roll-forward log file directory. See dbCreate for more + * information. + * @param sPassword Password for opening the database. This is only needed + * if the database key is currently wrapped in a password instead of the + * local NICI storage key. + * @return Returns an instance of a {@xflaim.Db Db} object. * @throws XFlaimException */ public Db dbOpen( - String sDbFileName, - String sDataDir, - String sRflDir, - String sPassword, - boolean bAllowLimited) throws XFlaimException + String sDbFileName, + String sDataDir, + String sRflDir, + String sPassword, + boolean bAllowLimited) throws XFlaimException { Db jDb = null; long jDb_ref; @@ -141,21 +155,20 @@ public class DbSystem /** * Removes (deletes) an XFlaim database. - * @param sDbFileName The name of the database to delete. (Should be a - * filename ending in .db) - * @param sDataDir The directory where the database currently exists. - * If null, the current directory is assumed. - * @param sRflDir The directory where the roll forward log files are - * stored. If null, then they are assumed to be stored in a subdirectory - * under the directory containing the main database file. + * @param sDbFileName The name of the control file of the database to delete. + * For more information see dbCreate. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @param sRflDir The roll-forward log file directory. See dbCreate for more + * information. * @param bRemoveRflFiles If true, the roll forward log files will be * deleted. */ public void dbRemove( - String sDbFileName, - String sDataDir, - String sRflDir, - boolean bRemoveRflFiles) throws XFlaimException + String sDbFileName, + String sDataDir, + String sRflDir, + boolean bRemoveRflFiles) throws XFlaimException { _dbRemove( m_this, sDbFileName, sDataDir, sRflDir, bRemoveRflFiles); } @@ -167,19 +180,27 @@ public class DbSystem * DefaultRestoreClient will be created and * sBackupPath passed into its constructor. If * RestoreClient is non-null, sBackupPath is ignored. - * @param sDbPath The name of the database to create. (Should be a - * filename ending in .db) - * @param sDataDir Optional. The directory where the new data files will - * be stored. If null, then they will be stored in the same directory as - * the .db file. - * @param sRflDir Optional. The directory where RFL files will be stored. - * If null, then they will be stored in a subdirectory under the directory - * containing the .db file. - * @param sBackupPath Optional. The path to the backup files. - * @param RestoreClient Optional. An object implementing the - * {@link RestoreClient RestoreClient} interface - * @param RestoreStatus Optional. An object implementing the - * {@link RestoreStatus RestoreStatus} interface + * @param sDbPath The name of the control file of the database to restore. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @param sRflDir The roll-forward log file directory. See dbCreate for more + * information. + * @param sBackupPath The path to the backup files. This may be null. If + * non-null, it specifies the directory where the backup files which are + * to be restored are found. If null, the restoreClient parameter must be + * non-null. + * @param sPassword Password for the backup. If non-null, the database key in + * the backup was wrapped in a password instead of the local NICI storage + * key. This allows the database to be restored to a different machine if + * desired. If null, the database can only be restored to the same machine + * where it originally existed. + * @param restoreClient An object implementing the + * {@link RestoreClient RestoreClient} interface. This may be null. If + * non-null, it is an object that knows how to get the backup data. + * @param restoreStatus An object implementing the + * {@link RestoreStatus RestoreStatus} interface. This may be null. If + * non-null, it is a callback object whose methods will be called to report + * restore progress. * @throws XFlaimException */ public void dbRestore( @@ -188,32 +209,164 @@ public class DbSystem String sRflDir, String sBackupPath, String sPassword, - RestoreClient RestoreClient, - RestoreStatus RestoreStatus) throws XFlaimException + RestoreClient restoreClient, + RestoreStatus restoreStatus) throws XFlaimException { - RestoreClient Client; + RestoreClient client; - if (RestoreClient != null) + if (restoreClient != null) { - Client = RestoreClient; + client = restoreClient; } else { - Client = new DefaultRestoreClient( sBackupPath); + client = new DefaultRestoreClient( sBackupPath); } _dbRestore( m_this, sDbPath, sDataDir, sRflDir, sBackupPath, - sPassword, Client, RestoreStatus); + sPassword, client, restoreStatus); } + /** + * Peforms an integrity check on the specified database. + * @param sDbFileName The name of the control file of the database to be checked. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @param sRflDir The roll-forward log file directory. See dbCreate for more + * information. + * @param sPassword Password for opening the database. This is only needed + * if the database key is currently wrapped in a password instead of the + * local NICI storage key. + * @param iFlags Flags that control exactly what the operation checks. + * Should be a logical OR of the members of + * {@link xflaim.DbCheckFlags DbCheckFlags}. + * @param checkStatus Optional. If non-null, then XFlaim will call member + * functions to report progress of the check and report any errors that + * are found. + * @return Returns an instance of DbInfo containing data on the physical + * structure of the database. + * @throws XFlaimException + */ + public DbInfo dbCheck( + String sDbFileName, + String sDataDir, + String sRflDir, + String sPassword, + int iFlags, + DbCheckStatus checkStatus) throws XFlaimException + { + long lRef = _dbCheck( m_this, sDbFileName, sDataDir, sRflDir, + sPassword, iFlags, checkStatus); + return new DbInfo( lRef); + } + + /** + * Makes a copy of an existing database. + * @param sSrcDbName The name of the control file of the database to be copied. + * @param sSrcDataDir The directory where the data files for the source + * database are stored. See dbCreate for more information. + * @param sSrcRflDir The directory where the RFL files for the source + * database are stored. See dbCreate for more information. + * @param sDestDbName The name of the control file that is to be created + * for the destination database. + * @param sDestDataDir The directory where the data files for the + * destination database will be stored. See dbCreate for more information. + * @param sDestRflDir The directory where the RFL files for the + * destination database will be stored. See dbCreate for more information. + * @param copyStatus If non-null this is an object that implements the + * {@link xflaim.DbCopyStatus DbCopyStatus} interface. It is a callback + * object that is used to report copy progress. + * @throws XFlaimException + */ + public void dbCopy( + String sSrcDbName, + String sSrcDataDir, + String sSrcRflDir, + String sDestDbName, + String sDestDataDir, + String sDestRflDir, + DbCopyStatus copyStatus) throws XFlaimException + { + _dbCopy( m_this, sSrcDbName, sSrcDataDir, sSrcRflDir, + sDestDbName, sDestDataDir, sDestRflDir, copyStatus); + } /** - * Opens a buffered input stream. - * @param sBuffer - * @return Returns an instance of IStream. + * Renames a database. + * @param sDbName The name of the control file of the database to be renamed. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @param sRflDir The roll-forward log file directory. See dbCreate for more + * information. + * @param sNewDbName The new control file name for the database. + * @param bOverwriteDestOk If true, then if the database specified in + * sNewDbName already exists, it will be overwritten. + * @param renameStatus If non-null this is an object that implements the + * {@link xflaim.DbRenameStatus DbRenameStatus} interface. It is a callback + * object that is used to report rename progress. + * @throws XFlaimException + */ + public void dbRename( + String sDbName, + String sDataDir, + String sRflDir, + String sNewDbName, + boolean bOverwriteDestOk, + DbRenameStatus renameStatus) throws XFlaimException + { + _dbRename( m_this, sDbName, sDataDir, sRflDir, sNewDbName, + bOverwriteDestOk, renameStatus); + } + + /** + * Rebuilds a database. + * @param sSourceDbPath The name of the control file of the database to be + * rebuilt. + * @param sSourceDataDir The data file directory. See dbCreate for more + * information. + * @param sDestDbPath The name of the control file of the destination + * database that is to be built from the source database. + * @param sDestDataDir The destination database's data file directory. + * See dbCreate for more information. + * @param sDestRflDir The destination database's roll-forward log file + * directory. See dbCreate for more information. + * @param sDictPath The name of a file containing dictionary definitions that + * are to be put into the destination database when it is created. + * @param sPassword Password for opening the source database. This is only needed + * if the database key is currently wrapped in a password instead of the + * local NICI storage key. + * @param createOpts - A {@link xflaim.CREATEOPTS CREATEOPTS} object that + * contains several parameters that are used in the creation of the + * destination database. (For advanced users.) + * @param rebuildStatus If non-null this is an object that implements the + * {@link xflaim.RebuildStatus RebuildStatus} interface. It is a callback + * object that is used to report rebuild progress. + * @throws XFlaimException + */ + public void dbRebuild( + String sSourceDbPath, + String sSourceDataDir, + String sDestDbPath, + String sDestDataDir, + String sDestRflDir, + String sDictPath, + String sPassword, + CREATEOPTS createOpts, + RebuildStatus rebuildStatus) throws XFlaimException + { + _dbRebuild( m_this, sSourceDbPath, sSourceDataDir, sDestDbPath, + sDestDataDir, sDestRflDir, sDictPath, sPassword, + createOpts, rebuildStatus); + } + + /** + * Opens an input stream that reads from a string buffer. + * @param sBuffer String buffer that is to be used as an input stream. + * @return Returns a {@link xflaim.IStream IStream} object. + * @throws XFlaimException */ public IStream openBufferIStream( - String sBuffer) throws XFlaimException + String sBuffer) throws XFlaimException { IStream jIStream = null; long lRef = 0; @@ -251,159 +404,17 @@ public class DbSystem } /** - * Creates and returns a DataVector object to be used when searching - * indexes. - * @return DataVector + * Open a multi-file input stream. + * @param sDirectory Directory where the input files are located. + * @return sBaseName Base name of the input files. Files that constitute the + * input stream are sBaseName, sBaseName.00000001, sBaseName.00000002, etc. - where + * the extension is a Hex number. + * @return Returns an {@link xflaim.IStream IStream} object. + * @throws XFlaimException */ - public DataVector createJDataVector() throws XFlaimException - { - DataVector jDataVector = null; - long lRef = 0; - - lRef = _createJDataVector(m_this); - - if (lRef != 0) - { - jDataVector = new DataVector(lRef, this); - } - - return jDataVector; - } - - /** - * Peforms an integrity check on the specified database. - * @param sDbFileName The name of the database to be checked. (Should be a - * filename ending in .db) - * @param sDataDir Optional. The directory where the data files are - * stored. If null, then XFlaim will assume that they are stored in the - * same directory as the .db file. - * @param sRflDir Optional. The directory where RFL files are stored. - * If null, then XFlaim will assume that they are stored in a subdirectory - * under the directory containing the .db file. - * @param iFlags Flags that control exactly what the operation checks. - * Should be a logical OR of the members of - * {@link xflaim.DbCheckFlags DbCheckFlags}. - * @param Status Optional. If non-null, then XFlaim will call member - * functions to report progress of the check and report any errors that - * are found. - * @return Returns an instance of DbInfo containing data on the physical - * structure of the database. - * @throws XFlaimException - */ - public DbInfo dbCheck( - String sDbFileName, - String sDataDir, - String sRflDir, - String sPassword, - int iFlags, - DbCheckStatus Status) throws XFlaimException - { - long lRef = _dbCheck( m_this, sDbFileName, sDataDir, sRflDir, - sPassword, iFlags, Status); - return new DbInfo( lRef); - } - - /** - * Makes a copy of an existing database. - * @param sSrcDbName The name of the existing database. (Should be a - * filename ending in .db) - * @param sSrcDataDir Optional. The directory where the data files are - * stored. If null, then XFlaim will assume that they are stored in the - * same directory as the .db file. - * @param sSrcRflDir Optional. The directory where RFL files are stored. - * If null, then XFlaim will assume that they are stored in a subdirectory - * under the directory containing the .db file. - * @param sDestDbName The name for the new database. - * @param sDestDataDir Optional. The directory where the data files for - * the new database will be stored. - * @param sDestRflDir Optional. The directory where the RFL files for the - * new database will be stored. - * @param Status Optional. If non-null, then Status.dbCopyStatus - * will be called periodically. - * @throws XFlaimException - */ - public void dbCopy( - String sSrcDbName, - String sSrcDataDir, - String sSrcRflDir, - String sDestDbName, - String sDestDataDir, - String sDestRflDir, - DbCopyStatus Status) throws XFlaimException - { - _dbCopy( m_this, sSrcDbName, sSrcDataDir, sSrcRflDir, - sDestDbName, sDestDataDir, sDestRflDir, Status); - } - - /** - * Renames a database. - * @param sDbName The name of the database to be renamed. (Should be a - * filename ending in .db) - * @param sDataDir Optional. The directory where the data files are - * stored. If null, then XFlaim will assume that they are stored in the - * same directory as the .db file. - * @param sRflDir Optional. The directory where RFL files are stored. - * If null, then XFlaim will assume that they are stored in a subdirectory - * under the directory containing the .db file. - * @param sNewDbName The new name for the database. - * @param bOverwriteDestOk If true, then if the database specified in - * sNewDbName already exists, it will be overwritten. - * @param Status Optional. If non-null, then Status.dbRenameStatus - * will be called as every file is renamed. - * @throws XFlaimException - */ - public void dbRename( - String sDbName, - String sDataDir, - String sRflDir, - String sNewDbName, - boolean bOverwriteDestOk, - DbRenameStatus Status) throws XFlaimException - { - _dbRename( m_this, sDbName, sDataDir, sRflDir, sNewDbName, - bOverwriteDestOk, Status); - } - - public void dbRebuild( - String sSourceDbPath, - String sSourceDataDir, - String sDestDbPath, - String sDestDataDir, - String sDestRflDir, - String sDictPath, - String sPassword, - CREATEOPTS createOpts, - RebuildStatus rebuildStatus) throws XFlaimException - { - _dbRebuild( m_this, sSourceDbPath, sSourceDataDir, sDestDbPath, - sDestDataDir, sDestRflDir, sDictPath, sPassword, - createOpts, rebuildStatus); - } - - public void updateIniFile( - String sParamName, - String sValue) throws XFlaimException - { - _updateIniFile( m_this, sParamName, sValue); - } - - public Db dbDup( - Db DbToDup) throws XFlaimException - { - Db jDb = null; - long jDb_ref; - - if( (jDb_ref = _dbDup( m_this, DbToDup.getThis())) != 0) - { - jDb = new Db( jDb_ref, this); - } - - return( jDb); - } - public IStream openMultiFileIStream( - String sDirectory, - String sBaseName) throws XFlaimException + String sDirectory, + String sBaseName) throws XFlaimException { IStream jIStream = null; long lRef = 0; @@ -418,6 +429,17 @@ public class DbSystem return( jIStream); } + /** + * Open a buffered input stream from an existing input stream. + * @param istream An {@link xflaim.IStream IStream} object that is to be + * the input for the buffered stream. + * @return iBufferSize The size (in bytes) of the buffer to use for the + * input stream. Data will be read into the buffer in chunks of this size. + * This will help performance by preventing lots of smaller reads from + * the original input stream. + * @return Returns an {@link xflaim.IStream IStream} object. + * @throws XFlaimException + */ public IStream openBufferedIStream( IStream istream, int iBufferSize) throws XFlaimException @@ -434,6 +456,15 @@ public class DbSystem return( jIStream); } + /** + * Open an input stream that decompresses data from another input stream. It + * is assumed that data coming out of the other input stream is compressed. + * @param istream An {@link xflaim.IStream IStream} object that is to be + * the input for this input stream. It is assumed that the data coming out + * of this input stream is compressed. + * @return Returns an {@link xflaim.IStream IStream} object. + * @throws XFlaimException + */ public IStream openUncompressingIStream( IStream istream) throws XFlaimException { @@ -449,9 +480,70 @@ public class DbSystem return( jIStream); } + /** + * Open an input stream that encodes data from another input stream into + * base 64 encoded binary. Data read from the stream object returned by + * this method will be base 64 encoded. + * @param istream An {@link xflaim.IStream IStream} object that is to be + * the input for this input stream. + * @param bInsertLineBreaks Flag indicating whether or not line breaks + * should be inserted into the data as it is base 64 encoded. + * @return Returns an {@link xflaim.IStream IStream} object. + * @throws XFlaimException + */ + public IStream openBase64Encoder( + IStream istream, + boolean bInsertLineBreaks) throws XFlaimException + { + IStream jIStream = null; + long lRef = 0; + + lRef = _openBase64Encoder( m_this, istream.getThis(), bInsertLineBreaks); + if (lRef != 0) + { + jIStream = new IStream( lRef, this); + } + + return( jIStream); + } + + /** + * Open an input stream that decodes data from another input stream. It is + * assumed that data read from the original input stream is base 64 + * encoded. + * @param istream An {@link xflaim.IStream IStream} object that is to be + * the input for this input stream. It is assumed that data read from this + * input stream will come back base 64 encoded. + * @return Returns an {@link xflaim.IStream IStream} object. + * @throws XFlaimException + */ + public IStream openBase64Decoder( + IStream istream) throws XFlaimException + { + IStream jIStream = null; + long lRef = 0; + + lRef = _openBase64Decoder( m_this, istream.getThis()); + if (lRef != 0) + { + jIStream = new IStream( lRef, this); + } + + return( jIStream); + } + + /** + * Open an output stream that writes data to a file. + * @param sFileName File name to write data to. + * @param bTruncateIfExists Flag indicating whether or not the output file + * should be truncated if it already exists. If false, the file will be + * appended to. + * @return Returns an {@link xflaim.OStream OStream} object. + * @throws XFlaimException + */ public OStream openFileOStream( - String sFileName, - boolean bTruncateIfExists) throws XFlaimException + String sFileName, + boolean bTruncateIfExists) throws XFlaimException { OStream jOStream = null; long lRef = 0; @@ -465,6 +557,19 @@ public class DbSystem return( jOStream); } + /** + * Open a multi-file output stream. Data is written to one or more files. + * @param sDirectory Directory where output files are to be created. + * @param sBaseName Base name for creating file names. The first file will + * be called sBaseName. Subsequent files will be named sBaseName.00000001, + * sBaseName.00000002, etc. The extension is a hex number. + * @param iMaxFileSize Maximum number of bytes to write to each file in the + * multi-file set. + * @param bOkToOverwrite. Flag indicating whether or not the output files + * should be overwritten if they already exist. + * @return Returns an {@link xflaim.OStream OStream} object. + * @throws XFlaimException + */ public OStream openMultiFileOStream( String sDirectory, String sBaseName, @@ -484,6 +589,15 @@ public class DbSystem return( jOStream); } + /** + * Delete a multi-file stream from disk. + * @param sDirectory Directory where the multiple files that constitute the + * stream are located. + * @param sBaseName Base name for files in the multi-file stream. The first file will + * be called sBaseName. Subsequent files will be named sBaseName.00000001, + * sBaseName.00000002, etc. The extension is a hex number. + * @throws XFlaimException + */ public void removeMultiFileStream( String sDirectory, String sBaseName) throws XFlaimException @@ -491,6 +605,17 @@ public class DbSystem _removeMultiFileStream( m_this, sDirectory, sBaseName); } + /** + * Open a buffered output stream. A buffer is allocated for writing data to + * the original output stream. Instead of writing small chunks of data to + * the original output stream, it is first gathered into the output buffer. + * When the output buffer fills, the entire buffer is sent to the original + * output stream with a single write. The idea is that by buffering the + * output data, performance can be improved. + * @param iBufferSize Size of the buffer to be used for buffering output. + * @return Returns an {@link xflaim.OStream OStream} object. + * @throws XFlaimException + */ public OStream openBufferedOStream( OStream ostream, int iBufferSize) throws XFlaimException @@ -507,6 +632,12 @@ public class DbSystem return( jOStream); } + /** + * Open a compressing output stream. Data is compressed before writing it + * out to the passed in output stream object. + * @return Returns an {@link xflaim.OStream OStream} object. + * @throws XFlaimException + */ public OStream openCompressingOStream( OStream ostream) throws XFlaimException { @@ -522,6 +653,13 @@ public class DbSystem return( jOStream); } + /** + * Read data from an input stream and write it out to an output stream. This + * is a quick way to copy all data from an input stream to an output stream. + * @param istream Input stream data is to be read from. + * @param ostream Output stream data is to be written to. + * @throws XFlaimException + */ public void writeToOStream( IStream istream, OStream ostream) throws XFlaimException @@ -529,37 +667,80 @@ public class DbSystem _writeToOStream( m_this, istream.getThis(), ostream.getThis()); } - public IStream openBase64Encoder( - IStream istream, - boolean bInsertLineBreaks) throws XFlaimException + /** + * Creates and returns a DataVector object to be used when searching + * indexes. + * @return Returns a {@link xflaim.DataVector DataVector} object. + * @throws XFlaimException + */ + public DataVector createJDataVector() throws XFlaimException { - IStream jIStream = null; - long lRef = 0; - - lRef = _openBase64Encoder( m_this, istream.getThis(), bInsertLineBreaks); + DataVector jDataVector = null; + long lRef = 0; + + lRef = _createJDataVector(m_this); + if (lRef != 0) { - jIStream = new IStream( lRef, this); + jDataVector = new DataVector(lRef, this); } - return( jIStream); + return jDataVector; + } + + /** + * Updates a parameter in the .ini file. + * @param sParamName Name of parameter to be updated. + * @param sValue Value that is to be assigned to the parameter. + * @throws XFlaimException + */ + public void updateIniFile( + String sParamName, + String sValue) throws XFlaimException + { + _updateIniFile( m_this, sParamName, sValue); } - public IStream openBase64Decoder( - IStream istream) throws XFlaimException + /** + * Dup a {@link xflaim.Db Db} object. This method is a quicker way to open + * a database than calling the dbOpen method. If the application has already + * opened a database, it may pass the {@link xflaim.Db Db} object it obtained + * into this method to get another {@link xflaim.Db Db} object. + * @param dbToDup {@link xflaim.Db Db} object to dup. + * @return Returns a new {@link xflaim.Db Db} object that is opened to the + * same database as dbToDup. + * @throws XFlaimException + */ + public Db dbDup( + Db dbToDup) throws XFlaimException { - IStream jIStream = null; - long lRef = 0; - - lRef = _openBase64Decoder( m_this, istream.getThis()); - if (lRef != 0) + Db jDb = null; + long jDb_ref; + + if( (jDb_ref = _dbDup( m_this, dbToDup.getThis())) != 0) { - jIStream = new IStream( lRef, this); + jDb = new Db( jDb_ref, this); } - return( jIStream); + return( jDb); } + /** + * Set a cache limit that is dynamically adjusted. + * @param iCacheAdjustPercent Percent of available memory that the cache + * limit is to be set to. A new cache limit is periodically recalculated + * based on this percentage. + * @param iCacheAdjustMin Minimum value that the cache limit is to be set + * to whenever a new cache limit is calculated. + * @param iCacheAdjustMax Maximum value that the cache limit is to be set + * to whenever a new cache limit is calculated. + * @param iCacheAdjustMinToLeave This is an alternative way to specify a + * maximum cache limit. If zero, this parameter is ignored and + * iCacheAdjustMax is used. If non-zero, the maximum cache limit is calculated + * to be the amount of available memory minus this number - the idea being to + * leave a certain amount of memory for other processes to use. + * @throws XFlaimException + */ public void setDynamicMemoryLimit( int iCacheAdjustPercent, int iCacheAdjustMin, @@ -570,6 +751,34 @@ public class DbSystem iCacheAdjustMax, iCacheAdjustMinToLeave); } + /** + * Set a cache limit that is permanent until the next explicit call to either + * setHardMemoryLimit or setDynamicMemoryLimit. + * @param iPercent If non-zero, the new cache limit will be calculated as a + * percentage of either the available memory or as a percentage of the + * total memory on the system. iMin and iMax and iMinToLeave are used to + * determine a minimum and maximum range for the new cache limit. + * @param bPercentOfAvail Only used if iPercent is non-zero. If true, it + * specifies that the percent is to be percent of available memory. If false, + * the percent is the percent of total memory on the system. + * @param iMin Only used if iPercent is non-zero. Specifies the minimum + * value that the cache limit is to be allowed to be set to. + * @param iMax If iPercent is non-zero, this specifies the maxmimum value + * that the cache limit is to be set to. If iPercent is zero, this specifies + * the new cache limit (in bytes). + * @param iMinToLeave Only used if iPercent is non-zero. In that + * case, and this value is non-zero, this is an alternative way to specify a + * maximum cache limit. If zero, this parameter is ignored and + * iMax is used. If non-zero, the maximum cache limit is calculated + * to be the amount of available memory (or total memory if bPercentOfAvail + * is false) minus this number - the idea being to leave a certain amount + * of memory for other processes to use. + * @param bPreallocate Flag indicating whether cache should be + * pre-allocated. If true, the amount of memory specified in the new + * limit will be allocated immediately. Otherwise, the memory is allocated + * as needed. + * @throws XFlaimException + */ public void setHardMemoryLimit( int iPercent, boolean bPercentOfAvail, @@ -582,137 +791,312 @@ public class DbSystem iMinToLeave, bPreallocate); } + /** + * Determine if dynamic cache limits are supported on this platform. + * @return Boolean indicating whether or not dynamic cache limits are + * supported on this platform. + * @throws XFlaimException + */ public boolean getDynamicCacheSupported() throws XFlaimException { return( _getDynamicCacheSupported( m_this)); } + /** + * Return information about current cache usage and other cache + * statistics. + * @return Returns a {@link xflaim.CacheInfo CacheInfo} object. + * @throws XFlaimException + */ public CacheInfo getCacheInfo() throws XFlaimException { return( _getCacheInfo( m_this)); } + /** + * Enable or disable debugging of XFLAIM cache. + * @param bDebug If true, enable debugging, otherwise disable. + * @throws XFlaimException + */ public void enableCacheDebug( boolean bDebug) throws XFlaimException { _enableCacheDebug( m_this, bDebug); } + /** + * Determine if cache debugging is currently enabled. + * @return Boolean indicating whether or not cache debugging is currently + * enabled. + * @throws XFlaimException + */ public boolean cacheDebugEnabled() throws XFlaimException { return( _cacheDebugEnabled( m_this)); } + /** + * Close all file descriptors that have are not currently in use and have been + * out of use for at least n seconds. + * @param iSeconds Specifies the number of seconds. File descriptors that + * are not currently in use and have been out of use for at least this amount + * of time will be closed and released. A value of zero will cause all file + * descriptors not currently in use to be closed and released. + * @throws XFlaimException + */ public void closeUnusedFiles( int iSeconds) throws XFlaimException { _closeUnusedFiles( m_this, iSeconds); } + /** + * Start collecting of statistics. + * @throws XFlaimException + */ public void startStats() throws XFlaimException { _startStats( m_this); } + /** + * Stop collecting of statistics. NOTE: Statistics collected from the time + * the startStats method was called will still be available to retrieve + * from the getStats() method. + * @throws XFlaimException + */ public void stopStats() throws XFlaimException { _stopStats( m_this); } + /** + * Reset statistics. All current statistics are started over - as if the + * startStats method had been called. + * @throws XFlaimException + */ public void resetStats() throws XFlaimException { _resetStats( m_this); } + /** + * Retrieve the current statistics that have been collected so far. + * @return Returns a {@link xflaim.Stats Stats} object. + * @throws XFlaimException + */ public Stats getStats() throws XFlaimException { return( _getStats( m_this)); } + /** + * Set the directory where temporary files are to be created. + * @param sPath Name of directory where temporary files are to be created. + * @throws XFlaimException + */ public void setTempDir( String sPath) throws XFlaimException { _setTempDir( m_this, sPath); } + /** + * Get the directory where temporary files are to be created. + * @return Returns the name of directory where temporary files are to be created. + * @throws XFlaimException + */ public String getTempDir() throws XFlaimException { return( _getTempDir( m_this)); } + /** + * Set the checkpoint interval. The checkpoint interval is the maximum number + * of seconds that XFLAIM will allow to go by before a checkpoint is forced. + * Note that XFLAIM attempt to complete a checkpoint as often as possible. + * However, if many update transctions are being performed one after the other + * with no break, it is possible that XFLAIM will not be able to complete + * a checkpoint. If the checkpoint interval is exceeded without a checkpoint + * being done, XFLAIM will hold off updaters until a checkpoint can be + * completed. This is what is known as a "forced" checkpoint. + * @param iSeconds Checkpoint interval, in seconds. + * @throws XFlaimException + */ public void setCheckpointInterval( int iSeconds) throws XFlaimException { _setCheckpointInterval( m_this, iSeconds); } + /** + * Get the current checkpoint interval. + * @return Returns the current checkpoint interval, in seconds. + * @throws XFlaimException + */ public int getCheckpointInterval() throws XFlaimException { return( _getCheckpointInterval( m_this)); } + /** + * Set the cache adjust interval. The cache adjust interval is only used + * when the application has set a dynamic cache limit (see the + * setDynamicCacheLimit API). It specifies how often XFLAIM should calculate + * a new cache limit. + * @param iSeconds Specifies the number of seconds between times when XFLAIM + * recalculates a new cache limit. + * @throws XFlaimException + */ public void setCacheAdjustInterval( int iSeconds) throws XFlaimException { _setCacheAdjustInterval( m_this, iSeconds); } + /** + * Get the current cache adjust interval. + * @return Returns the current cache adjust interval, in seconds. + * @throws XFlaimException + */ public int getCacheAdjustInterval() throws XFlaimException { return( _getCacheAdjustInterval( m_this)); } + /** + * Set the current cache cleanup interval. XFLAIM has a background thread + * that periodically wakes up and removes "old" objects from cache. Old + * objects are objects that are prior versions of current objects. During + * a cleanup cycle, XFLAIM determines which of these objects are never going + * to be needed again and removes them from cache. + * @param iSeconds Specifies the number of seconds between times when XFLAIM + * cleans up "old" objects in cache. + * @throws XFlaimException + */ public void setCacheCleanupInterval( int iSeconds) throws XFlaimException { _setCacheCleanupInterval( m_this, iSeconds); } + /** + * Get the current cache cleanup interval. + * @return Returns the current cache cleanup interval, in seconds. + * @throws XFlaimException + */ public int getCacheCleanupInterval() throws XFlaimException { return( _getCacheCleanupInterval( m_this)); } + /** + * Set the current unused cleanup interval. XFLAIM has a background thread + * that periodically wakes up and removes objects that have not been in use + * for a certain amount of time (as specified by the setMaxUnusedTime method). + * This includes file descriptors and other in-memory objects that XFLAIM + * may have been holding on to in case they are reused. It does NOT include + * blocks in block cache or nodes in node cache. + * @param iSeconds Specifies the number of seconds between times when XFLAIM + * cleans up "unused" objects in cache. + * @throws XFlaimException + */ public void setUnusedCleanupInterval( int iSeconds) throws XFlaimException { _setUnusedCleanupInterval( m_this, iSeconds); } + /** + * Get the current unused cleanup interval. + * @return Returns the current unused cleanup interval, in seconds. + * @throws XFlaimException + */ public int getUnusedCleanupInterval() throws XFlaimException { return( _getUnusedCleanupInterval( m_this)); } + /** + * Set the maximum unused time limit. XFLAIM has a background thread + * that periodically wakes up and removes objects that have not been in use + * for a certain amount of time. This includes file descriptors and + * other in-memory objects that XFLAIM may have been holding on to in case + * they are reused. This method allows an application to specify a timeout + * value that determines the maximum time an object may be "unused" before + * it is cleaned up. + * @param iSeconds Specifies the time limit (in seconds) for objects to be + * "unused" before they are cleaned up. + * @throws XFlaimException + */ public void setMaxUnusedTime( int iSeconds) throws XFlaimException { _setMaxUnusedTime( m_this, iSeconds); } + /** + * Get the maximum unused time limit. + * @return Returns the maximum unused time limit, in seconds. + * @throws XFlaimException + */ public int getMaxUnusedTime() throws XFlaimException { return( _getMaxUnusedTime( m_this)); } + /** + * Deactivate an open database. This method allows an application to force + * a particular database to be closed by all threads. + * @param sDbFileName The name of the control file of the database to. + * deactivate. For more explanation see documentation for dbCreate. + * @param sDataDir The data file directory. See dbCreate for more + * information. + * @throws XFlaimException + */ public void deactivateOpenDb( - String sDatabasePath, - String sDataFilePath) throws XFlaimException + String sDbFileName, + String sDataDir) throws XFlaimException { - _deactivateOpenDb( m_this, sDatabasePath, sDataFilePath); + _deactivateOpenDb( m_this, sDbFileName, sDataDir); } + /** + * Set maximum number of queries to save statistics and information on. NOTE: + * If the startStats method is called, the maximum is set to 20 until + * stopStats is called - unless a non-zero value has already been set. + * @param iMaxToSave The maximum number of queries to save information on. The + * last N queries that were executed will be saved. + * @throws XFlaimException + */ public void setQuerySaveMax( int iMaxToSave) throws XFlaimException { _setQuerySaveMax( m_this, iMaxToSave); } + /** + * Get maximum number of queries to save statistics and information on. + * @return Returns the maximum number of queries to save information on. + * @throws XFlaimException + */ public int getQuerySaveMax() throws XFlaimException { return( _getQuerySaveMax( m_this)); } + /** + * Set dirty cache limits. + * @param iMaxDirty This is the maximum amount of cache (in bytes) that the system + * should allow to be dirty. Once the maximum is exceeded, XFLAIM will + * attempt to write out dirty blocks until the dirty cache is less than or + * equal to the value specified by iLowDirty. + * @param iLowDirty This number is the low threshhold for dirty cache. It is + * a hysteresis value. Once iMaxDirty is exceeded, XFLAIM will write out + * dirty blocks until the dirty cache is once again less than or equal to + * this number. + * @throws XFlaimException + */ public void setDirtyCacheLimits( int iMaxDirty, int iLowDirty) throws XFlaimException @@ -720,16 +1104,51 @@ public class DbSystem _setDirtyCacheLimits( m_this, iMaxDirty, iLowDirty); } + /** + * Get the maximum dirty cache limit. See setDirtyCacheLimits for an + * explanation of what the maximum dirty cache limit is. + * @return Returns the maximum dirty cache limit. + * @throws XFlaimException + */ public int getMaxDirtyCacheLimit() throws XFlaimException { return( _getMaxDirtyCacheLimit( m_this)); } + /** + * Get the low dirty cache limit. See setDirtyCacheLimits for an + * explanation of what the low dirty cache limit is. + * @return Returns the low dirty cache limit. + * @throws XFlaimException + */ public int getLowDirtyCacheLimit() throws XFlaimException { return( _getLowDirtyCacheLimit( m_this)); } + /** + * Compare two strings. + * @param sLeftString This is the string on the left side of the comparison + * operation. + * @param bLeftWild This flag, if true, specifies that wildcard characters + * found in sLeftString should be treated as wildcard characters instead of + * literal characters to compare. If false, the wildcard character (*) is + * treated like a normal character. + * @param sRightString This is the string on the right side of the comparison + * operation. + * @param bRightWild This flag, if true, specifies that wildcard characters + * found in sRightString should be treated as wildcard characters instead of + * literal characters to compare. If false, the wildcard character (*) is + * treated like a normal character. + * @param iCompareRules Flags for doing string comparisons. Should be + * logical ORs of the members of {@link xflaim.CompareRules CompareRules}. + * @param iLanguage Language to use for doing collation of strings. + * @return Returns a value indicating whether sLeftString is less than, equal to, + * or greater than sRightString. A value of -1 means sLeftString < sRightString. + * A value of 0 means the strings are equal. A value of 1 means that + * sLeftString > sRightString. + * @throws XFlaimException + */ public int compareStrings( String sLeftString, boolean bLeftWild, @@ -742,6 +1161,18 @@ public class DbSystem sRightString, bRightWild, iCompareRules, iLanguage)); } + /** + * Determine if a string has a sub-string in it. + * @param sString This is the string that is to be checked to see if it + * contains a substring. + * @param bSubString This is the substring that is being looked for. + * @param iCompareRules Flags for doing string comparisons. Should be + * logical ORs of the members of {@link xflaim.CompareRules CompareRules}. + * @param iLanguage Language to use for doing collation of strings. + * @return Returns a boolean value indicating whether sString contains the + * substring specified by sSubString. + * @throws XFlaimException + */ public boolean hasSubStr( String sString, String sSubString, @@ -751,96 +1182,135 @@ public class DbSystem return( _hasSubStr( m_this, sString, sSubString, iCompareRules, iLanguage)); } + /** + * Determine if a character is an upper-case character. + * @param uzChar This is the character that is to be tested. + * @return Returns a boolean value indicating whether uzChar is upper + * case. + * @throws XFlaimException + */ public boolean uniIsUpper( char uzChar) throws XFlaimException { return( _uniIsUpper( m_this, uzChar)); } + /** + * Determine if a character is a lower-case character. + * @param uzChar This is the character that is to be tested. + * @return Returns a boolean value indicating whether uzChar is lower + * case. + * @throws XFlaimException + */ public boolean _uniIsLower( char uzChar) throws XFlaimException { return( _uniIsLower( m_this, uzChar)); } + /** + * Determine if a character is an alphabetic character. + * @param uzChar This is the character that is to be tested. + * @return Returns a boolean value indicating whether uzChar is + * alphabetic. + * @throws XFlaimException + */ public boolean uniIsAlpha( char uzChar) throws XFlaimException { return( _uniIsAlpha( m_this, uzChar)); } + /** + * Determine if a character is a a decimal digit (0..9). + * @param uzChar This is the character that is to be tested. + * @return Returns a boolean value indicating whether uzChar is + * a decimal digit. + * @throws XFlaimException + */ public boolean uniIsDecimalDigit( char uzChar) throws XFlaimException { return( _uniIsDecimalDigit( m_this, uzChar)); } + /** + * Convert a character to lower case. + * @param uzChar This is the character that is to be converted. + * @return Returns the lower-case character. + * @throws XFlaimException + */ public char uniToLower( char uzChar) throws XFlaimException { return( _uniToLower( m_this, uzChar)); } + /** + * Wait for a database to close. This method will not return until the + * database specified has been closed by all Db ojects that currently have + * it open. + * @param sDbFileName The name of the control file of the database to wait + * to close. For more explanation see documentation for dbCreate. + * @throws XFlaimException + */ public void waitToClose( - String sDbName) throws XFlaimException + String sDbFileName) throws XFlaimException { - _waitToClose( m_this, sDbName); + _waitToClose( m_this, sDbFileName); } + /** + * Free as much cache as possible. NOTE: This method will not be able to + * remove cached blocks and nodes that are currently in use. + * @param dbWithUpdateTrans This is a {@link xflaim.Db Db} object that may be used to + * write out dirty cache blocks. It may be null. If non-null, it must be + * the {@link xflaim.Db Db} object that is currently running an update + * transaction. + * @throws XFlaimException + */ public void clearCache( - Db dbToClear) throws XFlaimException + Db dbWithUpdateTrans) throws XFlaimException { - _clearCache( m_this, dbToClear.getThis()); + if (dbWithUpdateTrans != null) + { + _clearCache( m_this, dbWithUpdateTrans.getThis()); + } + else + { + _clearCache( m_this, 0); + } } + +// PRIVATE METHODS private native long _createDbSystem(); - private native void _init( long lThis); - - private native void _exit( long lThis); + private native void _release( long lThis); private native long _dbCreate( - long lThis, - String DbFileName, - String DataDir, - String RflDir, - String DictFileName, - String DictBuf, - CREATEOPTS CreateOpts); + long lThis, + String sDbFileName, + String sDataDir, + String sRflDir, + String sDictFileName, + String sDictBuf, + CREATEOPTS createOpts); private native long _dbOpen( - long lThis, - String DbFileName, - String DataDir, - String RflDir, - String Password, - boolean bAllowLimited); + long lThis, + String sDbFileName, + String sDataDir, + String sRflDir, + String sPassword, + boolean bAllowLimited); private native void _dbRemove( - long lThis, - String DbFileName, - String DataDir, - String RflDir, - boolean bRemoveRflFiles) throws XFlaimException; - - private native long _dbCheck( - long lThis, - String sDbFileName, - String sDataDir, - String sRflDir, - String sPassword, - int iFlags, - DbCheckStatus Status) throws XFlaimException; - - private native void _dbCopy( - long lThis, - String sSrcDbName, - String sSrcDataDir, - String sSrcRflDir, - String sDestDbName, - String sDestDataDir, - String sDestRflDir, - DbCopyStatus Status) throws XFlaimException; + long lThis, + String sDbFileName, + String sDataDir, + String sRflDir, + boolean bRemoveRflFiles) throws XFlaimException; private native void _dbRestore( long lThis, @@ -852,6 +1322,25 @@ public class DbSystem RestoreClient RestoreClient, RestoreStatus RestoreStatus) throws XFlaimException; + private native long _dbCheck( + long lThis, + String sDbFileName, + String sDataDir, + String sRflDir, + String sPassword, + int iFlags, + DbCheckStatus checkStatus) throws XFlaimException; + + private native void _dbCopy( + long lThis, + String sSrcDbName, + String sSrcDataDir, + String sSrcRflDir, + String sDestDbName, + String sDestDataDir, + String sDestRflDir, + DbCopyStatus copyStatus) throws XFlaimException; + private native void _dbRename( long lThis, String sDbName, @@ -859,19 +1348,8 @@ public class DbSystem String sRflDir, String sNewDbName, boolean bOverwriteDestOk, - DbRenameStatus Status) throws XFlaimException; + DbRenameStatus renameStatus) throws XFlaimException; - private native long _openBufferIStream( - long lThis, - String sBuffer) throws XFlaimException; - - private native long _openFileIStream( - long lThis, - String sPath); - - private native long _createJDataVector( - long lRef); - private native void _dbRebuild( long lThis, String sSourceDbPath, @@ -884,14 +1362,13 @@ public class DbSystem CREATEOPTS createOpts, RebuildStatus rebuildStatus) throws XFlaimException; - private native void _updateIniFile( - long lThis, - String sParamName, - String sValue) throws XFlaimException; + private native long _openBufferIStream( + long lThis, + String sBuffer) throws XFlaimException; - private native long _dbDup( - long lThis, - long lDbToDup) throws XFlaimException; + private native long _openFileIStream( + long lThis, + String sPath); private native long _openMultiFileIStream( long lThis, @@ -907,6 +1384,15 @@ public class DbSystem long lThis, long lIStream) throws XFlaimException; + private native long _openBase64Encoder( + long lThis, + long lIstream, + boolean bInsertLineBreaks) throws XFlaimException; + + private native long _openBase64Decoder( + long lThis, + long lIstream) throws XFlaimException; + private native long _openFileOStream( long lThis, String sFileName, @@ -938,14 +1424,17 @@ public class DbSystem long lIstream, long lOStream) throws XFlaimException; - private native long _openBase64Encoder( - long lThis, - long lIstream, - boolean bInsertLineBreaks) throws XFlaimException; + private native long _createJDataVector( + long lRef); - private native long _openBase64Decoder( - long lThis, - long lIstream) throws XFlaimException; + private native void _updateIniFile( + long lThis, + String sParamName, + String sValue) throws XFlaimException; + + private native long _dbDup( + long lThis, + long lDbToDup) throws XFlaimException; private native void _setDynamicMemoryLimit( long lThis, @@ -1036,8 +1525,8 @@ public class DbSystem private native void _deactivateOpenDb( long lThis, - String sDatabasePath, - String sDataFilePath) throws XFlaimException; + String sDbFileName, + String sDataDir) throws XFlaimException; private native void _setQuerySaveMax( long lThis, @@ -1095,7 +1584,7 @@ public class DbSystem private native void _waitToClose( long lThis, - String sDbName) throws XFlaimException; + String sDbFileName) throws XFlaimException; private native void _clearCache( long lThis,