|
PJODeThe PersonalJava ODBMS |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.linxpda.PJODe.PJODe
This class is the access point for users to the com.linxpda.PJODe ODBMS system. A typical session would go like this:
Person paul = new Person("Male", 16, 68, 150); try { PJODe db = new PJODe("test.db", 64); // NOTE: The class Person must implement java.io.Serializable // and should override the equals(Object) method // to ensure proper comparison to another Person. db.set(paul); db.close(); } catch(IOException ioe) { //Handle IO errors here.. } catch(DBException rfe) { //Handle DB errors here.. } Person query = new Person("Male"); try { PJODe db = new PJODe("test.db", "rw"); ResultSet results = db.get(query); if (! results.isEmpty()) { for (int i = 0; i < results.getObjectCount(); i++) { System.out.println(results.getObjectAt(i).toString()); } } } catch(IOException ioe) { //IO Error handling here.. } catch(DBException rfe) { //DB Error handling here.. }
Constructor Summary | |
PJODe(java.lang.String dbPath)
Initializes an PJODe with the default permissions and capacity. |
|
PJODe(java.lang.String dbPath,
int initialCapacity)
Initializes an PJODe with the requested initial capacity and default permissions of "rw". |
|
PJODe(java.lang.String dbPath,
java.lang.String access)
Open an existing PJODe with the requested access permissions. |
Method Summary | |
void |
close()
Defragments the database file and closes all connected streams. |
ResultSet |
get(java.lang.Object query)
Reads all objects from the datafile and compares them to the supplied query object through a call to equals(). |
void |
remove(java.lang.Object object)
Deletes the specified object from the data file. |
void |
set(java.lang.Object object)
Add (or updates) the object into the persistent file. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PJODe(java.lang.String dbPath) throws java.io.IOException, DBException
dbPath
- The relative or absolute path for the
database file. If this path points to an existing file,
then it is opened, if it does not, then a new file is created.java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.public PJODe(java.lang.String dbPath, int initialCapacity) throws java.io.IOException, DBException
dbPath
- The relative or absolute path for the
database file. If this path points to an existing file,
then it is opened, if it does not, then a new file is created.initialCapacity
- The initial capacity (in bytes) for the
database. The database file will be created with this
capacity and increased by this amount anytime new memory
space needs to be made available.java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.public PJODe(java.lang.String dbPath, java.lang.String access) throws java.io.IOException, DBException
dbPath
- The relative or absolute path for the
database file. If this path points to an existing file,
then it is opened, if it does not, then a new file is created.access
- The access flags for permission setting.
Can be "r" for read-only, "w" for write only or "rw"
for read and write permissions.java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.Method Detail |
public void set(java.lang.Object object) throws java.io.IOException, DBException
Object
- The object to add (or update) in the database.
This object must implement the java.io.Serializable
interface and may override the equals() method to better
define how it compares itself to other objects.java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.public ResultSet get(java.lang.Object query) throws java.io.IOException, java.io.OptionalDataException, java.lang.ClassNotFoundException, DBException
Object
- The template to use for the query. All objects
in the database will be compared to this object's equals()
method to determine if it should be added to the resulting
ResultSet.ResultSet
object that contains all the objects that tested true to
object.equals(query).java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.public void remove(java.lang.Object object) throws java.io.IOException, DBException
object
- The object to delete.java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.public void close() throws java.io.IOException, DBException
java.io.IOException
- For typical file I/O errorsDBException
- upon an database specific error.
|
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |