jgnash.engine.xml
Class XMLContainer
java.lang.Object
jgnash.engine.xml.XMLContainer
public class XMLContainer
- extends java.lang.Object
Simple object container for StoredObjects that reads and writes a xml file
- Version:
- $Id$
- Author:
- Craig Cavanaugh
|
Constructor Summary |
protected |
XMLContainer(java.io.File file)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
objects
private final java.util.List<StoredObject> objects
readWriteLock
private final java.util.concurrent.locks.ReadWriteLock readWriteLock
file
private final java.io.File file
fileLock
private java.nio.channels.FileLock fileLock
lockChannel
private java.nio.channels.FileChannel lockChannel
XMLContainer
protected XMLContainer(java.io.File file)
acquireFileLock
private boolean acquireFileLock()
releaseFileLock
private boolean releaseFileLock()
commit
void commit()
set
boolean set(StoredObject object)
delete
void delete(StoredObject object)
get
StoredObject get(java.lang.String uuid)
query
<T extends StoredObject> java.util.List<T> query(java.lang.Class<T> clazz)
close
void close()
getFileName
java.lang.String getFileName()
query
private static <T extends StoredObject> java.util.List<T> query(java.util.Collection<StoredObject> values,
java.lang.Class<T> clazz)
asList
java.util.List<StoredObject> asList()
- Returns of list of all
StoredObjects held within this container. The returned list is a defensive
copy.
- Returns:
- A list of all
StoredObjects - See Also:
StoredObject
writeXML
private void writeXML()
writeXML
public static void writeXML(java.util.Collection<StoredObject> objects,
java.io.File file)
- Writes an XML file given a collection of StoredObjects. TrashObjects and objects marked for removal are not
written. If the file already exists, it will be overwritten.
- Parameters:
objects - Collection of StoredObjects to writefile - file to write
readXML
void readXML()
throws java.io.FileNotFoundException,
java.io.UnsupportedEncodingException
- Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
configureXStream
private static com.thoughtworks.xstream.XStream configureXStream(com.thoughtworks.xstream.XStream xstream)