Coverage Report - org.apache.tapestry5.internal.parser.ComponentTemplateImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentTemplateImpl
100%
13/13
N/A
0
 
 1  
 // Copyright 2006, 2008, 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.internal.parser;
 16  
 
 17  
 import org.apache.tapestry5.ioc.Location;
 18  
 import org.apache.tapestry5.ioc.Resource;
 19  
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 20  
 import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
 21  
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 22  
 
 23  
 import java.util.List;
 24  
 import java.util.Map;
 25  
 
 26  
 public class ComponentTemplateImpl implements ComponentTemplate
 27  
 {
 28  
     private final Resource resource;
 29  
 
 30  
     private final List<TemplateToken> tokens;
 31  
 
 32  
     private final Map<String, Location> componentIds;
 33  
 
 34  
     private final boolean extension;
 35  
 
 36  
     private final Map<String, List<TemplateToken>> overrides;
 37  
 
 38  
     /**
 39  
      * @param resource     the resource from which the template was parsed
 40  
      * @param tokens       the tokens of the template, a copy of this list will be made
 41  
      * @param componentIds ids of components defined in the template
 42  
      * @param extension
 43  
      * @param overrides    id to list of tokens for that override
 44  
      */
 45  
     public ComponentTemplateImpl(Resource resource, List<TemplateToken> tokens,
 46  
                                  Map<String, Location> componentIds, boolean extension,
 47  
                                  Map<String, List<TemplateToken>> overrides)
 48  524
     {
 49  524
         this.resource = resource;
 50  524
         this.extension = extension;
 51  524
         this.overrides = overrides;
 52  524
         this.tokens = newList(tokens);
 53  524
         this.componentIds = CollectionFactory.newMap(componentIds);
 54  524
     }
 55  
 
 56  
     public Resource getResource()
 57  
     {
 58  470
         return resource;
 59  
     }
 60  
 
 61  
     public List<TemplateToken> getTokens()
 62  
     {
 63  552
         return tokens;
 64  
     }
 65  
 
 66  
     public Map<String, Location> getComponentIds()
 67  
     {
 68  474
         return componentIds;
 69  
     }
 70  
 
 71  
     /**
 72  
      * Returns false.
 73  
      */
 74  
     public boolean isMissing()
 75  
     {
 76  464
         return false;
 77  
     }
 78  
 
 79  
     public List<TemplateToken> getExtensionPointTokens(String extensionPointId)
 80  
     {
 81  14
         return InternalUtils.get(overrides, extensionPointId);
 82  
     }
 83  
 
 84  
     public boolean isExtension()
 85  
     {
 86  474
         return extension;
 87  
     }
 88  
 }