Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 124   Methods: 5
NCLOC: 67   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FileListProperty.java 35.7% 80% 80% 69.5%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.config;
 38   
 39    import edu.rice.cs.util.FileOps;
 40    import java.util.HashSet;
 41    import java.util.List;
 42    import java.io.File;
 43    import java.io.IOException;
 44    import edu.rice.cs.util.StringOps;
 45   
 46    /** Class representing file lists that are not evaluated until necessary.
 47    * @version $Id: FileListProperty.java 5175 2010-01-20 08:46:32Z mgricken $
 48    */
 49    public abstract class FileListProperty extends DrJavaProperty {
 50    /** Separating string. */
 51    protected String _sep;
 52    /** Relative directory. */
 53    protected String _dir;
 54    /** Create an lazy file list property. */
 55  312 public FileListProperty(String name, String sep, String dir, String help) {
 56  312 super(name, help);
 57  312 _sep = sep;
 58  312 _dir = dir;
 59  312 resetAttributes();
 60    }
 61   
 62    /** Mark the value as stale. */
 63  120 public void invalidate() {
 64    // nothing to do, but tell those who are listening
 65  120 invalidateOthers(new HashSet<DrJavaProperty>());
 66    }
 67   
 68    /** Return true if the value is current. */
 69  0 public boolean isCurrent() { return false; }
 70   
 71    /** Abstract factory method specifying the list.PropertyMaps pm
 72    * @param pm PropertyMaps used for substitution when replacing variables */
 73    protected abstract List<File> getList(PropertyMaps pm);
 74   
 75    /** Update the value by concatenating the list of documents.
 76    * @param pm PropertyMaps used for substitution when replacing variables */
 77  32 public void update(PropertyMaps pm) {
 78  32 String quot = "";
 79  32 String q = _attributes.get("squote");
 80  32 if (q != null) {
 81  0 if (q.toLowerCase().equals("true")) { quot = "'"; }
 82    }
 83  32 q = _attributes.get("dquote");
 84  32 if (q != null) {
 85  0 if (q.toLowerCase().equals("true")) { quot = "\"" + quot; }
 86    }
 87  32 List<File> l = getList(pm);
 88  0 if (l.size() == 0) { _value = ""; return; }
 89  32 StringBuilder sb = new StringBuilder();
 90  32 for(File fil: l) {
 91  47 sb.append(StringOps.replaceVariables(_attributes.get("sep"), pm, PropertyMaps.GET_CURRENT));
 92  47 try {
 93  47 String f = fil.toString();
 94  0 if (_attributes.get("rel").equals("/")) f = fil.getAbsolutePath();
 95    else {
 96  47 File rf = new File(StringOps.
 97    unescapeFileName(StringOps.replaceVariables(_attributes.get("rel"),
 98    pm,
 99    PropertyMaps.GET_CURRENT)));
 100  47 f = FileOps.stringMakeRelativeTo(fil, rf);
 101    }
 102  47 String s = edu.rice.cs.util.StringOps.escapeFileName(f);
 103  47 sb.append(quot);
 104  47 sb.append(s);
 105  47 sb.append(quot);
 106    }
 107    catch(IOException e) { /* ignore */ }
 108    catch(SecurityException e) { /* ignore */ }
 109    }
 110  32 _value = sb.toString();
 111  32 if (_value.startsWith(_attributes.get("sep"))) {
 112  32 _value= _value.substring(_attributes.get("sep").length());
 113    }
 114    }
 115   
 116    /** Reset the attributes. */
 117  456 public void resetAttributes() {
 118  456 _attributes.clear();
 119  456 _attributes.put("sep", _sep);
 120  456 _attributes.put("rel", _dir);
 121  456 _attributes.put("squote", null);
 122  456 _attributes.put("dquote", null);
 123    }
 124    }