Clover coverage report - Maven Clover report
Coverage timestamp: Sun Jan 3 2010 19:08:46 CET
file stats: LOC: 122   Methods: 7
NCLOC: 51   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Cell.java 50% 78.6% 100% 77.8%
coverage coverage
 1    /**
 2    * Licensed under the Artistic License; you may not use this file
 3    * except in compliance with the License.
 4    * You may obtain a copy of the License at
 5    *
 6    * http://displaytag.sourceforge.net/license.html
 7    *
 8    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
 9    * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 10    * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 11    */
 12    package org.displaytag.model;
 13   
 14    import org.apache.commons.lang.builder.ToStringBuilder;
 15    import org.apache.commons.lang.builder.ToStringStyle;
 16    import org.displaytag.util.HtmlAttributeMap;
 17   
 18   
 19    /**
 20    * <p>
 21    * Represents a table cell.
 22    * </p>
 23    * <p>
 24    * A cell is used only when the content is placed as content of the column tag and need to be evaluated during
 25    * iteration.
 26    * </p>
 27    * @author Fabrizio Giustina
 28    * @version $Revision: 1094 $ ($Author: rapruitt $)
 29    */
 30    public class Cell implements Comparable, Cloneable
 31    {
 32   
 33    /**
 34    * empty cell object. Use as placeholder for empty cell to avoid useless object creation.
 35    */
 36    public static final Cell EMPTY_CELL = new Cell();
 37   
 38    /**
 39    * content of the cell.
 40    */
 41    private Object staticValue;
 42   
 43    /**
 44    * Per row html attributes (style, class).
 45    */
 46    private HtmlAttributeMap attributes;
 47   
 48    /**
 49    * Creates a new empty cell. This should never be done, use EMPTY_CELL instead.
 50    */
 51  1 private Cell()
 52    {
 53  1 super();
 54    }
 55   
 56    /**
 57    * Creates a cell with a static value.
 58    * @param value Object value of the Cell object
 59    */
 60  222 public Cell(Object value)
 61    {
 62  222 this.staticValue = value;
 63    }
 64   
 65    /**
 66    * get the static value for the cell.
 67    * @return the Object value of this.staticValue.
 68    */
 69  1438 public Object getStaticValue()
 70    {
 71  1438 return this.staticValue;
 72    }
 73   
 74    /**
 75    * Compare the Cell value to another Cell.
 76    * @param obj Object to compare this cell to
 77    * @return int
 78    * @see java.lang.Comparable#compareTo(Object)
 79    */
 80  12 public int compareTo(Object obj)
 81    {
 82   
 83  12 if (this.staticValue == null)
 84    {
 85  0 return -1;
 86    }
 87   
 88  12 if (obj instanceof Cell)
 89    {
 90  12 Object otherStatic = ((Cell) obj).getStaticValue();
 91  12 if (otherStatic == null)
 92    {
 93  0 return 1;
 94    }
 95  12 return ((Comparable) this.staticValue).compareTo(otherStatic);
 96    }
 97   
 98  0 return ((Comparable) this.staticValue).compareTo(obj);
 99   
 100    }
 101   
 102    /**
 103    * Simple toString wich output the static value.
 104    * @return String represantation of the cell
 105    */
 106  1 public String toString()
 107    {
 108  1 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) //
 109    .append("staticValue", this.staticValue).toString(); //$NON-NLS-1$
 110    }
 111   
 112  6 public void setPerRowAttributes(HtmlAttributeMap perRowValues)
 113    {
 114  6 this.attributes = perRowValues;
 115    }
 116   
 117  1059 public HtmlAttributeMap getPerRowAttributes()
 118    {
 119  1059 return this.attributes;
 120    }
 121   
 122    }