|
|||||||||
| Home >> All >> com >> sample >> addressbook >> [ dumbdb overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.sample.addressbook.dumbdb
Class DumbDB

java.lang.Objectcom.sample.addressbook.dumbdb.DumbDB
- public class DumbDB
- extends java.lang.Object
This class is used to fake a dumb database.
It is only used for this application so that it can be demonstrated without the need of a proper database.
Please do not use this class for anything other than testing/prototype purposes.
| Nested Class Summary | |
private class |
DumbDB.EntryComparator
|
| Field Summary | |
private java.util.TreeMap |
database
The "database". |
private int |
increment
|
private java.lang.String |
path
|
| Constructor Summary | |
protected |
DumbDB()
DO NOT USE THIS DIRECTLY |
|
DumbDB(java.lang.String path)
|
| Method Summary | |
void |
deleteObjectById(java.lang.String id)
Delete an object in the db by it's ID. |
java.util.ArrayList |
getAllEntries()
|
private java.lang.Object |
getBeanProperty(java.lang.Object beanObject,
java.lang.String propertyName)
Internal Method. |
java.util.TreeMap |
getDatabase()
|
static DumbDB |
getDumbDB(javax.servlet.http.HttpServletRequest request,
java.lang.String attrName)
|
int |
getIncrement()
|
java.lang.Object |
getObjectByAttributeValue(java.lang.String attributeName,
java.lang.String attributeValue,
boolean likeMatch)
Extract an object from the db using the value of an attribute within the object. |
private java.lang.Object |
getObjectByAttributeValueInternal(java.lang.String attributeName,
java.lang.String attributeValue)
Internal Method. |
java.lang.Object |
getObjectByAttributeValues(java.util.HashMap attributes,
boolean likeMatch)
Extract an object from the db using the value of an attribute within the object. |
java.lang.Object |
getObjectById(java.lang.String id)
Get an object from the db by it's ID. |
java.util.Collection |
getObjectsByAttributeValue(java.lang.String attributeName,
java.lang.String attributeValue,
boolean likeMatch)
Extract a collection of objects from the db using the value of an attribute within the object. |
private java.util.Collection |
getObjectsByAttributeValueInternal(java.lang.String attributeName,
java.lang.String attributeValue)
Internal Method. |
java.util.Collection |
getObjectsByAttributeValues(java.util.HashMap attributes,
boolean likeMatch)
Extract a collection of objects from the db using the name/value pairs within the object. |
void |
insertObject(java.lang.Object data)
Insert an object into the db by it's ID. |
private void |
loadDumbDb(DumbDB db,
java.lang.String path)
Load the db from the given XML file. |
int |
newIncrement()
|
private void |
saveDumbDb(DumbDB db,
java.lang.String path)
Save the db into the given file as XML. |
void |
setDatabase(java.util.TreeMap db)
|
void |
setIncrement(int inc)
|
java.lang.String |
toString()
Convert this Object to a human-readable String. |
void |
updateObjectById(java.lang.String id,
java.lang.Object data)
Update an object in the db by it's ID. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
database
private java.util.TreeMap database
- The "database".
increment
private int increment
path
private java.lang.String path
| Constructor Detail |
DumbDB
protected DumbDB()
- DO NOT USE THIS DIRECTLY
DumbDB
public DumbDB(java.lang.String path)
| Method Detail |
getDumbDB
public static DumbDB getDumbDB(javax.servlet.http.HttpServletRequest request, java.lang.String attrName)
getDatabase
public java.util.TreeMap getDatabase()
setDatabase
public void setDatabase(java.util.TreeMap db)
getAllEntries
public java.util.ArrayList getAllEntries()
newIncrement
public int newIncrement()
getIncrement
public int getIncrement()
setIncrement
public void setIncrement(int inc)
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
getObjectById
public java.lang.Object getObjectById(java.lang.String id)
- Get an object from the db by it's ID.
updateObjectById
public void updateObjectById(java.lang.String id, java.lang.Object data)
- Update an object in the db by it's ID.
deleteObjectById
public void deleteObjectById(java.lang.String id)
- Delete an object in the db by it's ID.
insertObject
public void insertObject(java.lang.Object data)
- Insert an object into the db by it's ID.
getObjectByAttributeValues
public java.lang.Object getObjectByAttributeValues(java.util.HashMap attributes, boolean likeMatch)
- Extract an object from the db using the value of an attribute within the object.
All attributes given must match for the object to be returned.
getObjectsByAttributeValues
public java.util.Collection getObjectsByAttributeValues(java.util.HashMap attributes, boolean likeMatch)
- Extract a collection of objects from the db using the name/value pairs within the object.
All attributes given must match for the object to be returned.
getObjectByAttributeValue
public java.lang.Object getObjectByAttributeValue(java.lang.String attributeName, java.lang.String attributeValue, boolean likeMatch)
- Extract an object from the db using the value of an attribute within the object.
This returns the first matching object.
getObjectsByAttributeValue
public java.util.Collection getObjectsByAttributeValue(java.lang.String attributeName, java.lang.String attributeValue, boolean likeMatch)
- Extract a collection of objects from the db using the value of an attribute within the object.
This returns all matching objects.
saveDumbDb
private void saveDumbDb(DumbDB db, java.lang.String path)
- Save the db into the given file as XML.
loadDumbDb
private void loadDumbDb(DumbDB db, java.lang.String path)
- Load the db from the given XML file.
getObjectByAttributeValueInternal
private java.lang.Object getObjectByAttributeValueInternal(java.lang.String attributeName, java.lang.String attributeValue)
- Internal Method.
getObjectsByAttributeValueInternal
private java.util.Collection getObjectsByAttributeValueInternal(java.lang.String attributeName, java.lang.String attributeValue)
- Internal Method.
getBeanProperty
private java.lang.Object getBeanProperty(java.lang.Object beanObject, java.lang.String propertyName)
- Internal Method.
|
|||||||||
| Home >> All >> com >> sample >> addressbook >> [ dumbdb overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.sample.addressbook.dumbdb.DumbDB