Methods Summary |
---|
private java.lang.String | getEffectiveKey(java.lang.String key)
// Everything after the first .
int index = key.indexOf(".");
if(index < 0)
return key;
return key.substring(index + 1);
|
private java.lang.String | getIndex(java.lang.String key)
// Everything before the first .
int index = key.indexOf(".");
if(index < 0)
return "default";
return key.substring(0, index);
|
public java.lang.String[] | getKeys(java.lang.String index)This method returns all the keys for the given index.
Repository rep = getRepository(index);
return rep.keys();
|
public java.lang.Object | getObject(java.lang.String key)
String fname = getProperty(key);
Object obj = null;
// Use this fname to deserialize...
if(fname != null) {
try{
FileInputStream fstream = new FileInputStream(fname);
ObjectInputStream objstream =
new ObjectInputStream(fstream);
obj = objstream.readObject();
fstream.close();
}catch(Exception e){
//IASRI 4660742 e.printStackTrace(System.out);
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.file_exception",e);
// END OF IASRI 4660742
}
}
return obj;
|
public java.lang.String | getProperty(java.lang.String key)This method gets a property value associated with the given key.
String index = getIndex(key);
String newKey = getEffectiveKey(key);
Repository rep = getRepository(index);
String val = null;
if(rep.getName().equals(index)){
val = rep.find(newKey);
} else {
val = rep.find(key);
}
return val;
|
private Repository | getRepository(java.lang.String repName)
Repository rep = (Repository) table.get(repName);
if(rep == null) {
rep = new Repository(repName);
if(rep.getName().equals(repName)) {
table.put(repName, rep);
} else
rep = defaultRepository;
}
return rep;
|
public void | removeObject(java.lang.String key)
String fname = getProperty(key);
// Use this fname & delete the file first..
if(fname != null) {
try{
File file = new File(fname);
if(file.exists())
file.delete();
removeProperty(key);
}catch(Exception e){
//IASRI 4660742 e.printStackTrace(System.out);
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.file_exception",e);
// END OF IASRI 4660742
}
}
|
public void | removeProperty(java.lang.String key)This method removes a property value given the key.
String index = getIndex(key);
String newKey = getEffectiveKey(key);
Repository rep = getRepository(index);
if(rep.getName().equals(index)){
rep.remove(newKey);
} else {
rep.remove(key);
}
|
public void | setObject(java.lang.String key, java.lang.Object obj)This method associates an Object with the given key.
String className = obj.getClass().getName();
String instanceId = String.valueOf(obj.hashCode());
String fname = OBJECT_STORE_DIR + className + instanceId +
OBJECT_FILE_EXT;
// serialize obj and store it in the file .....
try{
String absFileName = FileUtil.getAbsolutePath(fname);
FileOutputStream fstream = new FileOutputStream(absFileName);
ObjectOutputStream objstream = new ObjectOutputStream(fstream);
objstream.writeObject(obj);
objstream.flush();
fstream.close();
setProperty(key, absFileName);
}catch(Exception e){
//IASRI 4660742 e.printStackTrace(System.out);
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.file_exception",e);
// END OF IASRI 4660742
}
|
public void | setProperty(java.lang.String key, java.lang.String value)This method associates a property value with the given key.
String index = getIndex(key);
String newKey = getEffectiveKey(key);
Repository rep = getRepository(index);
if(rep.getName().equals(index)){
rep.add(newKey, value);
} else {
rep.add(key, value);
}
|