org.sape.carbon.core.config.node.file
Class FileConfigurationDocument

java.lang.Object
  |
  +--org.sape.carbon.core.config.node.AbstractNode
        |
        +--org.sape.carbon.core.config.node.AbstractConfigurationDocument
              |
              +--org.sape.carbon.core.config.node.file.FileConfigurationDocument
All Implemented Interfaces:
ConfigurationDocument, Node

public class FileConfigurationDocument
extends AbstractConfigurationDocument

A node that represents a physical configuration file within a file system. Files are read and writen using a ConfigurationFormatService. These nodes may not have children. Read and write access to the underlying file is synchronized for thread safety. Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.17 $($Author: dvoet $ / $Date: 2003/12/18 18:42:14 $)
Author:
Mike Redd, February 2001
See Also:
FileFolder, ConfigurationFormatService

Field Summary
private  File file
          file where this node's configuration is persisted
 
Fields inherited from class org.sape.carbon.core.config.node.AbstractConfigurationDocument
configuration
 
Fields inherited from class org.sape.carbon.core.config.node.AbstractNode
childNodes, nodeListeners
 
Fields inherited from interface org.sape.carbon.core.config.node.Node
DELIMITER
 
Constructor Summary
FileConfigurationDocument(Node parent, String name, ConfigurationFormatService formatter, File file)
          Constructor for FileConfigurationDocument.
 
Method Summary
protected  boolean backingDataExists()
          Method called from the refresh method to see if the backing data still exists.
protected  void destroyBackingData()
          This method is called by remove to destroy the data backing this node in the data source.
(package private)  File getInternalFileObject()
          Accessor method for file.
protected  InputStream openInputStream()
          This method should be overridden by classes implementing ConfigurationDocuments for specific data stores.
protected  OutputStream openOutputStream()
          This method should be overridden by classes implementing ConfigurationDocuments for specific data stores.
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractConfigurationDocument
addNestedConfigurationDocument, closeInputStream, closeOutputStream, getAllChildNames, getFormatService, getNestedNodeFactory, issueNodeModifiedEvent, loadChild, notifyNestedDocuments, readConfiguration, refresh, remove, writeChildReferences, writeConfiguration
 
Methods inherited from class org.sape.carbon.core.config.node.AbstractNode
addNodeListener, addNodeListener, addNodeListener, containsChild, fetchChild, fetchChildren, getAbsoluteName, getAddOrLoadChildLock, getAllowsChildren, getName, getParent, getReadOrAlterNodeLock, isRemoved, issueChildLoadedEvent, issueNodeRemovedEvent, removeRemovedChildren, setRemoved, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.sape.carbon.core.config.node.Node
addNodeListener, addNodeListener, containsChild, fetchChild, fetchChildren, getAbsoluteName, getAllowsChildren, getName, getParent, isRemoved
 

Field Detail

file

private File file
file where this node's configuration is persisted

Constructor Detail

FileConfigurationDocument

public FileConfigurationDocument(Node parent,
                                 String name,
                                 ConfigurationFormatService formatter,
                                 File file)
Constructor for FileConfigurationDocument.

Parameters:
parent - the parent node containing this configuration.
name - name of the configuration being loaded
formatter - formatter for the document
file - file containing the configuration document
Throws:
NullPointerException - if file is null
Method Detail

destroyBackingData

protected void destroyBackingData()
                           throws NodeRemovalException
Description copied from class: AbstractNode
This method is called by remove to destroy the data backing this node in the data source. Implementations of this method should remove all traces of the Node's existence

Specified by:
destroyBackingData in class AbstractNode
Throws:
NodeRemovalException - indicates an error removing the node
See Also:
AbstractNode.destroyBackingData()

openInputStream

protected InputStream openInputStream()
                               throws IOException
Description copied from class: AbstractConfigurationDocument
This method should be overridden by classes implementing ConfigurationDocuments for specific data stores. The returned InputStream should be a stream of data that can be read by the ConfigurationFormatService and converted to a Configuration object.

This method is called by readConfiguration.

Specified by:
openInputStream in class AbstractConfigurationDocument
Returns:
InputStream the InputStream from which to read the Configuration object within this ConfigurationDocument
IOException
See Also:
AbstractConfigurationDocument.openInputStream()

openOutputStream

protected OutputStream openOutputStream()
                                 throws IOException
Description copied from class: AbstractConfigurationDocument
This method should be overridden by classes implementing ConfigurationDocuments for specific data stores. The returned OutputStream should be a stream of data that can be written to by the ConfigurationFormatService.

This method is called by writeConfiguration.

Specified by:
openOutputStream in class AbstractConfigurationDocument
Returns:
OutputStream the OutputStream to which to write the Configuration object within this ConfigurationDocument
IOException
See Also:
AbstractConfigurationDocument.openOutputStream()

backingDataExists

protected boolean backingDataExists()
Description copied from class: AbstractNode
Method called from the refresh method to see if the backing data still exists. If it exists, the isRemoved flag is set to false, if it does not, the isRemoved flag is set to true.

Specified by:
backingDataExists in class AbstractNode
Returns:
boolean true if the backing date exists, false otherwise
See Also:
AbstractNode.backingDataExists()

getInternalFileObject

File getInternalFileObject()
Accessor method for file.

Returns:
File internal File object representing the file on the file system.


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.