Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 122   Methods: 5
NCLOC: 73   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ListDiff.java 14.3% 36.2% 60% 33.3%
coverage coverage
 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   
 33    package com.jeantessier.dependencyfinder.cli;
 34   
 35    import java.io.*;
 36    import java.util.*;
 37   
 38    import com.jeantessier.diff.*;
 39    import com.jeantessier.commandline.*;
 40   
 41    public class ListDiff extends Command {
 42  1 protected void showSpecificUsage(PrintStream out) {
 43  1 out.println();
 44  1 out.println("Defaults is text output to the console.");
 45  1 out.println();
 46    }
 47   
 48  8 protected void populateCommandLineSwitches() {
 49  8 super.populateCommandLineSwitches();
 50  8 populateCommandLineSwitchesForXMLOutput(ListDiffPrinter.DEFAULT_ENCODING, ListDiffPrinter.DEFAULT_DTD_PREFIX, ListDiffPrinter.DEFAULT_INDENT_TEXT);
 51   
 52  8 getCommandLine().addSingleValueSwitch("name");
 53  8 getCommandLine().addSingleValueSwitch("old-label");
 54  8 getCommandLine().addSingleValueSwitch("old", true);
 55  8 getCommandLine().addSingleValueSwitch("new-label");
 56  8 getCommandLine().addSingleValueSwitch("new", true);
 57  8 getCommandLine().addToggleSwitch("compress");
 58    }
 59   
 60  7 protected Collection<CommandLineException> parseCommandLine(String[] args) {
 61  7 Collection<CommandLineException> exceptions = super.parseCommandLine(args);
 62   
 63  7 if (!getCommandLine().isPresent("old-label")) {
 64  7 getCommandLine().getSwitch("old-label").setValue(getCommandLine().getSingleSwitch("old"));
 65    }
 66   
 67  7 if (!getCommandLine().isPresent("new-label")) {
 68  7 getCommandLine().getSwitch("new-label").setValue(getCommandLine().getSingleSwitch("new"));
 69    }
 70   
 71  7 return exceptions;
 72    }
 73   
 74  0 protected void doProcessing() throws Exception {
 75  0 String line;
 76   
 77  0 getVerboseListener().print("Loading old list ...");
 78  0 Collection<String> oldAPI = new TreeSet<String>();
 79  0 BufferedReader oldIn = new BufferedReader(new FileReader(getCommandLine().getSingleSwitch("old")));
 80  0 while((line = oldIn.readLine()) != null) {
 81  0 oldAPI.add(line);
 82    }
 83  0 oldIn.close();
 84   
 85  0 getVerboseListener().print("Loading new list ...");
 86  0 Collection<String> newAPI = new TreeSet<String>();
 87  0 BufferedReader newIn = new BufferedReader(new FileReader(getCommandLine().getSingleSwitch("new")));
 88  0 while((line = newIn.readLine()) != null) {
 89  0 newAPI.add(line);
 90    }
 91  0 newIn.close();
 92   
 93  0 ListDiffPrinter printer = new ListDiffPrinter(getCommandLine().getToggleSwitch("compress"), getCommandLine().getSingleSwitch("encoding"), getCommandLine().getSingleSwitch("dtd-prefix"));
 94  0 printer.setName(getCommandLine().getSingleSwitch("name"));
 95  0 printer.setOldVersion(getCommandLine().getSingleSwitch("old-label"));
 96  0 printer.setNewVersion(getCommandLine().getSingleSwitch("new-label"));
 97  0 if (getCommandLine().isPresent("indent-text")) {
 98  0 printer.setIndentText(getCommandLine().getSingleSwitch("indent-text"));
 99    }
 100   
 101  0 getVerboseListener().print("Computing removed elements ...");
 102  0 for (String name : oldAPI) {
 103  0 if (!newAPI.contains(name)) {
 104  0 printer.remove(name);
 105    }
 106    }
 107   
 108  0 getVerboseListener().print("Computing added elements ...");
 109  0 for (String name : newAPI) {
 110  0 if (!oldAPI.contains(name)) {
 111  0 printer.add(name);
 112    }
 113    }
 114   
 115  0 getVerboseListener().print("Printing results ...");
 116  0 getOut().print(printer);
 117    }
 118   
 119  0 public static void main(String[] args) throws Exception {
 120  0 new ListDiff().run(args);
 121    }
 122    }