Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 121   Methods: 4
NCLOC: 69   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ConfigProperty.java 50% 54.8% 100% 56.2%
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.drjava.DrJava;
 40   
 41    import java.util.Vector;
 42   
 43    /** Class representing values from the DrJava configuration file that can be inserted as variables in external processes.
 44    * @version $Id: ConfigProperty.java 5175 2010-01-20 08:46:32Z mgricken $
 45    */
 46    public class ConfigProperty extends EagerProperty {
 47    /** True if this is a list of values. This allows the sep="..." attribute. */
 48    protected boolean _isList = false;
 49   
 50    /** Create a configuration property. */
 51  2684 public ConfigProperty(String name) {
 52  2684 super(name, "Help not available.");
 53  2684 resetAttributes();
 54    }
 55   
 56    /** Update the property so the value is current.
 57    * @param pm PropertyMaps used for substitution when replacing variables */
 58  38 public void update(PropertyMaps pm) {
 59  38 OptionMap om = DrJava.getConfig().getOptionMap();
 60  38 for (OptionParser<?> op : om.keys()) {
 61  304 String key = op.getName();
 62  304 String value = om.getString(op);
 63  304 if (_name.equals("config." + key)) {
 64  38 if (op instanceof VectorOption<?>) {
 65  0 @SuppressWarnings("unchecked")
 66    Vector<?> vec = ((VectorOption)op).parse(value);
 67  0 StringBuilder sb = new StringBuilder();
 68  0 for(Object o: vec) {
 69  0 sb.append(_attributes.get("sep"));
 70  0 sb.append(o.toString());
 71    }
 72  0 _value = sb.toString();
 73  0 if (_value.startsWith(_attributes.get("sep"))) {
 74  0 _value= _value.substring(_attributes.get("sep").length());
 75    }
 76    }
 77  38 else if (_name.equals("config.debug.step.exclude")) {
 78  0 java.util.StringTokenizer tok = new java.util.StringTokenizer(value);
 79  0 StringBuilder sb = new StringBuilder();
 80  0 while(tok.hasMoreTokens()) {
 81  0 sb.append(_attributes.get("sep"));
 82  0 sb.append(tok.nextToken());
 83    }
 84  0 _value = sb.toString();
 85  0 if (_value.startsWith(_attributes.get("sep"))) {
 86  0 _value= _value.substring(_attributes.get("sep").length());
 87    }
 88    }
 89    else {
 90  38 _value = value;
 91    }
 92  38 return;
 93    }
 94    }
 95  0 _value = "--unknown--";
 96    }
 97   
 98    /** Reset attributes to their defaults. */
 99  5368 public void resetAttributes() {
 100  5368 _attributes.clear();
 101  5368 OptionMap om = DrJava.getConfig().getOptionMap();
 102  5368 for (OptionParser<?> op : om.keys()) {
 103  903096 String key = op.getName();
 104  903096 if (_name.equals("config." + key)) {
 105  5368 if (op instanceof VectorOption<?>) {
 106  2304 _isList = true;
 107  2304 _attributes.put("sep", java.io.File.pathSeparator);
 108    }
 109  3064 else if (_name.equals("config.debug.step.exclude")) {
 110  0 _isList = true;
 111  0 _attributes.put("sep", ",");
 112    }
 113  3064 else _isList = false;
 114  5368 return;
 115    }
 116    }
 117    }
 118   
 119    /** Return the value. */
 120  6 public String toString() { return _value; }
 121    }