gov.nih.nlm.nls.dbm
Class InMemory

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

public abstract class InMemory
extends java.lang.Object
implements JDbmInterface

InMemory implements the interface to the dbm package Tue Dec 04 12:00:16 EST 2001, divita Initial Version


Constructor Summary
InMemory()
          This is a constructor for Inmemory
InMemory(java.lang.String pFileName, int pMode)
          This is a constructor for InMemory
 
Method Summary
 java.util.ArrayList beginsWith(java.lang.String pString)
          Method beginsWith
 java.util.ArrayList beginsWithWord(java.lang.String pString)
          Method beginsWithWord
 void close()
          Method close
 java.util.Enumeration elements()
          Method elements returns an Enumeration to traverse the data store.
 java.lang.Object get(int pRowId)
          Method get retrieves an object from the datastore using a string as the key
 java.lang.Object get(java.lang.String pKey)
          Method get gets an object back from the datastore, using a string 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
 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.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 UTF-8 Strings from the datastore using a String as the key
 java.util.Iterator keyIterator()
          Method keyIterator returns the keys from this datastore This is not implementable in this package.
 java.util.Enumeration keys()
          Method keys returns the keys from this datastore
static void main(java.lang.String[] argv)
          This is a test main, whose purpose is to test the functionality of each method developed for this class.
 void open(java.lang.String pFileName)
          Method open
 void put(int pRowId, java.lang.Object pValue)
          Method put puts a serializable object into a datastore keyed by an int.
 int put(java.lang.Object pValue)
          Method put puts a serializable object into a datastore keyed by an int.
 void put(java.lang.String pKey, java.lang.Object pValue)
          Method put puts a serializable object into a datastore, keyed by a string
 void put(java.lang.String pKey, java.lang.String pValue)
          Method put puts a String into a datastore keyed by a String.
 void putInts(java.lang.String pKey, int[] pValue)
          Method putInts puts an int[] into a datastore keyed by a string
 void putString(int pRowId, java.lang.String pValue)
          Method putString puts a String into a datastore keyed by an int.
 int putString(java.lang.String pValue)
          Method putString puts a String into a datastore keyed by an int.
 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
 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
 
Methods inherited from interface gov.nih.nlm.nls.dbm.JDbmInterface
get, getBytes, getBytes, getInt, getInts, getNonUniqInts, getObject, getObject, getStrings, put, put, putAString, putBytes, putBytes, putInts, putNonUniqInts, putObject, putObject, putStrings
 

Constructor Detail

InMemory

public InMemory()
         throws java.lang.Exception
This is a constructor for Inmemory

Throws:
java.lang.Exception

InMemory

public InMemory(java.lang.String pFileName,
                int pMode)
         throws java.lang.Exception
This is a constructor for InMemory

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

open

public void open(java.lang.String pFileName)
          throws java.lang.Exception
Method open

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

close

public void close()
           throws java.lang.Exception
Method close

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

save

public void save()
          throws java.lang.Exception
Method save

Specified by:
save in interface JDbmInterface
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 is not needed with this implementation because each insert is reported to go into an automatically balanced tree. We will cause the side effect that the current cache is written to disk though.

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

put

public void put(java.lang.String pKey,
                java.lang.Object pValue)
         throws java.lang.Exception
Method put puts a serializable object into a datastore, keyed by a string

Parameters:
pKey -
pValue -
Throws:
java.lang.Exception

put

public void put(int pRowId,
                java.lang.Object pValue)
         throws java.lang.Exception
Method put puts a serializable object into a datastore keyed by an int.

Parameters:
pRowId -
pValue -
Throws:
java.lang.Exception

put

public int put(java.lang.Object pValue)
        throws java.lang.Exception
Method put puts a serializable object into a datastore keyed by an int.

Parameters:
pValue -
Returns:
int
Throws:
java.lang.Exception

put

public void put(java.lang.String pKey,
                java.lang.String pValue)
         throws java.lang.Exception
Method put puts a String into a datastore keyed by a String. UTF-8 chars are stored. ( I cannot claim the UTF-8 nature using this package).

Specified by:
put in interface JDbmInterface
Parameters:
pKey - <------ it's got to be unique
pValue -
Throws:
java.lang.Exception

putInts

public void putInts(java.lang.String pKey,
                    int[] pValue)
             throws java.lang.Exception
Method putInts puts an int[] into a datastore keyed by a string

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

putString

public void putString(int pRowId,
                      java.lang.String pValue)
               throws java.lang.Exception
Method putString puts a String into a datastore keyed by an int. UTF-8 chars are stored. (Can't claim the UTF-8 nature here)

Specified by:
putString in interface JDbmInterface
Parameters:
pRowId - <---- it's got to be unique
pValue -
Throws:
java.lang.Exception

putString

public int putString(java.lang.String pValue)
              throws java.lang.Exception
Method putString puts a String into a datastore keyed by an int. UTF-8 chars are stored. (Can't claim the UTF-8 nature here)

Parameters:
pValue -
Returns:
int
Throws:
java.lang.Exception

get

public java.lang.Object get(java.lang.String pKey)
                     throws java.lang.Exception
Method get gets an object back from the datastore, using a string as the key

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

get

public java.lang.Object get(int pRowId)
                     throws java.lang.Exception
Method get retrieves an object from the datastore using a string as the key

Parameters:
pRowId -
Returns:
Object
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 UTF-8 Strings from the datastore using a String as the key

Specified by:
getString in interface JDbmInterface
Parameters:
pKey -
Returns:
String
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

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

elements

public java.util.Enumeration elements()
                               throws java.lang.Exception
Method elements returns an Enumeration to traverse the data store. This method makes no claims about ordering. This is not implementable in this package. There are other ways to traverse the store.

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

keys

public java.util.Enumeration keys()
Method keys returns the keys from this datastore

Specified by:
keys in interface JDbmInterface
Returns:
Enumeration

keyIterator

public java.util.Iterator keyIterator()
Method keyIterator returns the keys from this datastore This is not implementable in this package. There are other ways to traverse the store.

Specified by:
keyIterator in interface JDbmInterface
Returns:
Iterator

beginsWith

public java.util.ArrayList beginsWith(java.lang.String pString)
Method beginsWith

Specified by:
beginsWith in interface JDbmInterface
Parameters:
pString -
Returns:
ArrayList

beginsWithWord

public java.util.ArrayList beginsWithWord(java.lang.String pString)
Method beginsWithWord

Specified by:
beginsWithWord in interface JDbmInterface
Parameters:
pString -
Returns:
ArrayList

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

main

public static final void main(java.lang.String[] argv)
This is a test main, whose purpose is to test the functionality of each method developed for this class. This main strives to test the boundary conditions as well as some sample common ways each public method is intended to be used.

Parameters:
argv - The command line input, tokenized


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.