com.partnersoft.system
Class Config

java.lang.Object
  extended by com.partnersoft.system.Config

public class Config
extends java.lang.Object

Global configuration store. Config is primarily concerned with listing and loading Cog XML files, but has some methods that are useful for querying other types of files.

Author:
Paul Reavis Copyright 2003-2005 Partner Software, Inc.

Constructor Summary
Config()
           
 
Method Summary
static VFS getBase()
           
static Naming list(java.lang.String path)
          Lists the available names under the given path.
static Naming list(java.lang.String path, java.lang.String extension)
          Lists the available names under the given path.
static Naming pathwiseList(java.lang.String subPath)
          Does a listing for the given subPath under each of the available config paths.
static Naming pathwiseMergeNaming(java.lang.String subPath)
          Combines namings from config files in the order from least to most specific.
static java.lang.Object pathwiseRetrieve(java.lang.String subPath)
          First does a pathwise search, then retrieves the most specific object for the given subpath.
static java.lang.String pathwiseSearch(java.lang.String subPath)
          Finds the most specific instance of subPath from the available config paths.
static java.lang.Object retrieve(java.lang.String path)
          Retrieve a configuration object.
static Cog retrieveCog(java.lang.String path)
           
static Naming retrieveFilesAsNaming(java.lang.String subPath)
          Retrieves a naming by loading all cog xml files in the given path, setting the cog property "name" for each to its file name.
static Naming retrieveNaming(java.lang.String path)
          Retrieve a configuration object as a naming.
static java.lang.Object retrieveOrDefault(java.lang.String path, java.lang.Object defaultObject)
          Retrieve a configuration object.
static java.lang.Object retrievePreferences(java.lang.String path)
           
static Naming retrieveScriptsAsNaming(java.lang.String path, java.util.ArrayList scriptLibDirs)
          Takes a directory full of Groovy scripts and turns them into a Naming, indexed by the file name.
static void setBase(VFS newVFS)
          Sets the VFS base for the Config store.
static void store(java.lang.String path, java.lang.Object data)
          Stores the object at the given path.
static void storeCog(java.lang.String path, Cog data)
           
static void storeNamingAsFiles(java.lang.String path, Naming naming)
          Stores the given naming by splitting up each entry into separate cog XMLs, using the entry's name as the file name.
static void storePreferences(java.lang.String path, java.lang.Object data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config()
Method Detail

list

public static Naming list(java.lang.String path)
                   throws java.io.IOException
Lists the available names under the given path. Builds the results into a Naming; keyed by the name, the value is the path.

Throws:
java.io.IOException

list

public static Naming list(java.lang.String path,
                          java.lang.String extension)
                   throws java.io.IOException
Lists the available names under the given path. Builds the results into a Naming; keyed by the name, the value is the path.

Throws:
java.io.IOException

pathwiseList

public static Naming pathwiseList(java.lang.String subPath)
                           throws java.io.IOException
Does a listing for the given subPath under each of the available config paths. Builds the results into a Naming, indexed by the end file name (no extension), with the values being the full path to the found file. Where the same name occurs in multiple locations, the most specific (e.g. seat rather than site) will be returned.

Throws:
java.io.IOException

pathwiseMergeNaming

public static Naming pathwiseMergeNaming(java.lang.String subPath)
                                  throws java.io.IOException
Combines namings from config files in the order from least to most specific. This allows a more specific config file to override just some entries in a more generic one.

Throws:
java.io.IOException

pathwiseSearch

public static java.lang.String pathwiseSearch(java.lang.String subPath)
                                       throws java.io.IOException
Finds the most specific instance of subPath from the available config paths. Returns the full path if found; returns null if none is found.

Throws:
java.io.IOException

retrieve

public static java.lang.Object retrieve(java.lang.String path)
                                 throws java.io.IOException
Retrieve a configuration object. Automatically converts it from XML cog format. Returns null if none found.

Throws:
java.io.IOException

retrieveNaming

public static Naming retrieveNaming(java.lang.String path)
                             throws java.io.IOException
Retrieve a configuration object as a naming. Really just a convenience wrapper for retrieve.

Throws:
java.io.IOException

retrieveOrDefault

public static java.lang.Object retrieveOrDefault(java.lang.String path,
                                                 java.lang.Object defaultObject)
                                          throws java.io.IOException
Retrieve a configuration object. Automatically converts it from XML cog format. Returns default if none found.

Throws:
java.io.IOException

pathwiseRetrieve

public static java.lang.Object pathwiseRetrieve(java.lang.String subPath)
                                         throws java.io.IOException
First does a pathwise search, then retrieves the most specific object for the given subpath.

Throws:
java.io.IOException

retrieveFilesAsNaming

public static Naming retrieveFilesAsNaming(java.lang.String subPath)
                                    throws java.io.IOException
Retrieves a naming by loading all cog xml files in the given path, setting the cog property "name" for each to its file name. Returns them indexed by the name as well.

Throws:
java.io.IOException

retrieveScriptsAsNaming

public static Naming retrieveScriptsAsNaming(java.lang.String path,
                                             java.util.ArrayList scriptLibDirs)
                                      throws java.io.IOException
Takes a directory full of Groovy scripts and turns them into a Naming, indexed by the file name.

Throws:
java.io.IOException

store

public static void store(java.lang.String path,
                         java.lang.Object data)
                  throws java.io.IOException
Stores the object at the given path. Automatically converts it to XML cog format.

Throws:
java.io.IOException

storeNamingAsFiles

public static void storeNamingAsFiles(java.lang.String path,
                                      Naming naming)
                               throws java.io.IOException
Stores the given naming by splitting up each entry into separate cog XMLs, using the entry's name as the file name.

Throws:
java.io.IOException

setBase

public static void setBase(VFS newVFS)
Sets the VFS base for the Config store.


getBase

public static VFS getBase()

retrieveCog

public static Cog retrieveCog(java.lang.String path)
                       throws java.io.IOException
Throws:
java.io.IOException

storeCog

public static void storeCog(java.lang.String path,
                            Cog data)
                     throws java.io.IOException
Throws:
java.io.IOException

retrievePreferences

public static java.lang.Object retrievePreferences(java.lang.String path)
                                            throws java.io.IOException
Throws:
java.io.IOException

storePreferences

public static void storePreferences(java.lang.String path,
                                    java.lang.Object data)
                             throws java.io.IOException
Throws:
java.io.IOException