ucot.utils
Class PropertiesTools

java.lang.Object
  extended by ucot.utils.PropertiesTools

public class PropertiesTools
extends java.lang.Object

Tools for properties management. Saving and loading from file and such.

Author:
UCOT

Field Summary
private static java.io.File propertiesFile
           
static java.net.URL propertiesURL
           
 
Constructor Summary
PropertiesTools()
           
 
Method Summary
private static java.net.URL getPropertiesURL()
          Method for creating the URL from the properties file.
static java.util.Properties loadProperties(java.util.Enumeration propertiesKeys)
          Method for (re)loading settings from the current properties XML file.
static java.util.Properties loadProperties(java.util.Enumeration propertiesKeys, java.net.URL propertiesURL)
          Method for loading settings from the properties XML file.
static java.util.Properties merge(java.util.Properties overriding, java.util.Properties virtual)
          Method for merging two sets of properties in such a way where overriding properties' values will override any values in virtual properties set that have the same key as in overriding set.
static void saveProperties(java.util.Properties properties)
          Method for (re)saving properties to the current properties XML file.
static void saveProperties(java.util.Properties properties, java.net.URL propertiesURL)
          Method for saving current settings to the properties XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertiesFile

private static final java.io.File propertiesFile

propertiesURL

public static final java.net.URL propertiesURL
Constructor Detail

PropertiesTools

public PropertiesTools()
Method Detail

getPropertiesURL

private static java.net.URL getPropertiesURL()
Method for creating the URL from the properties file.

Returns:
URL to the properties file.

merge

public static java.util.Properties merge(java.util.Properties overriding,
                                         java.util.Properties virtual)
Method for merging two sets of properties in such a way where overriding properties' values will override any values in virtual properties set that have the same key as in overriding set.

Parameters:
overriding - Overriding properties set.
virtual - Virtual properties set.
Returns:
Merged properties set.

saveProperties

public static void saveProperties(java.util.Properties properties,
                                  java.net.URL propertiesURL)
                           throws java.io.IOException
Method for saving current settings to the properties XML file. Notice that only the values for keys given in properties will be changed and all other possible keys and values in propertiesFile will remain untouched.

Parameters:
properties - Properties to be saved.
propertiesURL - Target file.
Throws:
java.io.IOException

saveProperties

public static void saveProperties(java.util.Properties properties)
                           throws java.io.IOException
Method for (re)saving properties to the current properties XML file.

Parameters:
properties - Properties to be saved.
Throws:
java.io.IOException

loadProperties

public static java.util.Properties loadProperties(java.util.Enumeration propertiesKeys,
                                                  java.net.URL propertiesURL)
                                           throws java.io.IOException
Method for loading settings from the properties XML file.

Parameters:
propertiesKeys - Properties' keys that are supposed to be loaded. If this is null, then all properties in the properties file are returned.
propertiesURL - Target file.
Returns:
Loaded properties.
Throws:
java.io.IOException

loadProperties

public static java.util.Properties loadProperties(java.util.Enumeration propertiesKeys)
                                           throws java.io.IOException
Method for (re)loading settings from the current properties XML file.

Parameters:
propertiesKeys - Properties' keys that are supposed to be loaded.
Returns:
Loaded properties.
Throws:
java.io.IOException