gov.nih.nlm.nls.dbm
Class MysqlJDbm

java.lang.Object
  extended bygov.nih.nlm.nls.dbm.MysqlJDbm
All Implemented Interfaces:
JDbmInterface

public class MysqlJDbm
extends java.lang.Object
implements JDbmInterface

MysqlJDbm is an implementation of the jdbm interface. It is intended to interface with the jdbc client. Tue Dec 04 12:00:16 EST 2001, divita Initial Version


Constructor Summary
MysqlJDbm(java.lang.String pFileName, int pMode)
          This is a constructor for MysqlJDbm.
MysqlJDbm(java.lang.String pFileName, int pMode, GlobalBehavior pSettings)
          This is a constructor for MysqlJDbm.
 
Method Summary
 java.util.ArrayList beginsWith(java.lang.String pKey)
          Method beginsWith [TBD]
 java.util.ArrayList beginsWithWord(java.lang.String pString)
          Method beginsWithWord [TBD]
 void close()
          Method close closes the db.
 java.util.Enumeration elements()
          Method elements [TBD]
 int get(long pRowId)
          Method get retrieves an int from the datastore using an int as the key This method returns a -1 if nothing was found.
 byte[] getBytes(int pRowId)
          Method getBytes
 byte[] getBytes(java.lang.String pRowId)
          Method getBytes
 int getInt(java.lang.String pKey)
          Method getInt gets an int back from the datastore, using a string as the key This method will return -1 if nothing is found.
 int[] getInts(int pKey)
          Method getInts retrieves an array of ints from the datastore using an int as the key
 int[] getInts(java.lang.String pKey)
          Method getInts retrieves an array of ints from the datastore using a string as the key
 int[] getNonUniqInts(java.lang.String pKey)
          Method getNonUniqInts retrieves an array of ints from the datastore using a string as the key
 long getNumberOfRecords()
          Method getNumberOfRecords retrieves the number of records from the table that is keyed by a record id.
 long getNumberOfStringKeyedRows()
          Method getNumberOfStringKeyedRows retrieves the number of rows in the table that contains strings as keys.
 java.lang.Object getObject(int pRowId)
          Method getObject
 java.lang.Object getObject(java.lang.String pRowId)
          Method getObject
 java.lang.String getString(int pRowId)
          Method getString retrieves strings from the datastore using an int as the key
 java.lang.String getString(java.lang.String pKey)
          Method getString retrieves from the datastore using a String as the key
 java.lang.String[] getStrings(java.lang.String pKey)
          Method getStrings retrieves an array of Strings from the datastore using a string as the key
 void index()
          Method index indexes the tables for the first time.
 java.util.Iterator keyIterator()
          Method keyIterator [TBD]
 java.util.Enumeration keys()
          Method keys [TBD]
 void open(java.lang.String pFileName)
          Method open opens the table name.
 void put(int pKey, int pValue)
          Method put
 void put(java.lang.String pKey, int pValue)
          Method put
 void put(java.lang.String pKey, java.lang.String pValue)
          Method put
 void putAString(java.lang.String pKey, java.lang.String pValue)
          Method putAString
 void putBytes(int pKey, byte[] pValue)
          Method putBytes
 void putBytes(java.lang.String pKey, byte[] pValue)
          Method putBytes
 void putInts(int pKey, int[] pValue)
          Method putInts
 void putInts(java.lang.String pKey, int[] pValue)
          Method putInts
 void putNonUniqInts(java.lang.String pKey, int pValue)
          Method putNonUniqInts
 void putObject(int pKey, java.lang.Object pValue)
          Method putObject
 void putObject(java.lang.String pKey, java.lang.Object pValue)
          Method putObject
 void putString(int pKey, java.lang.String pValue)
          Method putString
 void putStrings(java.lang.String pKey, java.lang.String[] pValue)
          Method putStrings[]
 void reorganize()
          Method reorganize reorganizes the db into an optimized or balanced btree and does a save as a side effect.
 void save()
          Method save [TBD] writes out the current state to disk.
 byte[] serializeObject(java.lang.Object pObject)
          Method serializeObject
 java.lang.Object unSerializeObject(byte[] pBytes)
          Method unSerializeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MysqlJDbm

public MysqlJDbm(java.lang.String pFileName,
                 int pMode)
          throws java.lang.Exception
This is a constructor for MysqlJDbm. This class assumes that there exists a database user "root", with the standard mmtx password, that can create the database "JDBMDatabase" if it does not exist.

Parameters:
pFileName -
pMode - JDBM.WRITE_ONLY|JDBM.READ_WRITE|JDBM.READ_ONLY
Throws:
java.lang.Exception

MysqlJDbm

public MysqlJDbm(java.lang.String pFileName,
                 int pMode,
                 GlobalBehavior pSettings)
          throws java.lang.Exception
