DLESE Tools
v1.6.0

org.dlese.dpc.schemedit.config
Class AbstractConfigReader

java.lang.Object
  extended by org.dlese.dpc.schemedit.config.AbstractConfigReader
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AccessManager, CollectionConfigReader, FrameworkConfigReader, SuggestionServiceManager

public class AbstractConfigReader
extends Object
implements Serializable

Abstract class for extracting information from, and writing to, XML config files

Author:
ostwald

See Also:
Serialized Form

Field Summary
protected static boolean debug
          Description of the Field
protected  DocumentFactory df
           
protected  DocMap docMap
           
protected  String nameSpaceInfo
           
protected  String rootElementName
           
protected  File source
           
protected static boolean writeOnDestroy
          Description of the Field
 
Constructor Summary
AbstractConfigReader(File source)
          Create a AbstractConfigReader.
AbstractConfigReader(String xmlSource)
           
 
Method Summary
 void destroy()
          This method is called at the conclusion of processing and may be used for tear-down.
 void flush()
          Write config document to disk and then force reread of values.
 Document getDelocalizedDoc()
          Gets delocalized Document for this reader.
 DocMap getDocMap()
          Gets the document attribute of the AbstractConfigReader object
 Document getDocument()
          Gets the localized Document for this reader.
 Node getNode(String xpath)
          Gets a single Node satisfying give XPath.
 List getNodes(String xpath)
          Get all Nodes satisfying the given xpath.
 String getNodeText(String xpath)
          return the Text of a Node satisfying the given XPath.
 File getSource()
          Gets the source attribute of the AbstractConfigReader object
 String getSourcePath()
          Gets the sourcePath attribute of the AbstractConfigReader object
protected static void prtln(String s)
          Print a line to standard out.
 void refresh()
          Write Document to disk and then set docMap to null, forcing a re-read upon next access.
protected  void setNodeText(String xpath, String value)
          Sets the nodeText for specified path, creating new node if necessary.
protected  void setSource(File file)
          set source file, used when creating new CollectionConfig's by first reading a default config file and then assigning a new source so it will be written to a new config file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static boolean debug
Description of the Field


writeOnDestroy

protected static boolean writeOnDestroy
Description of the Field


rootElementName

protected String rootElementName

nameSpaceInfo

protected String nameSpaceInfo

docMap

protected DocMap docMap

source

protected File source

df

protected DocumentFactory df
Constructor Detail

AbstractConfigReader

public AbstractConfigReader(File source)
                     throws Exception
Create a AbstractConfigReader.

Parameters:
source - Description of the Parameter
Throws:
Exception

AbstractConfigReader

public AbstractConfigReader(String xmlSource)
                     throws Exception
Throws:
Exception
Method Detail

getSourcePath

public String getSourcePath()
Gets the sourcePath attribute of the AbstractConfigReader object

Returns:
The sourcePath value

getDocMap

public DocMap getDocMap()
                 throws Exception
Gets the document attribute of the AbstractConfigReader object

Returns:
The document value
Throws:
Exception - Description of the Exception

getSource

public File getSource()
Gets the source attribute of the AbstractConfigReader object

Returns:
The source value

setSource

protected void setSource(File file)
set source file, used when creating new CollectionConfig's by first reading a default config file and then assigning a new source so it will be written to a new config file

Parameters:
file - The new source value

getDocument

public Document getDocument()
Gets the localized Document for this reader.


getDelocalizedDoc

public Document getDelocalizedDoc()
                           throws Exception
Gets delocalized Document for this reader.

Throws:
Exception

flush

public void flush()
           throws Exception
Write config document to disk and then force reread of values.

Throws:
Exception - Description of the Exception

refresh

public void refresh()
Write Document to disk and then set docMap to null, forcing a re-read upon next access.


getNodes

public List getNodes(String xpath)
Get all Nodes satisfying the given xpath.

Parameters:
xpath - an XPath
Returns:
a List of all modes satisfying given XPath, or null

getNode

public Node getNode(String xpath)
Gets a single Node satisfying give XPath. If more than one Node is found, the first is returned (and a msg is printed).

Parameters:
xpath - an XPath
Returns:
a dom4j Node

getNodeText

public String getNodeText(String xpath)
return the Text of a Node satisfying the given XPath.

Parameters:
xpath - an XPath\
Returns:
Text of Node or empty String if no Node is found

setNodeText

protected void setNodeText(String xpath,
                           String value)
Sets the nodeText for specified path, creating new node if necessary.

Parameters:
xpath - The new nodeText value
value - The new nodeText value

destroy

public void destroy()
This method is called at the conclusion of processing and may be used for tear-down.


prtln

protected static void prtln(String s)
Print a line to standard out.

Parameters:
s - The String to print.

DLESE Tools
v1.6.0