Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 120   Methods: 7
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
OpenToken.java 100% 73.3% 85.7% 79.2%
coverage coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.parse;
 16   
 17    import java.util.HashMap;
 18    import java.util.Map;
 19   
 20    import org.apache.hivemind.Location;
 21    import org.apache.hivemind.util.ToStringBuilder;
 22   
 23    /**
 24    * Token representing the open tag for a component. Components may be either specified or implicit.
 25    * Specified components (the traditional type, dating back to the origin of Tapestry) are matched by
 26    * an entry in the containing component's specification. Implicit components specify their type in
 27    * the component template and must not have an entry in the containing component's specification.
 28    *
 29    * @see TokenType#OPEN
 30    * @author Howard Lewis Ship
 31    * @since 3.0
 32    */
 33   
 34    public class OpenToken extends TemplateToken
 35    {
 36    private String _tag;
 37   
 38    private String _id;
 39   
 40    private String _componentType;
 41   
 42    private Map _attributes;
 43   
 44    /**
 45    * Creates a new token with the given tag, id and type
 46    *
 47    * @param tag
 48    * the template tag which represents the component, typically "span"
 49    * @param id
 50    * the id for the component, which may be assigned by the template parser for
 51    * implicit components
 52    * @param componentType
 53    * the type of component, if an implicit component, or null for a specified component
 54    * @param location
 55    * location of tag represented by this token
 56    */
 57   
 58  792 public OpenToken(String tag, String id, String componentType, Location location)
 59    {
 60  792 super(TokenType.OPEN, location);
 61   
 62  792 _tag = tag;
 63  792 _id = id;
 64  792 _componentType = componentType;
 65    }
 66   
 67    /**
 68    * Returns the id for the component.
 69    */
 70   
 71  1006 public String getId()
 72    {
 73  1006 return _id;
 74    }
 75   
 76    /**
 77    * Returns the tag used to represent the component within the template.
 78    */
 79   
 80  33 public String getTag()
 81    {
 82  33 return _tag;
 83    }
 84   
 85    /**
 86    * Returns the specified component type, or null for a component where the type is not defined
 87    * in the template. The type may include a library id prefix.
 88    */
 89   
 90  1006 public String getComponentType()
 91    {
 92  1006 return _componentType;
 93    }
 94   
 95  623 public void addAttribute(String name, String value)
 96    {
 97  623 if (_attributes == null)
 98  454 _attributes = new HashMap();
 99   
 100  623 _attributes.put(name, value);
 101    }
 102   
 103    /**
 104    * Returns a Map of attributes. Keys and values are strings.
 105    */
 106   
 107  979 public Map getAttributesMap()
 108    {
 109  979 return _attributes;
 110    }
 111   
 112  0 protected void extendDescription(ToStringBuilder builder)
 113    {
 114  0 builder.append("id", _id);
 115  0 builder.append("componentType", _componentType);
 116  0 builder.append("tag", _tag);
 117  0 builder.append("attributes", _attributes);
 118    }
 119   
 120    }