This is a constructor for MysqlJDbm. This class assumes that the root database settings are in the GlobalBehavior passed in

Parameters:
pFileName -
pMode - JDBM.WRITE_ONLY|JDBM.READ_WRITE|JDBM.READ_ONLY
pSettings -
Throws:
java.lang.Exception
Method Detail

open

public void open(java.lang.String pFileName)
          throws java.lang.Exception
Method open opens the table name. For compatibility sake, we are going to have a database and table name be named the same. In other instantiations, its a one to one correspondance between a jdbm instance and a database+table.

Specified by:
open in interface JDbmInterface
Parameters:
pFileName -
Throws:
java.lang.Exception

close

public void close()
           throws java.lang.Exception
Method close closes the db. This method does do a flush and a save before closing when opened with write modes.

Specified by:
close in interface JDbmInterface
Throws:
java.lang.Exception

save

public void save()
          throws java.lang.Exception
Method save [TBD] writes out the current state to disk. This does not close the db, but makes sure the current state is saved.

Specified by:
save in interface JDbmInterface
Throws:
java.lang.Exception

index

public void index()
           throws java.lang.Exception
Method index indexes the tables for the first time. This method is here because it is faster to insert everything into an sql table, then create the indexes, rather than index as they are being inserted. It should be noted that unique indexes cannot be made after the fact. The insert IGNORE or ON DUPLICATE UPDATE won't work unless there is an index. (GD 7/28/04)

Throws:
java.lang.Exception

reorganize

public void reorganize()
                throws java.lang.Exception
Method reorganize reorganizes the db into an optimized or balanced btree and does a save as a side effect. This method is useful when you've done some substantial number of updates where the underlying tree could get out of balance. [This method has no meaning in this implementation]

Specified by:
reorganize in interface JDbmInterface
Throws:
java.lang.Exception

putObject

public void putObject(java.lang.String pKey,
                      java.lang.Object pValue)
               throws java.lang.Exception
Method putObject

Specified by:
putObject in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putBytes

public void putBytes(java.lang.String pKey,
                     byte[] pValue)
              throws java.lang.Exception
Method putBytes

Specified by:
putBytes in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

put

public void put(java.lang.String pKey,
                java.lang.String pValue)
         throws java.lang.Exception
Method put

Specified by:
put in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putObject

public void putObject(int pKey,
                      java.lang.Object pValue)
               throws java.lang.Exception
Method putObject

Specified by:
putObject in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putBytes

public void putBytes(int pKey,
                     byte[] pValue)
              throws java.lang.Exception
Method putBytes

Specified by:
putBytes in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

put

public void put(int pKey,
                int pValue)
         throws java.lang.Exception
Method put

Specified by:
put in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putInts

public void putInts(java.lang.String pKey,
                    int[] pValue)
             throws java.lang.Exception
Method putInts

Specified by:
putInts in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putInts

public void putInts(int pKey,
                    int[] pValue)
             throws java.lang.Exception
Method putInts

Specified by:
putInts in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putNonUniqInts

public void putNonUniqInts(java.lang.String pKey,
                           int pValue)
                    throws java.lang.Exception
Method putNonUniqInts

Specified by:
putNonUniqInts in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putString

public void putString(int pKey,
                      java.lang.String pValue)
               throws java.lang.Exception
Method putString

Specified by:
putString in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putStrings

public void putStrings(java.lang.String pKey,
                       java.lang.String[] pValue)
                throws java.lang.Exception
Method putStrings[]

Specified by:
putStrings in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

putAString

public void putAString(java.lang.String pKey,
                       java.lang.String pValue)
                throws java.lang.Exception
Method putAString

Specified by:
putAString in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

put

public void put(java.lang.String pKey,
                int pValue)
         throws java.lang.Exception
Method put

Specified by:
put in interface JDbmInterface
Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

getObject

public java.lang.Object getObject(java.lang.String pRowId)
                           throws java.lang.Exception
Method getObject

Specified by:
getObject in interface JDbmInterface
Parameters:
pRowId -
Returns:
Object
Throws:
java.lang.Exception

getInt

public int getInt(java.lang.String pKey)
           throws java.lang.Exception
Method getInt gets an int back from the datastore, using a string as the key This method will return -1 if nothing is found.

Specified by:
getInt in interface JDbmInterface
Parameters:
pKey -
Returns:
int
Throws:
java.lang.Exception

getObject

public java.lang.Object getObject(int pRowId)
                           throws java.lang.Exception
Method getObject

Specified by:
getObject in interface JDbmInterface
Parameters:
pRowId -
Returns:
Object
Throws:
java.lang.Exception

getBytes

public byte[] getBytes(int pRowId)
                throws java.lang.Exception
Method getBytes

Specified by:
getBytes in interface JDbmInterface
Parameters:
pRowId -
Returns:
byte[]
Throws:
java.lang.Exception

