EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.dependencyfinder.cli]

COVERAGE SUMMARY FOR SOURCE FILE [DependencyGraphCommand.java]

nameclass, %method, %block, %line, %
DependencyGraphCommand.java100% (1/1)43%  (3/7)13%  (19/141)27%  (8/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DependencyGraphCommand100% (1/1)43%  (3/7)13%  (19/141)27%  (8/30)
loadGraph (): NodeFactory 0%   (0/1)0%   (0/18)0%   (0/5)
loadGraphFromFile (NodeFactory, String): void 0%   (0/1)0%   (0/42)0%   (0/6)
loadGraphFromFiles (NodeFactory): void 0%   (0/1)0%   (0/36)0%   (0/5)
loadGraphFromSystemIn (NodeFactory): void 0%   (0/1)0%   (0/26)0%   (0/6)
DependencyGraphCommand (): void 100% (1/1)100% (3/3)100% (1/1)
populateCommandLineSwitches (): void 100% (1/1)100% (8/8)100% (3/3)
showSpecificUsage (PrintStream): void 100% (1/1)100% (8/8)100% (4/4)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.dependencyfinder.cli;
34 
35import java.io.*;
36import javax.xml.parsers.*;
37 
38import org.xml.sax.*;
39 
40import com.jeantessier.dependency.*;
41 
42/**
43 * TODO Class comments
44 */
45public abstract class DependencyGraphCommand extends Command {
46    protected void populateCommandLineSwitches() {
47        super.populateCommandLineSwitches();
48 
49        getCommandLine().addToggleSwitch("validate");
50    }
51 
52    protected void showSpecificUsage(PrintStream out) {
53        out.println();
54        out.println("Default is text output to the console.");
55        out.println();
56    }
57 
58    protected NodeFactory loadGraph() throws IOException, SAXException, ParserConfigurationException {
59        NodeFactory result = new NodeFactory();
60 
61        if (getCommandLine().getParameters().isEmpty()) {
62            loadGraphFromSystemIn(result);
63        } else {
64            loadGraphFromFiles(result);
65        }
66 
67        return result;
68    }
69 
70    private void loadGraphFromSystemIn(NodeFactory factory) throws IOException, SAXException, ParserConfigurationException {
71        getVerboseListener().print("Reading from standard input");
72 
73        NodeLoader loader = new NodeLoader(factory, getCommandLine().getToggleSwitch("validate"));
74        loader.addDependencyListener(getVerboseListener());
75        loader.load(System.in);
76 
77        getVerboseListener().print("Read from standard input.");
78    }
79 
80    private void loadGraphFromFiles(NodeFactory factory) throws IOException, SAXException, ParserConfigurationException {
81        for (String filename : getCommandLine().getParameters()) {
82            if (filename.endsWith(".xml")) {
83                loadGraphFromFile(factory, filename);
84            } else {
85                getVerboseListener().print("Skipping \"" + filename + "\".");
86            }
87        }
88    }
89 
90    private void loadGraphFromFile(NodeFactory factory, String filename) throws IOException, SAXException, ParserConfigurationException {
91        getVerboseListener().print("Reading " + filename);
92 
93        NodeLoader loader = new NodeLoader(factory, getCommandLine().getToggleSwitch("validate"));
94        loader.addDependencyListener(getVerboseListener());
95        loader.load(filename);
96 
97        getVerboseListener().print("Read \"" + filename + "\".");
98    }
99}

[all classes][com.jeantessier.dependencyfinder.cli]
EMMA 2.0.5312 (C) Vladimir Roubtsov