Clover coverage report - Maven Clover report
Coverage timestamp: Wed Aug 15 2007 21:58:57 GMT+01:00
file stats: LOC: 86   Methods: 1
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
HtmlAttributeMap.java 100% 100% 100% 100%
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.util;
 13   
 14    import java.util.HashMap;
 15    import java.util.Iterator;
 16    import java.util.Map;
 17    import java.util.Set;
 18   
 19   
 20    /**
 21    * Extends Map providing only a different toString() method which can be used in printing attributes inside an html tag.
 22    * @author Fabrizio Giustina
 23    * @version $Revision: 1081 $ ($Author: fgiust $)
 24    */
 25    public class HtmlAttributeMap extends HashMap
 26    {
 27   
 28    /**
 29    * D1597A17A6.
 30    */
 31    private static final long serialVersionUID = 899149338534L;
 32   
 33    /**
 34    * Attribute value delimiter.
 35    */
 36    private static final char DELIMITER = '"';
 37   
 38    /**
 39    * character between name and value.
 40    */
 41    private static final char EQUALS = '=';
 42   
 43    /**
 44    * space before any attribute.
 45    */
 46    private static final char SPACE = ' ';
 47   
 48    /**
 49    * toString method: returns attributes in the format: attributename="attributevalue" attr2="attrValue2" ...
 50    * @return String representation of the HtmlAttributeMap
 51    */
 52  2524 public String toString()
 53    {
 54    // fast exit when no attribute are present
 55  2524 if (size() == 0)
 56    {
 57  1435 return TagConstants.EMPTY_STRING;
 58    }
 59   
 60    // buffer extimated in number of attributes * 30
 61  1089 StringBuffer buffer = new StringBuffer(size() * 30);
 62   
 63    // get the entrySet
 64  1089 Set entrySet = entrySet();
 65   
 66  1089 Iterator iterator = entrySet.iterator();
 67   
 68    // iterates on attributes
 69  1089 while (iterator.hasNext())
 70    {
 71  1131 Map.Entry entry = (Map.Entry) iterator.next();
 72   
 73    // append a new atribute
 74  1131 buffer
 75    .append(SPACE)
 76    .append(entry.getKey())
 77    .append(EQUALS)
 78    .append(DELIMITER)
 79    .append(entry.getValue())
 80    .append(DELIMITER);
 81    }
 82   
 83    // return
 84  1089 return buffer.toString();
 85    }
 86    }