|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
model.XMLFile
public class XMLFile
The class is used to store the data contained in a Tournament object to the file system in XML format. The XML document is maintained in memory and when it is altered the changes are saved to disk.
Nested Class Summary | |
---|---|
private static class |
XMLFile.BackupDataFileFilter
|
Field Summary | |
---|---|
private org.w3c.dom.Element |
base_fee
|
private org.w3c.dom.Element |
confirmed_pre_entries
|
private org.w3c.dom.Element |
date
|
private org.w3c.dom.Element |
default_country
|
private org.w3c.dom.Element |
discount_id_counter
|
private org.w3c.dom.Element |
discounts
|
private org.w3c.dom.Document |
doc
|
private org.w3c.dom.Element |
element_id
|
private org.w3c.dom.Element |
entries
|
private org.w3c.dom.Element |
entry_id_counter
|
private org.w3c.dom.Element |
header
|
private org.w3c.dom.Element |
html
|
private org.w3c.dom.Element |
name
|
private org.w3c.dom.Element |
pre_entries
|
private org.w3c.dom.Element |
preregistration_open
|
private static long |
serialVersionUID
UID for serialization |
private org.w3c.dom.Element |
tournament_open
|
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
---|---|
protected |
XMLFile(java.io.File folder,
java.lang.String filename)
Creates a pathname string and calls the constructor XMLFile(final String pathname) |
protected |
XMLFile(java.io.File folder,
java.lang.String filename,
TournamentInitializer initializer)
Creates a pathname string and calls the constructor XMLFile(final String pathname, final TournamentInitializer initializer) |
protected |
XMLFile(java.lang.String pathname)
Create a new XMLFile object based on a XML data file on disk |
protected |
XMLFile(java.lang.String pathname,
TournamentInitializer initializer)
Creates a completely new tournament XML data file with data from the initializer. |
Method Summary | |
---|---|
protected void |
addEntry(Entry... entriestoadd)
Adds a new entry element to XML document as a child of element 'entries' with the data from the entry. |
protected void |
addPreEntry(Entry... preentries)
Adds a new entry element to XML document as a child of element 'preEntries' with the data from the entry. |
protected void |
closeTournament()
Sets the tournament as closed in the XML data file |
protected void |
confirmPreEntry(ID entry_id)
Moves the pre-entry with the given ID under the element 'confirmedPreEntries' |
private static void |
copyFile(java.io.File from_file,
java.io.File to_file)
Copies a file. |
protected void |
deleteBackupFiles()
|
protected void |
deleteEntry(ID entry_id)
Deletes an entry element that is a descendant of 'entries' |
private org.w3c.dom.Element |
deleteEntry(ID entry_id,
org.w3c.dom.Element parent_elem)
Deletes an entry element that is a descendant of 'parent_elem' |
protected void |
deletePreEntry(ID entry_id)
Deletes an entry element that is a descendant of 'preEntries' |
protected java.util.ArrayList<Entry> |
getConfirmedPreEntries(Tournament tournament)
Returns an Entry-array of all the confirmed pre-entries in the tournament file. |
protected ID |
getDiscountIdCounter()
|
protected java.util.ArrayList<Entry> |
getEntries(Tournament tournament)
Returns an Entry-array of all the entries in the tournament file. |
private org.w3c.dom.Element |
getEntryElement(ID entry_id)
|
private org.w3c.dom.Element |
getEntryElement(ID entry_id,
org.w3c.dom.Element parent_elem)
|
protected ID |
getEntryIdCounter()
|
protected java.util.ArrayList<Entry> |
getPreEntries(Tournament tournament)
Returns an Entry-array of all the pre-entries in the tournament file. |
protected ID |
getTournamentId()
|
protected TournamentInitializer |
getTournamentInitializer()
|
protected ID |
incrementDiscountIdCounter(int increment)
Updates the discount ID counter of the tournament |
protected ID |
incrementEntryIdCounter(int increment)
Updates the entry ID counter of the tournament |
protected void |
openTournament()
Sets the tournament as open in the XML data file |
private void |
setElementReferences()
Sets the fields of the class to point to different elements of the XML document for convenience |
protected void |
updateEntry(ID entry_id,
EntryUpdater updater)
Updates the entry element with the ID 'entry_id' with the data from the updater |
protected void |
updateHeader(TournamentUpdater updater)
Updates the tournament information and discounts. |
protected void |
write()
Writes the XML document to disk. |
Methods inherited from class java.io.File |
---|
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private transient org.w3c.dom.Document doc
private transient org.w3c.dom.Element header
private transient org.w3c.dom.Element element_id
private transient org.w3c.dom.Element name
private transient org.w3c.dom.Element html
private transient org.w3c.dom.Element default_country
private transient org.w3c.dom.Element date
private transient org.w3c.dom.Element base_fee
private transient org.w3c.dom.Element preregistration_open
private transient org.w3c.dom.Element tournament_open
private transient org.w3c.dom.Element discounts
private transient org.w3c.dom.Element entry_id_counter
private transient org.w3c.dom.Element discount_id_counter
private transient org.w3c.dom.Element entries
private transient org.w3c.dom.Element pre_entries
private transient org.w3c.dom.Element confirmed_pre_entries
Constructor Detail |
---|
protected XMLFile(java.lang.String pathname) throws DataFileException, XMLParsingException
pathname
- absolute pathname of the XML file to be read
DataFileException
- thrown if the XML data file is not found
XMLParsingException
- thrown if the data file cannot be parsed as an XML documentprotected XMLFile(java.lang.String pathname, TournamentInitializer initializer) throws GoException
pathname
- absolute pathname of the XMLFile to be created
GoException
- thrown if the XMLFile cannot be created or the initializer cannot be readprotected XMLFile(java.io.File folder, java.lang.String filename) throws DataFileException, XMLParsingException
DataFileException
XMLParsingException
protected XMLFile(java.io.File folder, java.lang.String filename, TournamentInitializer initializer) throws GoException
GoException
Method Detail |
---|
private void setElementReferences()
private org.w3c.dom.Element getEntryElement(ID entry_id)
entry_id
- ID
private org.w3c.dom.Element getEntryElement(ID entry_id, org.w3c.dom.Element parent_elem)
entry_id
- IDparent_elem
-
protected ID getTournamentId()
protected TournamentInitializer getTournamentInitializer() throws GoException
GoException
- if there is a problem with the initializerprotected void closeTournament() throws GoIOException
GoIOException
- if write operation failsprotected void openTournament() throws GoIOException
GoIOException
- if write operation failsprotected ID getEntryIdCounter()
protected ID getDiscountIdCounter()
protected ID incrementEntryIdCounter(int increment) throws GoIOException
increment
- by how much the counter is incremented
GoIOException
- if the write operation failsprotected ID incrementDiscountIdCounter(int increment) throws GoIOException
increment
- by how much the counter is incremented
GoIOException
- if the write operation failsprotected void addPreEntry(Entry... preentries) throws GoIOException
preentries
- the pre-entries to be added
GoIOException
- if the write operation failsprotected void addEntry(Entry... entriestoadd) throws GoIOException
entriestoadd
- the entries to be added
GoIOException
- if the write operation failsprotected java.util.ArrayList<Entry> getEntries(Tournament tournament) throws GoException
GoException
protected java.util.ArrayList<Entry> getPreEntries(Tournament tournament) throws GoException
GoException
protected java.util.ArrayList<Entry> getConfirmedPreEntries(Tournament tournament) throws GoException
GoException
protected void confirmPreEntry(ID entry_id) throws GoIOException
GoIOException
protected void updateHeader(TournamentUpdater updater) throws GoIOException
GoIOException
protected void deleteEntry(ID entry_id) throws GoIOException
GoIOException
protected void deletePreEntry(ID entry_id) throws GoIOException
GoIOException
private org.w3c.dom.Element deleteEntry(ID entry_id, org.w3c.dom.Element parent_elem)
protected void updateEntry(ID entry_id, EntryUpdater updater) throws GoIOException
GoIOException
protected void write() throws GoIOException
GoIOException
private static void copyFile(java.io.File from_file, java.io.File to_file)
protected void deleteBackupFiles()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |