|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.aspects.persistence.SQLStorage
Implements the storage to store within an SQL compliant database system.
LongOID
,
Serialized FormNested Class Summary | |
static class |
SQLStorage.InvalidStorageException
|
Field Summary | |
protected Connection |
db
The SQL connection to the database that is use by this storage. |
Constructor Summary | |
protected |
SQLStorage()
Default constructor. |
|
SQLStorage(Connection db)
Creates a new SQL storage. |
Method Summary | |
static String |
addSlashes(String str)
|
void |
addToList(OID cid,
long position,
Object value)
Insert a value into an existing List. |
void |
addToList(OID cid,
Object value)
Add a value at the end of a list. |
boolean |
addToSet(OID cid,
Object value)
Add an object to a Set. |
void |
bindOIDToName(OID oid,
String name)
Bind an existing object to a logical name to that it can be found later on. |
protected void |
checkStorage()
Throw an exception if storage is null or invalid |
void |
clearList(OID cid)
Remove all objects from a list. |
void |
clearMap(OID cid)
Remove all objects from a set. |
void |
clearSet(OID cid)
Remove all objects from a set. |
void |
close()
Closes the storage. |
boolean |
collectionContains(String table,
OID cid,
Object value)
|
void |
commit()
Commit started transaction |
OID |
createObject(String className)
Creates a new object using a PostgreSQL sequance. |
void |
deleteName(String name)
Delete a name from the storage. |
void |
deleteObject(OID oid)
Delete an object from the storage. |
protected boolean |
execute(String query)
|
protected ResultSet |
executeQuery(String query)
|
protected int |
executeUpdate(String query)
|
String |
getClassID(OID oid)
Get the class ID of a given object. |
OID |
getCollectionID(OID oid,
CollectionItem collection)
Get the ID of a collection |
List |
getCollectionValues(OID oid,
CollectionItem collection,
String table,
String orderBy)
|
Object |
getField(OID oid,
FieldItem field)
Get the value of a field. |
StorageField[] |
getFields(OID oid,
ClassItem cl,
FieldItem[] fields)
Get the values of several fields. |
Object |
getFromMap(OID cid,
Object key)
Get the value associated to a key from a Map. |
long |
getIndexInList(OID cid,
Object value)
Get the smallest index of an element in a List. |
protected long |
getInternalIndexInList(OID cid,
Object value)
|
long |
getLastIndexInList(OID cid,
Object value)
Get the highest index of an element in a List. |
List |
getList(OID cid)
Get a List from the storage. |
List |
getList(OID oid,
CollectionItem collection)
Get a List from the storage. |
Object |
getListItem(OID cid,
long index)
Get an element from a list |
long |
getListSize(OID cid)
Get the number of objects contained in a list |
long |
getLong(String query)
|
Map |
getMap(OID cid)
Get the elements of a Map. |
Map |
getMap(OID oid,
CollectionItem collection)
Describe getMap method here. |
long |
getMapSize(OID cid)
Get the number of objects contained in a map |
String |
getNameFromOID(OID oid)
Get the name of an object from its oid. |
abstract long |
getNextVal(String sequence)
Returns the next value of a sequence |
Collection |
getObjects(ClassItem cl)
Get all instances of a class, or all objects if cl == null. |
protected void |
getObjects(ClassItem cl,
Vector objects)
|
OID |
getOID(String query)
|
OID |
getOIDFromName(String name)
Get the ID of an object from its name. |
Collection |
getRootObjects()
Get OIDs of all root objects. |
List |
getSet(OID cid)
Get the elements of a Set. |
List |
getSet(OID oid,
CollectionItem collection)
Get the elements of a Set. |
long |
getSetSize(OID cid)
Get the number of objects contained in a set |
boolean |
listContains(OID cid,
Object value)
Say if a List contains an object. |
boolean |
mapContainsKey(OID cid,
Object key)
Says if a Map contains a key. |
boolean |
mapContainsValue(OID cid,
Object value)
Says if a Map contains a value. |
String |
newName(String className)
Generate a new name for an instance. |
Object |
putInMap(OID cid,
Object key,
Object value)
Put an element in a Map. |
void |
removeField(OID oid,
FieldItem field,
Object value)
Remove a field from an existing object. |
void |
removeFromList(OID cid,
long position)
Remove a value from an existing list. |
void |
removeFromList(OID cid,
Object value)
Remove the first value from an existing list. |
Object |
removeFromMap(OID cid,
Object key)
Remove a key from a Map. |
boolean |
removeFromSet(OID cid,
Object value)
Remove an element from a Set. |
void |
rollback()
Rollback started transaction |
protected void |
setConnection(Connection db)
Resets the connection to the database with the given connection. |
boolean |
setContains(OID cid,
Object value)
Say if a set contains an object. |
void |
setField(OID oid,
FieldItem field,
Object object)
Initialize the value of an object's field. |
void |
setListItem(OID cid,
long index,
Object value)
Set the value of a list element. |
void |
startTransaction()
Starts a transaction |
void |
updateField(OID oid,
FieldItem field,
Object object)
Update a field value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Connection db
Constructor Detail |
protected SQLStorage() throws SQLException
public SQLStorage(Connection db) throws SQLException
db
- the connection to the databaseMethod Detail |
public void close()
Storage
close
in interface Storage
protected void setConnection(Connection db)
db
- the new connectionprotected int executeUpdate(String query) throws SQLException
SQLException
protected ResultSet executeQuery(String query) throws SQLException
SQLException
protected boolean execute(String query) throws SQLException
SQLException
public void deleteObject(OID oid) throws Exception
Storage
deleteObject
in interface Storage
oid
- the ID of the object to delete
Exception
- if an error occurspublic void setField(OID oid, FieldItem field, Object object) throws Exception
Storage
setField
in interface Storage
oid
- the ID of the object that will contain the fieldfield
- the field to setobject
- the value of the field
Exception
- if an error occurspublic void updateField(OID oid, FieldItem field, Object object) throws Exception
Storage
updateField
in interface Storage
oid
- the ID of the object that already contains the fieldfield
- the field to updateobject
- the new value of the field
Exception
- if an error occurspublic Object getField(OID oid, FieldItem field) throws Exception
Storage
getField
in interface Storage
oid
- the ID of the object that contains the fieldfield
- the field to retrieve
Exception
- if an error occurspublic StorageField[] getFields(OID oid, ClassItem cl, FieldItem[] fields) throws Exception
Storage
getFields
in interface Storage
oid
- the ID of object to retrievecl
- the class of the objectfields
- the fields to retrieve
Exception
- if an error occurspublic void removeField(OID oid, FieldItem field, Object value) throws Exception
Storage
removeField
in interface Storage
oid
- the ID of the object that contains the fieldfield
- the ID of the field to removevalue
- Deprecated
Exception
public Collection getRootObjects() throws Exception
Storage
getRootObjects
in interface Storage
Exception
- if an error occurspublic OID getCollectionID(OID oid, CollectionItem collection) throws Exception
Storage
getCollectionID
in interface Storage
oid
- the oid of he object that owns the collectioncollection
- the collection
Exception
- if an error occurspublic List getCollectionValues(OID oid, CollectionItem collection, String table, String orderBy) throws Exception
Exception
public boolean collectionContains(String table, OID cid, Object value) throws Exception
Exception
public void clearList(OID cid) throws Exception
Storage
clearList
in interface Storage
cid
- the ID of the list to clear
Exception
- if an error occurspublic List getList(OID oid, CollectionItem collection) throws Exception
Storage
getList
in interface Storage
oid
- the ID of the object that contains the vectorcollection
- the collection to retrieve
Exception
- if an error occurspublic List getList(OID cid) throws Exception
Storage
getList
in interface Storage
cid
- the ID of the List
Exception
- if an error occurspublic long getListSize(OID cid) throws Exception
Storage
getListSize
in interface Storage
cid
- the ID of the list
Exception
- if an error occurspublic boolean listContains(OID cid, Object value) throws Exception
Storage
listContains
in interface Storage
cid
- the ID of the Listvalue
- the object to look for in the list
Exception
- if an error occurspublic Object getListItem(OID cid, long index) throws Exception
Storage
getListItem
in interface Storage
cid
- the ID of the Listindex
- the index of the element
Exception
- if an error occurspublic long getIndexInList(OID cid, Object value) throws Exception
Storage
getIndexInList
in interface Storage
cid
- the ID of the Listvalue
- the value
Exception
- if an error occursprotected long getInternalIndexInList(OID cid, Object value) throws Exception
Exception
public long getLastIndexInList(OID cid, Object value) throws Exception
Storage
getLastIndexInList
in interface Storage
cid
- the ID of the Listvalue
- the value
Exception
- if an error occurspublic void addToList(OID cid, long position, Object value) throws Exception
Storage
addToList
in interface Storage
cid
- the ID of the Listposition
- the position where to insert the valuevalue
- the value to insert
Exception
- if an error occurspublic void addToList(OID cid, Object value) throws Exception
Storage
addToList
in interface Storage
cid
- the ID of the Listvalue
- the value to add
Exception
- if an error occurspublic void setListItem(OID cid, long index, Object value) throws Exception
Storage
setListItem
in interface Storage
cid
- the ID of the Listindex
- the index of the element to setvalue
- the value
Exception
- if an error occurspublic void removeFromList(OID cid, long position) throws Exception
Storage
removeFromList
in interface Storage
cid
- the ID the Listposition
- the position of the element to remove
Exception
- if an error occurspublic void removeFromList(OID cid, Object value) throws Exception
Storage
removeFromList
in interface Storage
cid
- the ID the Listvalue
- the value to remove
Exception
- if an error occurspublic void clearSet(OID cid) throws Exception
Storage
clearSet
in interface Storage
cid
- the ID of the set to clear
Exception
- if an error occurspublic List getSet(OID oid, CollectionItem collection) throws Exception
Storage
getSet
in interface Storage
oid
- the ID of the object that contains the Setcollection
- the collection
Exception
- if an error occurspublic List getSet(OID cid) throws Exception
Storage
getSet
in interface Storage
cid
- the ID of the Set
Exception
- if an error occurspublic long getSetSize(OID cid) throws Exception
Storage
getSetSize
in interface Storage
cid
- the ID of the list
Exception
- if an error occurspublic boolean setContains(OID cid, Object value) throws Exception
Storage
setContains
in interface Storage
cid
- the ID of the Setvalue
- the value
Exception
- if an error occurspublic boolean addToSet(OID cid, Object value) throws Exception
Storage
addToSet
in interface Storage
cid
- the ID of the Setvalue
- the value to add
Exception
- if an error occurspublic boolean removeFromSet(OID cid, Object value) throws Exception
Storage
removeFromSet
in interface Storage
cid
- the ID of the Setvalue
- the value to add
Exception
- if an error occurspublic void clearMap(OID cid) throws Exception
Storage
clearMap
in interface Storage
cid
- the ID of the set to clear
Exception
- if an error occurspublic Map getMap(OID oid, CollectionItem collection) throws Exception
Storage
getMap
method here.
getMap
in interface Storage
oid
- an OID
valuecollection
- a CollectionItem
value
Map
value
Exception
- if an error occurspublic Map getMap(OID cid) throws Exception
Storage
getMap
in interface Storage
cid
- the ID of the Set
Exception
- if an error occurspublic long getMapSize(OID cid) throws Exception
Storage
getMapSize
in interface Storage
cid
- the ID of the list
Exception
- if an error occurspublic Object putInMap(OID cid, Object key, Object value) throws Exception
Storage
putInMap
in interface Storage
cid
- the ID of the Mapkey
- the keyvalue
- the value
Exception
- if an error occurspublic Object getFromMap(OID cid, Object key) throws Exception
Storage
getFromMap
in interface Storage
cid
- the ID of the Mapkey
- the key
Exception
- if an error occurspublic boolean mapContainsKey(OID cid, Object key) throws Exception
Storage
mapContainsKey
in interface Storage
cid
- the ID of the Mapkey
- the key to search
Exception
- if an error occurspublic boolean mapContainsValue(OID cid, Object value) throws Exception
Storage
mapContainsValue
in interface Storage
cid
- the ID of the Mapvalue
- the value to search
Exception
- if an error occurspublic Object removeFromMap(OID cid, Object key) throws Exception
Storage
removeFromMap
in interface Storage
cid
- the ID the Mapkey
- the key to remove
Exception
- if an error occurspublic String newName(String className) throws Exception
Storage
newName
in interface Storage
className
- the className of the instance for which to generate a name
Exception
public OID getOIDFromName(String name) throws Exception
Storage
getOIDFromName
in interface Storage
name
- the candidate object name
Exception
public String getNameFromOID(OID oid) throws Exception
Storage
getNameFromOID
in interface Storage
oid
- the candidate object oid
Exception
public void bindOIDToName(OID oid, String name) throws Exception
Storage
This method allows the user to create persistence roots.
bindOIDToName
in interface Storage
oid
- an existing object IDname
- the name that is given to it
Exception
public void deleteName(String name) throws Exception
Storage
deleteName
in interface Storage
name
- the name to remove
Exception
public String getClassID(OID oid) throws Exception
Storage
getClassID
in interface Storage
oid
- the object's class ID
Exception
- if an error occurspublic Collection getObjects(ClassItem cl) throws Exception
Storage
getObjects
in interface Storage
cl
- the class
Exception
protected void getObjects(ClassItem cl, Vector objects) throws SQLException
SQLException
public void startTransaction() throws SQLException
Storage
startTransaction
in interface Storage
SQLException
public void commit() throws SQLException
Storage
commit
in interface Storage
SQLException
public void rollback() throws SQLException
Storage
rollback
in interface Storage
SQLException
protected void checkStorage()
public OID createObject(String className) throws Exception
createObject
in interface Storage
className
- a String
value
Exception
- if an error occurspublic abstract long getNextVal(String sequence) throws Exception
Exception
public long getLong(String query) throws Exception
Exception
public OID getOID(String query) throws Exception
Exception
public static String addSlashes(String str)
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |