FileDocCategorySizeDatePackage
ReportCfg.javaAPI DocAndroid 1.5 API13133Wed May 06 22:41:16 BST 2009com.vladium.emma.report

ReportCfg

public class ReportCfg extends Object implements IReportProperties
ReportCfg is a container for report type {@link ReportCfg.Element}s that are in turn containers for all properties that could be set on a <report> report type configurator (<txt>, <html>, etc). The elements provide the ability for report properties to be set either via the generic <property> nested elements or dedicated attributes. Potential conflicts between the same conceptual property being set via an attribute and a nested element are resolved by making dedicated attributes higher priority.

Note that ReportCfg does not handle any non-report related properties. This can be done via {@link com.vladium.emma.ant.GenericCfg}. It is also the parent's responsibility to merge any inherited report properties with ReportCfg settings.

author
Vlad Roubtsov, (C) 2003

Fields Summary
private final org.apache.tools.ant.Project
m_project
private final org.apache.tools.ant.Task
m_task
private final List
m_reportTypes
private final List
m_cfgList
private final com.vladium.util.IProperties
m_settings
private org.apache.tools.ant.types.Path
m_srcpath
private transient org.apache.tools.ant.BuildException
m_settingsFailure
private transient boolean
m_processed
Constructors Summary
public ReportCfg(org.apache.tools.ant.Project project, org.apache.tools.ant.Task task)

        
     // end of nested class
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    
           
    
        m_project = project;
        m_task = task;
        
        m_reportTypes = new ArrayList (4);
        m_cfgList = new ArrayList (4);
        m_settings = EMMAProperties.wrap (new Properties ());
    
Methods Summary
protected com.vladium.emma.report.ReportCfg$ElementaddCfgElement(java.lang.String type, com.vladium.emma.report.ReportCfg$Element cfg)

        if (m_reportTypes.contains (type))
        {
            setFailure ((BuildException) SuppressableTask.newBuildException (m_task.getTaskName ()
                + ": duplicate configuration for report type [" + type + "]" ,
                m_task.getLocation ()).fillInStackTrace ());
        }
        else
        {
            m_reportTypes.add (type);
            m_cfgList.add (cfg);
        }
        
        return cfg;
    
public com.vladium.emma.report.ReportCfg$Element_HTMLcreateHtml()

        return (Element_HTML) addCfgElement (Element_HTML.TYPE,
                                                      new Element_HTML (m_task, m_settings));
    
public org.apache.tools.ant.types.PathcreateSourcepath()

        if (m_srcpath == null)
            m_srcpath = new Path (m_project);
        
        return m_srcpath.createPath ();
    
public com.vladium.emma.report.ReportCfg$Element_TXTcreateTxt()

        return (Element_TXT) addCfgElement (Element_TXT.TYPE,
                                                     new Element_TXT (m_task, m_settings));
    
public com.vladium.emma.report.ReportCfg$Element_XMLcreateXml()

        return (Element_XML) addCfgElement (Element_XML.TYPE,
                                                     new Element_XML (m_task, m_settings));
    
private org.apache.tools.ant.BuildExceptiongetFailure()

        return m_settingsFailure;
    
public com.vladium.util.IPropertiesgetReportSettings()

        final BuildException failure = getFailure ();
        
        if (failure != null)
            throw failure;
        else
        {
            if (! m_processed)
            {
                // collect all nested elements' generic settins into m_settings:
                
                for (Iterator i = m_cfgList.iterator (); i.hasNext (); )
                {
                    final Element cfg = (Element) i.next ();
                    cfg.processGenericSettings ();
                }
                
                m_processed = true;
            }
            
            return m_settings; // no clone
        }
    
public java.lang.String[]getReportTypes()

        final BuildException failure = getFailure ();
        
        if (failure != null)
            throw failure;
        else
        {
            if (m_reportTypes.isEmpty ())
                return IConstants.EMPTY_STRING_ARRAY;
            else
            {
                final String [] result = new String [m_reportTypes.size ()];
                m_reportTypes.toArray (result);
                
                return result;
            }
        }
    
public org.apache.tools.ant.types.PathgetSourcepath()

        return m_srcpath;
    
public voidsetColumns(java.lang.String columns)

        m_settings.setProperty (PREFIX.concat (COLUMNS), columns);
    
public voidsetDepth(com.vladium.emma.report.IReportEnums.DepthAttribute depth)

        m_settings.setProperty (PREFIX.concat (DEPTH), depth.getValue ());
    
public voidsetEncoding(java.lang.String encoding)

        m_settings.setProperty (PREFIX.concat (OUT_ENCODING), encoding);
    
private voidsetFailure(org.apache.tools.ant.BuildException failure)

        if (m_settingsFailure == null) m_settingsFailure = failure; // record the first one only
    
public voidsetMetrics(java.lang.String metrics)

        m_settings.setProperty (PREFIX.concat (METRICS), metrics);
    
public voidsetOutfile(java.lang.String fileName)

        m_settings.setProperty (PREFIX.concat (OUT_FILE), fileName);
    
public voidsetSort(java.lang.String sort)

        m_settings.setProperty (PREFIX.concat (SORT), sort);
    
public voidsetSourcepath(org.apache.tools.ant.types.Path path)

        if (m_srcpath == null)
            m_srcpath = path;
        else
            m_srcpath.append (path);
    
public voidsetSourcepathRef(org.apache.tools.ant.types.Reference ref)

        createSourcepath ().setRefid (ref);
    
public voidsetUnits(com.vladium.emma.report.IReportEnums.UnitsTypeAttribute units)

        m_settings.setProperty (PREFIX.concat (UNITS_TYPE), units.getValue ());