Coverage Report - org.apache.tapestry5.dom.Attribute
 
Classes in this File Line Coverage Branch Coverage Complexity
Attribute
100%
18/18
100%
4/4
0
 
 1  
 // Copyright 2009 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.tapestry5.dom;
 16  
 
 17  
 import org.apache.tapestry5.internal.TapestryInternalUtils;
 18  
 
 19  
 import java.util.Map;
 20  
 
 21  
 /**
 22  
  * An attribute within an {@link org.apache.tapestry5.dom.Element}. Each attribute has a namespace URI, a local name
 23  
  * within the namespace, and a value.
 24  
  *
 25  
  * @since 5.1.0.2
 26  
  */
 27  
 public class Attribute
 28  
 {
 29  
     private final Element element;
 30  
 
 31  
     private final String namespace;
 32  
 
 33  
     private final String name;
 34  
 
 35  
     String value;
 36  
 
 37  
     Attribute nextAttribute;
 38  
 
 39  
     Attribute(Element element, String namespace, String name, String value, Attribute nextAttribute)
 40  110252
     {
 41  110252
         this.element = element;
 42  110252
         this.namespace = namespace;
 43  110252
         this.name = name;
 44  110252
         this.value = value;
 45  110252
         this.nextAttribute = nextAttribute;
 46  110252
     }
 47  
 
 48  
     public String getName()
 49  
     {
 50  1422
         return name;
 51  
     }
 52  
 
 53  
     public String getNamespace()
 54  
     {
 55  110682
         return namespace;
 56  
     }
 57  
 
 58  
     public String getValue()
 59  
     {
 60  2
         return value;
 61  
     }
 62  
 
 63  
     void render(MarkupModel model, StringBuilder builder, Map<String, String> namespaceURIToPrefix)
 64  
     {
 65  110682
         builder.append(" ");
 66  110682
         builder.append(element.toPrefixedName(namespaceURIToPrefix, namespace, name));
 67  110682
         builder.append("=");
 68  110682
         builder.append(model.getAttributeQuote());
 69  110682
         model.encodeQuoted(value, builder);
 70  110682
         builder.append(model.getAttributeQuote());
 71  110682
     }
 72  
 
 73  
     boolean matches(String namespace, String name)
 74  
     {
 75  34178
         return TapestryInternalUtils.isEqual(this.namespace, namespace) &&
 76  
                 this.name.equalsIgnoreCase(name);
 77  
     }
 78  
 }