1 /* 2 * $Id: TemplateSuite.java 1044707 2010-12-11 20:35:57Z apetrelli $ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 package org.apache.tiles.autotag.model; 22 23 import java.util.Collection; 24 import java.util.LinkedHashMap; 25 import java.util.Map; 26 27 /** 28 * It represents a suite of template classes. 29 * 30 * @version $Rev: 1044707 $ $Date: 2010-12-11 21:35:57 +0100 (Sat, 11 Dec 2010) $ 31 */ 32 public class TemplateSuite { 33 34 /** 35 * The name of the suite. 36 */ 37 private String name; 38 39 /** 40 * The documentation of this suite. 41 */ 42 private String documentation; 43 44 /** 45 * The map of template classes. 46 */ 47 private Map<String, TemplateClass> templateClasses; 48 49 /** 50 * Constructor. 51 * 52 * @param name The name of the suite. 53 * @param documentation The documentation. 54 */ 55 public TemplateSuite(String name, String documentation) { 56 this(name, documentation, null); 57 } 58 59 /** 60 * Constructor. 61 * 62 * @param name The name of the suite. 63 * @param documentation The documentation. 64 * @param classes The template classes. 65 */ 66 public TemplateSuite(String name, String documentation, 67 Iterable<? extends TemplateClass> classes) { 68 this.name = name; 69 this.documentation = documentation; 70 templateClasses = new LinkedHashMap<String, TemplateClass>(); 71 if (classes != null) { 72 for (TemplateClass templateClass : classes) { 73 templateClasses.put(templateClass.getName(), templateClass); 74 } 75 } 76 } 77 78 /** 79 * Returns the template suite name. 80 * 81 * @return The name. 82 */ 83 public String getName() { 84 return name; 85 } 86 87 /** 88 * Returns the documentation. 89 * 90 * @return The documentation. 91 */ 92 public String getDocumentation() { 93 return documentation; 94 } 95 96 /** 97 * Adds a new template class. 98 * 99 * @param clazz The template class. 100 */ 101 public void addTemplateClass(TemplateClass clazz) { 102 templateClasses.put(clazz.getName(), clazz); 103 } 104 105 /** 106 * Returns the template classes. 107 * 108 * @return The template classes. 109 */ 110 public Collection<TemplateClass> getTemplateClasses() { 111 return templateClasses.values(); 112 } 113 114 /** 115 * Returns a template class given its name. 116 * 117 * @param name The name of the class. 118 * @return The template class instance. 119 */ 120 public TemplateClass getTemplateClassByName(String name) { 121 return templateClasses.get(name); 122 } 123 124 @Override 125 public String toString() { 126 return "TemplateSuite [name=" + name + ", documentation=" 127 + documentation + ", templateClasses=" + templateClasses + "]"; 128 } 129 }