|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.unidata.xml.XmlObjectStore
public class XmlObjectStore
This allows us to use the XmlEncoder to read/write a Hashtable that holds a collection
of persistent objects.
| Field Summary | |
|---|---|
protected List |
tmpFiles
Keep track of the tmp files that have been created |
| Constructor Summary | |
|---|---|
XmlObjectStore(XmlEncoder encoder)
Create a new store. |
|
| Method Summary | |
|---|---|
int |
append(XmlResourceCollection rc,
boolean onlyAddIfNotExists)
_more_ |
void |
cleanupTmpDirectory()
This routine will delete all files in the user's tmp directory but will leave the directories |
void |
cleanupTmpFiles()
This method will remove all temp files that have been created during the current run of the program and clear out the list of tmp files. |
Object |
get(Object key)
Lookup the given key's value. |
Object |
get(String key)
Return the object held in the table identified by the given key. |
boolean |
get(String key,
boolean dflt)
Lookup the given key's value. |
char |
get(String key,
char dflt)
Lookup the given key's value. |
Color |
get(String key,
Color dflt)
Lookup the given key's value. |
double |
get(String key,
double dflt)
Lookup the given key's value. |
float |
get(String key,
float dflt)
Lookup the given key's value. |
Font |
get(String key,
Font dflt)
Lookup the given key's value. |
int |
get(String key,
int dflt)
Lookup the given key's value. |
long |
get(String key,
long dflt)
Lookup the given key's value. |
short |
get(String key,
short dflt)
Lookup the given key's value. |
String |
get(String key,
String dflt)
Lookup the given key's value. |
Object |
getEncodedFile(String filename)
The given filename is a file which (should) hold the xml encoded ( XmlEncoder) version of some Object. |
protected XmlEncoder |
getEncoder()
Get the encoder we use |
String |
getFileContents(String filename)
Read the contents of the filename, which is relative to the user's directory. |
String |
getTmpFile(String tail)
Return the full path to a temporary file with the given file tail. |
File |
getUniqueTmpDirectory()
_more_ |
String |
getUniqueTmpFile(String prefix,
String suffix)
_more_ |
File |
getUserDirectory()
We will assume that the first file in the list of store files is held within the user's directory. |
String |
getUserTmpDirectory()
Create (if not there) a "tmp" directory under the user's directory. |
int |
init(XmlResourceCollection rc)
Initialize the store. |
static void |
main(String[] args)
|
protected Hashtable |
processTable(Hashtable newTable)
Process a HashTable |
void |
put(Object key,
Object value)
Put the given value. |
void |
put(String key,
boolean value)
Put the given value into the tabl. |
void |
put(String key,
char value)
Put the given value into the tabl. |
void |
put(String key,
double value)
Put the given value into the tabl. |
void |
put(String key,
float value)
Put the given value into the tabl. |
void |
put(String key,
int value)
Put the given value into the tabl. |
void |
put(String key,
long value)
Put the given value into the tabl. |
void |
put(String key,
Object value)
Put the given value. |
void |
put(String key,
short value)
Put the given value into the tabl. |
void |
putEncodedFile(String filename,
Object o)
Encode the given object and write it to the given filename. |
void |
putFile(String filename,
String contents)
Write the contents to the filename, which is relative to the user's directory. |
void |
remove(String key)
Remove the given value from the table. |
void |
save()
Save the store to disk. |
void |
saveIfNeeded()
Save the store to disk if there has been a put since the last save |
protected void |
setEncoder(XmlEncoder encoder)
Set the XmlEncoder that we use |
void |
setTmpDir(String dir)
_more_ |
boolean |
userDirectoryOk()
Check if the userDirectory is okay to write to. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List tmpFiles
| Constructor Detail |
|---|
public XmlObjectStore(XmlEncoder encoder)
encoder - | Method Detail |
|---|
protected void setEncoder(XmlEncoder encoder)
XmlEncoder that we use
encoder - The encoder we use to write out the storeprotected XmlEncoder getEncoder()
public File getUserDirectory()
public boolean userDirectoryOk()
public void setTmpDir(String dir)
dir - _more_public String getUserTmpDirectory()
public String getTmpFile(String tail)
tail - The file tail (e.g., temp.txt)
public void cleanupTmpDirectory()
public File getUniqueTmpDirectory()
public String getUniqueTmpFile(String prefix,
String suffix)
prefix - _more_suffix - _more_
public void cleanupTmpFiles()
public int init(XmlResourceCollection rc)
rc - The resource collection to read from
public int append(XmlResourceCollection rc,
boolean onlyAddIfNotExists)
rc - _more_onlyAddIfNotExists - _more_
protected Hashtable processTable(Hashtable newTable)
newTable - table to process
public Object getEncodedFile(String filename)
XmlEncoder) version of some Object.
filename - The file that contains the encoded object.
public void putEncodedFile(String filename,
Object o)
filename - The filename to write to.o - The object to encode.public String getFileContents(String filename)
filename - The file to read.
public void putFile(String filename,
String contents)
filename - The file to read.contents - The contents of the file.public Object get(String key)
key - The object's key.
public void put(String key,
boolean value)
key - The object's key.value - The value to store.
public void put(String key,
char value)
key - The object's key.value - The value to store.
public void put(String key,
short value)
key - The object's key.value - The value to store.
public void put(String key,
int value)
key - The object's key.value - The value to store.
public void put(String key,
float value)
key - The object's key.value - The value to store.
public void put(String key,
long value)
key - The object's key.value - The value to store.
public void put(String key,
double value)
key - The object's key.value - The value to store.
public void put(Object key,
Object value)
put in interface PersistentStorekey - Convert to toString to get the actual key.value - The value to store.
public void put(String key,
Object value)
key - The object's key.value - The value to store.
public String get(String key,
String dflt)
key - The object's key.dflt - The default value to return if not found.
public Color get(String key,
Color dflt)
key - The object's key.dflt - The default value to return if not found.
public Font get(String key,
Font dflt)
key - The object's key.dflt - The default value to return if not found.
public boolean get(String key,
boolean dflt)
key - The object's key.dflt - The default value to return if not found.
public char get(String key,
char dflt)
key - The object's key.dflt - The default value to return if not found.
public short get(String key,
short dflt)
key - The object's key.dflt - The default value to return if not found.
public int get(String key,
int dflt)
key - The object's key.dflt - The default value to return if not found.
public float get(String key,
float dflt)
key - The object's key.dflt - The default value to return if not found.
public long get(String key,
long dflt)
key - The object's key.dflt - The default value to return if not found.
public double get(String key,
double dflt)
key - The object's key.dflt - The default value to return if not found.
public Object get(Object key)
get in interface PersistentStorekey - The object's key.
public void remove(String key)
key - The object's key.public void saveIfNeeded()
public void save()
save in interface PersistentStorepublic static void main(String[] args)
args - Command line args.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||