com.vladium.util
Class Property

java.lang.Object
  extended by com.vladium.util.Property

public abstract class Property
extends java.lang.Object

Author:
Vlad Roubtsov, (C) 2003

Nested Class Summary
private static class Property.FilePropertyLookup
           
private static class Property.SystemPropertyLookup
           
private static class Property.SystemRedirectsLookup
           
 
Field Summary
private static java.lang.String s_systemFingerprint
           
private static java.util.Properties s_systemProperties
           
private static java.util.Properties s_systemRedirects
           
 
Constructor Summary
Property()
           
 
Method Summary
static java.util.Properties combine(java.util.Properties overrides, java.util.Properties base)
          NOTE: this does not guarantee that the result will be mutatable independently from 'overrides' or 'base', so this method should be used for read-only property only
static java.util.Properties getAppProperties(java.lang.String namespace, java.lang.ClassLoader loader)
          Creates a set of properties for an application with a given namespace.
static java.util.Properties getLazyPropertiesFromFile(java.io.File file)
          Returns a lazy property implementation that will read 'load' as a .properties file on first use.
static java.util.Properties getProperties(java.lang.String name)
          does not throw
static java.util.Properties getProperties(java.lang.String name, java.lang.ClassLoader loader)
          does not throw
static java.util.Properties getPropertiesFromFile(java.io.File file)
          Loads 'file' as a .properties file.
static java.lang.String getSystemFingerprint()
           
static java.util.Properties getSystemProperties(java.lang.String systemPrefix)
           
static java.lang.String getSystemProperty(java.lang.String key)
           
static java.lang.String getSystemProperty(java.lang.String key, java.lang.String def)
           
static java.util.Properties getSystemPropertyRedirects(java.util.Map systemRedirects)
           
static boolean toBoolean(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_systemFingerprint

private static java.lang.String s_systemFingerprint

s_systemProperties

private static java.util.Properties s_systemProperties

s_systemRedirects

private static java.util.Properties s_systemRedirects
Constructor Detail

Property

public Property()
Method Detail

toBoolean

public static boolean toBoolean(java.lang.String value)

combine

public static java.util.Properties combine(java.util.Properties overrides,
                                           java.util.Properties base)
NOTE: this does not guarantee that the result will be mutatable independently from 'overrides' or 'base', so this method should be used for read-only property only

Parameters:
overrides - [null is equivalent to empty]
base - [null is equivalent to empty]
Returns:
[never null, could be empty]

getAppProperties

public static java.util.Properties getAppProperties(java.lang.String namespace,
                                                    java.lang.ClassLoader loader)
Creates a set of properties for an application with a given namespace. This method is not property aliasing-aware.

Parameters:
namespace - application namespace [may not be null]
loader - classloader to use for any classloader resource lookups [null is equivalent to the applicaton classloader]
Returns:
application properties [never null, a new instance is created on each invocation]

getSystemProperties

public static java.util.Properties getSystemProperties(java.lang.String systemPrefix)

getSystemPropertyRedirects

public static java.util.Properties getSystemPropertyRedirects(java.util.Map systemRedirects)

getSystemFingerprint

public static java.lang.String getSystemFingerprint()

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key)

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key,
                                                 java.lang.String def)

getProperties

public static java.util.Properties getProperties(java.lang.String name)
does not throw

Parameters:
name -
Returns:

getProperties

public static java.util.Properties getProperties(java.lang.String name,
                                                 java.lang.ClassLoader loader)
does not throw

Parameters:
name -
loader -
Returns:

getPropertiesFromFile

public static java.util.Properties getPropertiesFromFile(java.io.File file)
                                                  throws java.io.IOException
Loads 'file' as a .properties file.

Parameters:
file - [may not be null]
Returns:
read properties [never null]
Throws:
java.io.IOException - on any file I/O errors

getLazyPropertiesFromFile

public static java.util.Properties getLazyPropertiesFromFile(java.io.File file)
Returns a lazy property implementation that will read 'load' as a .properties file on first use. If there are any file I/O errors when reading the file, they will be thrown as runtime exceptions (also on first use).

Parameters:
file - [can be null, which results in an empty property set returned]
Returns:
[never null]