EMMA Coverage Report (generated Fri Jun 19 09:16:10 CEST 2009)
[all classes][org.ktc.rbutils.rb.generation]

COVERAGE SUMMARY FOR SOURCE FILE [MainGenerator.java]

nameclass, %method, %block, %line, %
MainGenerator.java100% (1/1)67%  (2/3)89%  (59/66)91%  (20/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MainGenerator100% (1/1)67%  (2/3)89%  (59/66)91%  (20/22)
addConsoleLogger (): void 0%   (0/1)0%   (0/7)0%   (0/2)
MainGenerator (File, File): void 100% (1/1)100% (13/13)100% (6/6)
process (): int 100% (1/1)100% (46/46)100% (14/14)

1/*
2 * Copyright  2005-2006 The RbUtils Project
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 *
16 */
17 
18// $Id: MainGenerator.java,v 1.4 2007/07/08 01:14:44 moishi Exp $
19 
20package org.ktc.rbutils.rb.generation;
21 
22import java.io.File;
23import java.io.FileNotFoundException;
24import java.util.Iterator;
25 
26import org.ktc.rbutils.api.audit.AbstractMainProcessor;
27import org.ktc.rbutils.api.file.ValidateFile;
28 
29/**
30 * Generates a set of Java RessourceBundle source files using a set of Properties files.
31 * @see FileGenerator
32 * @since RbUtils 0.8.0
33 * @version $Revision: 1.4 $
34 * @author ktcguru
35 */
36public class MainGenerator extends AbstractMainProcessor {
37    /** Root directory where java resourcebundle file will be generated. */
38    private File genRootdir;
39 
40    /**
41     * Instanciates a new <code>MainGenerator</code>.
42     * <p>
43     * <code>propsRootDir</code> and <code>genRootdir</code> must be directories that exist in
44     * the filesystem.
45     * @param propsRootDir the root dir of the properties files used to resolve package name.
46     * @param genRootdir the target root directory where the java files will be put after package
47     *            name resolution and file generation.
48     * @throws java.io.FileNotFoundException if a parameter is a <code>File</code> that does not
49     *             exist in the filesystem.
50     * @throws org.ktc.rbutils.api.file.NotDirectoryException if a parameter is not a directory in
51     *             the filesystem.
52     */
53    public MainGenerator(final File propsRootDir, final File genRootdir)
54        throws FileNotFoundException
55    {
56        // Validate arguments
57        ValidateFile.isDirectory(propsRootDir);
58        ValidateFile.isDirectory(genRootdir);
59 
60        // Set field
61        this.root = propsRootDir;
62        this.genRootdir = genRootdir;
63    }
64 
65    /**
66     * Generates a Java RessourceBundle source class in the <code>genRootdir</code> directory for
67     * each file found in the <code>propsRootDir</code> directory.
68     * @return the number of errors that occured during generation.
69     */
70    public int process() {
71        // Initialization
72        finalizeInitialization();
73        fireProcessStarted();
74 
75        // Create or clean the generation directory
76        genRootdir.mkdirs();
77        // RFE cleanGenRootDir option
78        // Warning: be careful if the gen dir contains not gernerated code
79        // final boolean cleanGenRootDir = false;
80        // if (cleanGenRootDir) {
81        // FileUtils.cleanDirectory(genRootdir);
82        // }
83 
84        // Generate all found files
85        for (final Iterator iter = filesList.iterator(); iter.hasNext();) {
86            final File propsFile = (File) iter.next();
87            try {
88                final FileGenerator generator = new FileGenerator(root, propsFile, genRootdir);
89                generator.addLoggers(loggers);
90                generator.performGeneration();
91            }
92            catch (final Exception exception) {
93                fireException(exception);
94            }
95        }
96 
97        fireProcessEnded();
98        // Return the number of errors
99        return getErrorsCount();
100    }
101 
102    /**
103     * {@inheritDoc}
104     */
105    public void addConsoleLogger() {
106        addLogger(new ConsoleLogger());
107    }
108 
109}

[all classes][org.ktc.rbutils.rb.generation]
EMMA 2.0.5312 (C) Vladimir Roubtsov