FileDocCategorySizeDatePackage
EMMAProperties.javaAPI DocAndroid 1.5 API8170Wed May 06 22:41:16 BST 2009com.vladium.emma

EMMAProperties

public abstract class EMMAProperties extends Object
A reflection of "${IAppConstants.APP_PROPERTY_RES_NAME}.properties" resource as viewed by a given classloader.
author
Vlad Roubtsov, (C) 2003

Fields Summary
public static final String
GENERIC_PROPERTY_OVERRIDE_PREFIX
public static final String
DEFAULT_META_DATA_OUT_FILE
public static final Boolean
DEFAULT_META_DATA_OUT_MERGE
public static final String
PREFIX_META_DATA
public static final String
PROPERTY_META_DATA_OUT_FILE
public static final String
PROPERTY_META_DATA_OUT_MERGE
public static final String
DEFAULT_COVERAGE_DATA_OUT_FILE
public static final Boolean
DEFAULT_COVERAGE_DATA_OUT_MERGE
public static final String
PREFIX_COVERAGE_DATA
public static final String
PROPERTY_COVERAGE_DATA_OUT_FILE
public static final String
PROPERTY_COVERAGE_DATA_OUT_MERGE
public static final String
DEFAULT_SESSION_DATA_OUT_FILE
public static final Boolean
DEFAULT_SESSION_DATA_OUT_MERGE
public static final String
PREFIX_SESSION_DATA
public static final String
PROPERTY_SESSION_DATA_OUT_FILE
public static final String
PROPERTY_SESSION_DATA_OUT_MERGE
public static final String
PROPERTY_TEMP_FILE_EXT
public static final Map
SYSTEM_PROPERTY_REDIRECTS
private static long
s_timestamp
private static final Map
s_properties
Constructors Summary
private EMMAProperties()

Methods Summary
public static synchronized com.vladium.util.IPropertiesgetAppProperties()
Retrieves application properties as classloader resource with a given name. [as seen from ClassLoaderResolver.getClassLoader ()]. The result is cached using this loader as a weak key.

return
properties [can be null]

        final ClassLoader loader = ClassLoaderResolver.getClassLoader ();
        
        return getAppProperties (loader);
    
public static synchronized com.vladium.util.IPropertiesgetAppProperties(java.lang.ClassLoader loader)

        IProperties properties = (IProperties) s_properties.get (loader);

        if (properties != null)
            return properties;
        else
        {
            final String appName = IAppConstants.APP_NAME_LC;
            
            // note: this does not use Property.getAppProperties() by design,
            // because that mechanism is not property alias-capable
            
            final IProperties systemRedirects = wrap (Property.getSystemPropertyRedirects (EMMAProperties.SYSTEM_PROPERTY_REDIRECTS));
            final IProperties appDefaults = wrap (Property.getProperties (appName + "_default.properties", loader));
            final IProperties systemFile;
            {
                final String fileName = Property.getSystemProperty (appName + ".properties");
                final File file = fileName != null
                    ? new File (fileName)
                    : null;

                systemFile = wrap (Property.getLazyPropertiesFromFile (file));
            }
            final IProperties system = wrap (Property.getSystemProperties (appName));
            final IProperties userOverrides = wrap (Property.getProperties (appName + ".properties", loader));
            
            // "vertical" inheritance order:
            //      (1) user overrides ("emma.properties" classloader resource)
            //      (2) system properties (java.lang.System.getProperties(),
            //                             filtered by the app prefix)
            //      (3) system file properties ("emma.properties" system property,
            //                                  interpreted as a property file)
            //      (4) app defaults ("emma_default.properties" classloader resource)
            //      (5) system property redirects (report.out.encoding->file.encoding,
            //                                     report.out.dir->user.dir, etc)
        
            properties = IProperties.Factory.combine (userOverrides,
                         IProperties.Factory.combine (system,
                         IProperties.Factory.combine (systemFile,
                         IProperties.Factory.combine (appDefaults,
                                                      systemRedirects))));

            s_properties.put (loader, properties);
            
            return properties;
        }
    
public static synchronized longgetTimeStamp()
Global method used to create an appearance that all app work has been done at the same point in time (useful for setting archive and report timestamps etc).

return
the result of System.currentTimeMillis (), evaluated on the first call only

 // set in <clinit>
    
    
                                                  
         
    
        long result = s_timestamp;
        if (result == 0)
        {
            s_timestamp = result = System.currentTimeMillis ();
        }

        return result; 
    
public static java.lang.StringmakeAppVersion(int major, int minor, int build)

        final StringBuffer buf = new StringBuffer ();
        
        buf.append (major);
        buf.append ('.");
        buf.append (minor);
        buf.append ('.");
        buf.append (build);
        
        return buf.toString ();
    
public static com.vladium.util.IPropertieswrap(java.util.Properties properties)
Wraps a Properties into a IProperties with the app's standard property mapping in place.

param
properties [null results in null result]

        if (properties == null) return null;
        
        return IProperties.Factory.wrap (properties, ReportProperties.REPORT_PROPERTY_MAPPER);