scala.xml.persistent

class CachedFileStorage

[source: scala/xml/persistent/CachedFileStorage.scala]

abstract class CachedFileStorage(private file1 : java.io.File)
extends java.lang.Thread with Logged

Mutable storage of immutable xml trees. Everything is kept in memory, with a thread periodically checking for changes and writing to file. To ensure atomicity, two files are used, filename1 and '$'+filename1. The implementation switches between the two, deleting the older one after a complete dump of the database has been written.

Author
Burak Emir
Direct Known Subclasses:
IndexedStorage, SetStorage

Value Summary
protected var dirty : Boolean
this storage modified since last modification check
protected val interval : Int
period between modification checks, in milliseconds
Method Summary
abstract def += (e : Node) : Unit
adds a node, setting this.dirty to true as a side effect
abstract def -= (e : Node) : Unit
removes a tree, setting this.dirty to true as a side effect
def flush : Unit
forces writing of contents to the file, even if there has not been any update.
protected def initialNodes : Iterator[Node]
finds and loads the storage file. subclasses should call this method prior to any other, but only once, to obtain the initial sequence of nodes.
abstract def nodes : Iterator[Node]
returns an iterator over the nodes in this storage
override def run : Unit
run method of the thread. remember to use start() to start a thread, not run.
Methods inherited from Logged
log
Methods inherited from java.lang.Thread
java.lang.Thread.start, java.lang.Thread.stop, java.lang.Thread.stop, java.lang.Thread.interrupt, java.lang.Thread.isInterrupted, java.lang.Thread.destroy, java.lang.Thread.isAlive, java.lang.Thread.suspend, java.lang.Thread.resume, java.lang.Thread.setPriority, java.lang.Thread.getPriority, java.lang.Thread.setName, java.lang.Thread.getName, java.lang.Thread.getThreadGroup, java.lang.Thread.countStackFrames, java.lang.Thread.join, java.lang.Thread.join, java.lang.Thread.join, java.lang.Thread.setDaemon, java.lang.Thread.isDaemon, java.lang.Thread.checkAccess, java.lang.Thread.toString, java.lang.Thread.getContextClassLoader, java.lang.Thread.setContextClassLoader, java.lang.Thread.getStackTrace, java.lang.Thread.getId, java.lang.Thread.getState, java.lang.Thread.getUncaughtExceptionHandler, java.lang.Thread.setUncaughtExceptionHandler
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
protected var dirty : Boolean
this storage modified since last modification check

protected val interval : Int
period between modification checks, in milliseconds

Method Details
protected def initialNodes : Iterator[Node]
finds and loads the storage file. subclasses should call this method prior to any other, but only once, to obtain the initial sequence of nodes.

abstract def nodes : Iterator[Node]
returns an iterator over the nodes in this storage

abstract def +=(e : Node) : Unit
adds a node, setting this.dirty to true as a side effect

abstract def -=(e : Node) : Unit
removes a tree, setting this.dirty to true as a side effect

override def run : Unit
run method of the thread. remember to use start() to start a thread, not run.
Overrides
java.lang.Thread.java.lang.Thread.run

def flush : Unit
forces writing of contents to the file, even if there has not been any update.