com.commsen.apropos.core
Class PropertiesManager

java.lang.Object
  extended by com.commsen.apropos.core.PropertiesManager

public class PropertiesManager
extends java.lang.Object

The class provides static synchronized methods for common operations on Property and PropertyPackage like add, delete, update, etc. It is also responsible for persisting data after any change and loading data form storage on startup.

Author:
Milen Dyankov

Method Summary
static PropertyPackage addProperty(java.lang.String packageName, Property property)
          Adds new Property in PropertyPackage called packageName by calling PropertyPackage.addProperty(Property).
static void addPropertyPackage(PropertyPackage propertyPackage)
          Adds new PropertyPackage.
static PropertyPackage deleteProperty(java.lang.String packageName, java.lang.String propertyName)
          Deletes Property called propertyName from PropertyPackage called packageName.
static void deletePropertyPackage(java.lang.String packageName)
          Deletes the PropertyPackage specified by packageName and all it's children.
static PropertyPackage getPropertyPackage(java.lang.String name)
          Returns a clone of PropertyPackage called name.
static java.util.List<java.lang.String> getPropertyPackagesNames()
          Returns unmodifiable (read only) list of all package names
static java.util.List<PropertyPackage> getRootPropertyPackages()
          Returns unmodifiable (read only) list of all top level packages
static PropertyPackage importProperties(java.lang.String packageName, java.util.Properties externalProperties, boolean overwrite)
          Imports external properties into PropertyPackage called packageName .
static PropertyPackage updateProperty(java.lang.String packageName, Property property)
          Updates Property in PropertyPackage called packageName.
static PropertyPackage updateProperty(java.lang.String packageName, java.lang.String oldPropertyName, Property property)
          Updates existing Property called oldPropertyName in PropertyPackage called packageName with values from property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addPropertyPackage

public static void addPropertyPackage(PropertyPackage propertyPackage)
                               throws PropertiesException
Adds new PropertyPackage. NOTE: The object passed is cloned internally.

Parameters:
propertyPackage - the PropertyPackage to be added. Can not be null.
Throws:
PropertiesException - if package with that name already exists or if circular parent/child relation is detected.
java.lang.IllegalArgumentException - if propertyPackage is null

getRootPropertyPackages

public static java.util.List<PropertyPackage> getRootPropertyPackages()
Returns unmodifiable (read only) list of all top level packages

Returns:
unmodifiable (read only) list of all top level packages

getPropertyPackagesNames

public static java.util.List<java.lang.String> getPropertyPackagesNames()
Returns unmodifiable (read only) list of all package names

Returns:
unmodifiable (read only) list of all package names

getPropertyPackage

public static PropertyPackage getPropertyPackage(java.lang.String name)
Returns a clone of PropertyPackage called name. If no such PropertyPackage exists it will return null.

Returns:
a PropertyPackage called name or null.

deletePropertyPackage

public static void deletePropertyPackage(java.lang.String packageName)
                                  throws PropertiesException
Deletes the PropertyPackage specified by packageName and all it's children.

Parameters:
packageName -
Throws:
PropertiesException

addProperty

public static PropertyPackage addProperty(java.lang.String packageName,
                                          Property property)
                                   throws PropertiesException
Adds new Property in PropertyPackage called packageName by calling PropertyPackage.addProperty(Property).

Parameters:
packageName - the name of the package. Can not be null or empty.
property - the Property to add. Can not be null
Returns:
a new clone of the PropertyPackage made after the property is added
Throws:
PropertiesException - if no package called packageName found or if such Property already exists in this package
java.lang.IllegalArgumentException - if any of the arguments is null

updateProperty

public static PropertyPackage updateProperty(java.lang.String packageName,
                                             Property property)
                                      throws PropertiesException
Updates Property in PropertyPackage called packageName. The actual update is handled by PropertyPackage.updateProperty(Property)

Parameters:
packageName - the name of the package. Can not be null or empty.
property - the Property to be updated. Can not be null
Returns:
a new clone of the PropertyPackage made after the property is updated
Throws:
PropertiesException - if no package called packageName found or if no such Property exists in this package
java.lang.IllegalArgumentException - if any of the arguments is null

updateProperty

public static PropertyPackage updateProperty(java.lang.String packageName,
                                             java.lang.String oldPropertyName,
                                             Property property)
                                      throws PropertiesException
Updates existing Property called oldPropertyName in PropertyPackage called packageName with values from property. The actual update is handled by PropertyPackage.updateProperty(Property).

Parameters:
packageName - the name of the package. Can not be null or empty.
oldPropertyName - the name of the property to be updated
property - the Property object to get the values from. Can not be null
Returns:
a new clone of the PropertyPackage made after the property is updated
Throws:
PropertiesException - if no package called packageName found or if no such Property exists in this package
java.lang.IllegalArgumentException - if any of the arguments is null

importProperties

public static PropertyPackage importProperties(java.lang.String packageName,
                                               java.util.Properties externalProperties,
                                               boolean overwrite)
                                        throws PropertiesException
Imports external properties into PropertyPackage called packageName . The actual import is handled by PropertyPackage.importProperties(Properties, boolean).

Parameters:
packageName - the name of the package. Can not be null or empty.
externalProperties - the properties to import. This can not be null
overwrite - boolean flag indicates whether to override existing properties
Returns:
a new clone of the PropertyPackage made after the properties are imported
Throws:
PropertiesException - if there is no package called packageName
java.lang.IllegalArgumentException - if any of the arguments is null

deleteProperty

public static PropertyPackage deleteProperty(java.lang.String packageName,
                                             java.lang.String propertyName)
                                      throws PropertiesException
Deletes Property called propertyName from PropertyPackage called packageName. The actual deletion is handled by PropertyPackage.removeProperty(String).

Parameters:
packageName - the name of the package. Can not be null or empty.
propertyName - the name of the property to be updated
Returns:
a new clone of the PropertyPackage made after the property is deleted
Throws:
PropertiesException - if there is no package called packageName or no property called propertyName
java.lang.IllegalArgumentException - if any of the arguments is null


Copyright © 2008 Commsen International. All Rights Reserved.