getBytes

public byte[] getBytes(java.lang.String pRowId)
                throws java.lang.Exception
Method getBytes

Specified by:
getBytes in interface JDbmInterface
Parameters:
pRowId -
Returns:
Object
Throws:
java.lang.Exception

getInts

public int[] getInts(java.lang.String pKey)
              throws java.lang.Exception
Method getInts retrieves an array of ints from the datastore using a string as the key

Specified by:
getInts in interface JDbmInterface
Parameters:
pKey -
Returns:
int[]
Throws:
java.lang.Exception

getInts

public int[] getInts(int pKey)
              throws java.lang.Exception
Method getInts retrieves an array of ints from the datastore using an int as the key

Specified by:
getInts in interface JDbmInterface
Parameters:
pKey -
Returns:
int[]
Throws:
java.lang.Exception

getStrings

public java.lang.String[] getStrings(java.lang.String pKey)
                              throws java.lang.Exception
Method getStrings retrieves an array of Strings from the datastore using a string as the key

Specified by:
getStrings in interface JDbmInterface
Parameters:
pKey -
Returns:
String[]
Throws:
java.lang.Exception

getNonUniqInts

public int[] getNonUniqInts(java.lang.String pKey)
                     throws java.lang.Exception
Method getNonUniqInts retrieves an array of ints from the datastore using a string as the key

Specified by:
getNonUniqInts in interface JDbmInterface
Parameters:
pKey -
Returns:
int[]
Throws:
java.lang.Exception

get

public int get(long pRowId)
        throws java.lang.Exception
Method get retrieves an int from the datastore using an int as the key This method returns a -1 if nothing was found.

Specified by:
get in interface JDbmInterface
Parameters:
pRowId - ( (long) needs to be distinguished from the other get(int) signature)
Returns:
int
Throws:
java.lang.Exception

getString

public java.lang.String getString(int pRowId)
                           throws java.lang.Exception
Method getString retrieves strings from the datastore using an int as the key

Specified by:
getString in interface JDbmInterface
Parameters:
pRowId -
Returns:
String
Throws:
java.lang.Exception

getString

public java.lang.String getString(java.lang.String pKey)
                           throws java.lang.Exception
Method getString retrieves from the datastore using a String as the key

Specified by:
getString in interface JDbmInterface
Parameters:
pKey -
Returns:
String
Throws:
java.lang.Exception

elements

public java.util.Enumeration elements()
                               throws java.lang.Exception
Method elements [TBD]

Specified by:
elements in interface JDbmInterface
Returns:
Enumeration
Throws:
java.lang.Exception

keys

public java.util.Enumeration keys()
                           throws java.lang.Exception
Method keys [TBD]

Specified by:
keys in interface JDbmInterface
Returns:
Enumeration
Throws:
java.lang.Exception

keyIterator

public java.util.Iterator keyIterator()
                               throws java.lang.Exception
Method keyIterator [TBD]

Specified by:
keyIterator in interface JDbmInterface
Returns:
Iterator
Throws:
java.lang.Exception

getNumberOfRecords

public long getNumberOfRecords()
Method getNumberOfRecords retrieves the number of records from the table that is keyed by a record id.

Specified by:
getNumberOfRecords in interface JDbmInterface
Returns:
long

getNumberOfStringKeyedRows

public long getNumberOfStringKeyedRows()
Method getNumberOfStringKeyedRows retrieves the number of rows in the table that contains strings as keys.

Specified by:
getNumberOfStringKeyedRows in interface JDbmInterface
Returns:
long

beginsWith

public java.util.ArrayList beginsWith(java.lang.String pKey)
                               throws java.lang.Exception
Method beginsWith [TBD]

Specified by:
beginsWith in interface JDbmInterface
Parameters:
pKey -
Returns:
ArrayList
Throws:
java.lang.Exception

beginsWithWord

public java.util.ArrayList beginsWithWord(java.lang.String pString)
                                   throws java.lang.Exception
Method beginsWithWord [TBD]

Specified by:
beginsWithWord in interface JDbmInterface
Parameters:
pString -
Returns:
ArrayList (Of Objects)
Throws:
java.lang.Exception

serializeObject

public byte[] serializeObject(java.lang.Object pObject)
                       throws java.lang.Exception
Method serializeObject

Parameters:
pObject -
Returns:
byte[]
Throws:
java.lang.Exception

unSerializeObject

public java.lang.Object unSerializeObject(byte[] pBytes)
                                   throws java.lang.Exception
Method unSerializeObject

Parameters:
pBytes -
Returns:
Object
Throws:
java.lang.Exception


The use and distribution of this material is subject to the terms and conditions included in the file SPECIALIST_NLP_TOOLS_TERMS_AND_CONDITIONS.TXT, located in the root directory of the distribution.