Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 144   Methods: 13
NCLOC: 59   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DebugWatchData.java 100% 86.7% 76.9% 85.7%
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.model.debug;
 38   
 39    /**
 40    * Class for keeping track of watched fields and variables.
 41    * @version $Id: DebugWatchData.java 5175 2010-01-20 08:46:32Z mgricken $
 42    */
 43    public class DebugWatchData {
 44    /** String to display if the value is not in scope.
 45    */
 46    public static final String NO_VALUE = "<not found>";
 47   
 48    /** String to display if the type is not in scope.
 49    */
 50    public static final String NO_TYPE = "";
 51   
 52    /** String to display if the type is not loaded.
 53    */
 54    public static final String NOT_LOADED = "<not loaded>";
 55   
 56    private String _name;
 57    private String _value;
 58    private String _type;
 59    private boolean _showValue;
 60    private boolean _showType;
 61    private boolean _changed;
 62   
 63    /** Object to keep track of a watched field or variable.
 64    * @param name Name of the field or variable to watch
 65    */
 66  5 public DebugWatchData(String name) {
 67  5 _name = name;
 68  5 _value = "";
 69  5 _type = "";
 70  5 _showValue = false;
 71  5 _showType = false;
 72  5 _changed = false;
 73    }
 74   
 75    /** Returns the name of this field or variable. */
 76  3 public String getName() { return _name; }
 77   
 78    /** Returns the most recently determined value for this field or variable. */
 79  4 public String getValue() { return (_showValue) ? _value : ""; }
 80   
 81    /** Returns the type of this field or variable in the current context.
 82    */
 83  4 public String getType() {
 84  4 return (_showType) ? _type : "";
 85    }
 86   
 87    /** Sets a new name for this field or variable.
 88    * @param name Name of the field or variable
 89    */
 90  0 public void setName(String name) {
 91  0 _name = name;
 92    }
 93   
 94    /** Sets the most recently determined value for this field or variable.
 95    * @param value Value of the field or variable
 96    */
 97  3 public void setValue(Object value) {
 98  3 _showValue = true;
 99  3 String valString = String.valueOf(value);
 100  2 if (!valString.equals(_value)) _changed = true;
 101  1 else _changed = false;
 102  3 _value = valString;
 103    }
 104   
 105    /** Hides the value for this watch (when no thread is suspended). */
 106  1 public void hideValueAndType() {
 107  1 _showValue = false;
 108  1 _showType = false;
 109  1 _changed = false;
 110    }
 111   
 112    /** Called to indicate that this watch has no value in the current scope. */
 113  1 public void setNoValue() {
 114  1 _showValue = true;
 115  1 _value = NO_VALUE;
 116  1 _changed = false;
 117    }
 118   
 119    /** Sets the most recently determined type of this field or variable.
 120    * @param type Type of the field or variable
 121    */
 122  1 public void setType(String type) {
 123  1 _showType = true;
 124  1 _type = type;
 125    }
 126   
 127    /** Called to indicate that this watch has no type in the current scope. */
 128  1 public void setNoType() {
 129  1 _showType = true;
 130  1 _type = NO_TYPE;
 131    }
 132   
 133    /** Called to indicate that this watch's type has not been loaded. */
 134  0 public void setTypeNotLoaded() {
 135  0 _showType = true;
 136  0 _type = NOT_LOADED;
 137    }
 138   
 139    /** Returns whether this value has changed since the last call to setValue. */
 140  6 public boolean isChanged() { return _changed; }
 141   
 142    /** Returns a legible representation of the type, name, and value. */
 143  0 public String toString() { return _type + " " + _name + ": " + _value; }
 144    }