Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 191   Methods: 4
NCLOC: 128   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QuaternaryOpProperty.java 75% 76.4% 75% 76.1%
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.plt.lambda.Lambda4;
 40    import edu.rice.cs.plt.lambda.Lambda;
 41   
 42    /** Class representing quaternary operations that can be inserted as variables in external processes.
 43    * @version $Id: QuaternaryOpProperty.java 5175 2010-01-20 08:46:32Z mgricken $
 44    */
 45    public class QuaternaryOpProperty<N,O,P,Q,R> extends EagerProperty {
 46    /** Operation to perform. */
 47    protected Lambda4<N,O,P,Q,R> _op;
 48    /** Operator 1 name */
 49    protected String _op1Name;
 50    /** Operator 1 default */
 51    protected String _op1Default;
 52    /** Operator 2 name */
 53    protected String _op2Name;
 54    /** Operator 2 default */
 55    protected String _op2Default;
 56    /** Operator 3 name */
 57    protected String _op3Name;
 58    /** Operator 3 default */
 59    protected String _op3Default;
 60    /** Operator 4 name */
 61    protected String _op4Name;
 62    /** Operator 4 default */
 63    protected String _op4Default;
 64    /** Lambda to turn a string into the first operand. */
 65    protected Lambda<String,N> _parse1;
 66    /** Lambda to turn a string into the second operand. */
 67    protected Lambda<String,O> _parse2;
 68    /** Lambda to turn a string into the third operand. */
 69    protected Lambda<String,P> _parse3;
 70    /** Lambda to turn a string into the fourth operand. */
 71    protected Lambda<String,Q> _parse4;
 72    /** Lambda to format the result. */
 73    protected Lambda<R,String> _format;
 74   
 75    /** Create an eager property. */
 76  46 public QuaternaryOpProperty(String name,
 77    String help,
 78    Lambda4<N,O,P,Q,R> op,
 79    String op1Name,
 80    String op1Default,
 81    Lambda<String,N> parse1,
 82    String op2Name,
 83    String op2Default,
 84    Lambda<String,O> parse2,
 85    String op3Name,
 86    String op3Default,
 87    Lambda<String,P> parse3,
 88    String op4Name,
 89    String op4Default,
 90    Lambda<String,Q> parse4,
 91    Lambda<R,String> format) {
 92  46 super(name, help);
 93  46 _op = op;
 94  46 _op1Name = op1Name;
 95  46 _op1Default = op1Default;
 96  46 _parse1 = parse1;
 97  46 _op2Name = op2Name;
 98  46 _op2Default = op2Default;
 99  46 _parse2 = parse2;
 100  46 _op3Name = op3Name;
 101  46 _op3Default = op3Default;
 102  46 _parse3 = parse3;
 103  46 _op4Name = op4Name;
 104  46 _op4Default = op4Default;
 105  46 _parse4 = parse4;
 106  46 _format = format;
 107  46 resetAttributes();
 108    }
 109   
 110    /** Create an eager property. */
 111  0 public QuaternaryOpProperty(String name,
 112    String help,
 113    Lambda4<N,O,P,Q,R> op,
 114    Lambda<String,N> parse1,
 115    Lambda<String,O> parse2,
 116    Lambda<String,P> parse3,
 117    Lambda<String,Q> parse4,
 118    Lambda<R,String> format) {
 119  0 this(name,help,op,"op1",null,parse1,"op2",null,parse2,"op3",null,parse3,"op4",null,parse4,format);
 120    }
 121   
 122    /** Update the property so the value is current.
 123    * @param pm PropertyMaps used for substitution when replacing variables */
 124  51 public void update(PropertyMaps pm) {
 125  51 N op1;
 126  51 if (_attributes.get(_op1Name) == null) {
 127  2 _value = "(" + _name + " Error...)";
 128  2 return;
 129    }
 130    else {
 131  49 try {
 132  49 op1 = _parse1.value(_attributes.get(_op1Name));
 133    }
 134    catch(Exception e) {
 135  0 _value = "(" + _name + " Error...)";
 136  0 return;
 137    }
 138    }
 139  49 O op2;
 140  49 if (_attributes.get(_op2Name) == null) {
 141  1 _value = "(" + _name + " Error...)";
 142  1 return;
 143    }
 144    else {
 145  48 try {
 146  48 op2 = _parse2.value(_attributes.get(_op2Name));
 147    }
 148    catch(Exception e) {
 149  0 _value = "(" + _name + " Error...)";
 150  0 return;
 151    }
 152    }
 153  48 P op3;
 154  48 if (_attributes.get(_op3Name) == null) {
 155  0 _value = "(" + _name + " Error...)";
 156  0 return;
 157    }
 158    else {
 159  48 try {
 160  48 op3 = _parse3.value(_attributes.get(_op3Name));
 161    }
 162    catch(Exception e) {
 163  0 _value = "(" + _name + " Error...)";
 164  0 return;
 165    }
 166    }
 167  48 Q op4;
 168  48 if (_attributes.get(_op4Name) == null) {
 169  0 _value = "(" + _name + " Error...)";
 170  0 return;
 171    }
 172    else {
 173  48 try {
 174  48 op4 = _parse4.value(_attributes.get(_op4Name));
 175    }
 176    catch(Exception ee) {
 177  0 _value = "(" + _name + " Error...)";
 178  0 return;
 179    }
 180    }
 181  48 _value = _format.value(_op.value(op1,op2,op3,op4));
 182    }
 183   
 184  96 public void resetAttributes() {
 185  96 _attributes.clear();
 186  96 _attributes.put(_op1Name, _op1Default);
 187  96 _attributes.put(_op2Name, _op2Default);
 188  96 _attributes.put(_op3Name, _op3Default);
 189  96 _attributes.put(_op4Name, _op4Default);
 190    }
 191    }