org.objectweb.petals.tools.webadmin.util
Class ServerPropertiesManager

java.lang.Object
  extended by org.objectweb.petals.tools.webadmin.util.ServerPropertiesManager

public class ServerPropertiesManager
extends java.lang.Object

Manage a properties file.

Author:
msauvage chamerling - eBMWebSourcing

Constructor Summary
ServerPropertiesManager()
          Creates a new instance of ServerPropertiesManager
ServerPropertiesManager(java.lang.String rootPath)
          Creates a new instance of ServerPropertiesManager with a path for the file associated
 
Method Summary
 void clear()
           
 java.lang.String getAttributeValue(java.lang.String key)
          Returns the value corresponding to the key in the properties as a String.
 java.util.Properties getProperties()
          Returns all the properties
 java.lang.String getPropertiesFileName()
          Gets the file name where properties are stored
 java.lang.String getRootPath()
           
 boolean load()
          Load properties from file.
 void save()
          Save the actual properties into a file without comment
 void save(java.lang.String comments)
          Save the actual properties into a file with a comment
 void setAttribute(java.lang.String key, java.lang.String value)
          Sets a new key/value property.
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Copies all of the mappings from the specified Map to the properties attribute.
 void setProperties(java.util.Properties properties)
           
 void setRootPath(java.lang.String rootPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPropertiesManager

public ServerPropertiesManager()
Creates a new instance of ServerPropertiesManager


ServerPropertiesManager

public ServerPropertiesManager(java.lang.String rootPath)
Creates a new instance of ServerPropertiesManager with a path for the file associated

Method Detail

getPropertiesFileName

public java.lang.String getPropertiesFileName()
Gets the file name where properties are stored

Returns:
a String representation of the name

clear

public void clear()

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String key)
Returns the value corresponding to the key in the properties as a String.

Parameters:
key - the key searched
Returns:
a String representation of the value corresponding to the key, null if key doesn't exists

getProperties

public java.util.Properties getProperties()
Returns all the properties

Returns:
the properties as a Properties object

getRootPath

public java.lang.String getRootPath()

load

public boolean load()
             throws java.io.IOException
Load properties from file.

Returns:
boolean true if file is correctly loaded, false if file is not found
Throws:
java.io.IOException

save

public void save()
          throws java.io.IOException
Save the actual properties into a file without comment

Throws:
java.io.IOException

save

public void save(java.lang.String comments)
          throws java.io.IOException
Save the actual properties into a file with a comment

Parameters:
file - the complete path to the file to write
Throws:
java.io.IOException

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
Sets a new key/value property. If property already exist, value is updated

Parameters:
key - the key of the property
value - the value corresponding

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Copies all of the mappings from the specified Map to the properties attribute.

Parameters:
properties - a Map of the pairs to be stored

setProperties

public void setProperties(java.util.Properties properties)

setRootPath

public final void setRootPath(java.lang.String rootPath)
Parameters:
rootPath -


Copyright © 2005-2007 ObjectWeb Consortium. All Rights Reserved.