|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jac.aspects.persistence.FSStorage
A FileSystem storage
Field Summary | |
protected String |
encoding
|
protected String |
id
|
Constructor Summary | |
FSStorage(PersistenceAC ac,
String basedirName)
Create a new file system storage with the default encoding |
|
FSStorage(PersistenceAC ac,
String basedirName,
String encoding)
Create a new file system storage |
Method Summary | |
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. |
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()
Safely close the storage. |
void |
commit()
Commit started transaction |
OID |
createObject(String className)
Create an object in the storage. |
void |
deleteName(String name)
Delete a name from the storage. |
void |
deleteObject(OID oid)
Delete an object from the storage. |
String |
getClassID(OID oid)
Get the class ID of a given object. |
OID |
getCollectionID(OID oid,
CollectionItem collection)
Get the ID of a collection |
protected long |
getCollectionSize(OID cid)
|
Object |
getField(OID oid,
FieldItem field)
Get the value of a field. |
protected Properties |
getFields(OID oid)
|
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. |
String |
getId()
Returns the id of the storage |
long |
getIndexInList(OID cid,
Object value)
Get the smallest index of an element in a List. |
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 |
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 |
Map |
getNameCounters()
Gets the name counters used to generate new names. |
String |
getNameFromOID(OID oid)
Get the name of an object from its oid. |
Collection |
getObjects(ClassItem cl)
Get all instances of a class, or all objects if cl == null. |
protected void |
getObjects(ClassItem cl,
Vector objects)
Gets all instances of a class and its subclasses. |
OID |
getOIDFromName(String name)
Get the ID of an object from its name. |
protected PrintWriter |
getPrintWriter(File file,
boolean append,
boolean autoFlush)
|
protected PrintWriter |
getPrintWriter(OID oid,
boolean append,
boolean autoFlush)
|
protected PrintWriter |
getPrintWriter(OutputStream stream,
boolean autoFlush)
|
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 |
protected StreamTokenizer |
getStreamTokenizer(File file)
|
protected Writer |
getWriter(File file,
boolean append)
|
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 |
saveList(OID cid,
List list)
|
protected void |
saveMap(OID cid,
Map map)
|
boolean |
setContains(OID cid,
Object value)
Say if a set contains an object. |
void |
setField(OID oid,
FieldItem field,
Object value)
Initialize the value of an object's field. |
void |
setId(String id)
Sets the id of the storage |
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 value)
Update a field value. |
protected void |
updateJacNames()
|
void |
updateNameCounters(Map counters)
Sets the name counters used to generate new names. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected String encoding
protected String id
Constructor Detail |
public FSStorage(PersistenceAC ac, String basedirName) throws Exception
basedirName
- name of the directory where to store data filespublic FSStorage(PersistenceAC ac, String basedirName, String encoding) throws Exception
basedirName
- name of the directory where to store data filesencoding
- the encoding to use for filesMethod Detail |
public String getId()
Storage
getId
in interface Storage
public void setId(String id)
Storage
setId
in interface Storage
protected void updateJacNames()
public void close()
close
in interface Storage
public Map getNameCounters()
Storage
getNameCounters
in interface Storage
Storage.updateNameCounters(Map)
public void updateNameCounters(Map counters) throws IOException
Storage
updateNameCounters
in interface Storage
counters
- a Map associating counter names to a Long
value. The value is the next value to be used. A counter is
updated only if the suplied value is greater than the current
value.
IOException
Storage.getNameCounters()
protected StreamTokenizer getStreamTokenizer(File file) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public OID createObject(String className) throws Exception
Storage
createObject
in interface Storage
className
- a String
value
Exception
- if an error occurspublic 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 value) throws Exception
Storage
setField
in interface Storage
oid
- the ID of the object that will contain the fieldfield
- the field to setvalue
- the value of the field
Exception
- if an error occurspublic void updateField(OID oid, FieldItem field, Object value) throws Exception
Storage
updateField
in interface Storage
oid
- the ID of the object that already contains the fieldfield
- the field to updatevalue
- 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 occursprotected Properties getFields(OID oid) throws IOException
IOException
public 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 occursprotected long getCollectionSize(OID cid) throws Exception
Exception
public 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 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 Object getListItem(OID cid, long index) throws Exception, IndexOutOfBoundsException
Storage
getListItem
in interface Storage
cid
- the ID of the Listindex
- the index of the element
Exception
- if an error occurs
IndexOutOfBoundsException
public 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 occursprotected void saveList(OID cid, List list) throws IOException
IOException
public 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 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 occurspublic 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 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 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 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 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 occursprotected void saveMap(OID cid, Map map) throws IOException
IOException
public void clearMap(OID cid) throws Exception
Storage
clearMap
in interface Storage
cid
- the ID of the set to clear
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 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 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 getRootObjects() throws Exception
Storage
getRootObjects
in interface Storage
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 Exception
cl
- the classobjects
- instances of the class are added to this collection
Exception
public void startTransaction()
Storage
startTransaction
in interface Storage
public void commit()
Storage
commit
in interface Storage
public void rollback()
Storage
rollback
in interface Storage
protected PrintWriter getPrintWriter(OID oid, boolean append, boolean autoFlush) throws IOException
IOException
protected PrintWriter getPrintWriter(File file, boolean append, boolean autoFlush) throws IOException
IOException
protected PrintWriter getPrintWriter(OutputStream stream, boolean autoFlush) throws IOException
IOException
protected Writer getWriter(File file, boolean append) throws IOException
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |