1/*2 * $Id: AttributeContext.java 736275 2009-01-21 09:58:20Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles;
2223import java.util.Map;
24import java.util.Iterator;
25import java.util.Set;
2627/***28 * Encapsulation of the current state of execution.29 *30 * @since Tiles 2.031 * @version $Rev: 736275 $ $Date: 2009-01-21 10:58:20 +0100 (mer, 21 gen 2009) $32 */33publicinterfaceAttributeContext {
3435/***36 * Returns the attribute that will be used to render a template.37 *38 * @return The template attribute.39 * @since 2.1.240 */41Attribute getTemplateAttribute();
4243/***44 * Sets the template attribute, that will be used to render the template45 * page.46 *47 * @param templateAttribute The template attribute.48 * @since 2.1.249 */50void setTemplateAttribute(Attribute templateAttribute);
5152/***53 * Get associated preparer instance.54 *55 * @return The preparer name.56 * @since 2.1.057 */58 String getPreparer();
5960/***61 * Set associated preparer instance.62 *63 * @param url The preparer name.64 * @since 2.1.065 */66void setPreparer(String url);
6768/***69 * Add all attributes to the context.70 *71 * @param newAttributes the attributes to be added.72 */73void addAll(Map<String, Attribute> newAttributes);
7475/***76 * Add all attributes to the context.77 *78 * @param defaultAttributes attributes which should be present.79 */80void addMissing(Map<String, Attribute> defaultAttributes);
8182/***83 * Copies the cascaded attributes to this attribute context.84 *85 * @param parent The parent context to be used.86 * @since 2.1.087 */88void inheritCascadedAttributes(AttributeContext parent);
8990/***91 * Copies all missing attributes from the <code>parent</code> attribute92 * context to this one.93 *94 * @param parent The attribute context to copy attributes from.95 * @since 2.1.096 */97void inherit(AttributeContext parent);
9899/***100 * Retrieve the named attribute, either cascaded or not.101 *102 * @param name key name for the attribute.103 * @return Attribute associated with the given name.104 */105Attribute getAttribute(String name);
106107/***108 * Retrieve the attribute that has been defined in this context (i.e. not109 * cascaded).110 *111 * @param name key name for the attribute.112 * @return Attribute The local attribute associated with the given name, if113 * present, or <code>null</code> otherwise.114 * @since 2.1.0115 */116Attribute getLocalAttribute(String name);
117118/***119 * Retrieve the attribute that has been cascaded at upper levels.120 *121 * @param name key name for the attribute.122 * @return Attribute The cascaded attribute associated with the given name,123 * if present, or <code>null</code> otherwise.124 * @since 2.1.0125 */126Attribute getCascadedAttribute(String name);
127128/***129 * Iterator of all attribute names.130 *131 * @return iterator of all names.132 * @deprecated Use {@link AttributeContext#getLocalAttributeNames()} or133 * {@link AttributeContext#getCascadedAttributeNames()}.134 */135 @Deprecated
136 Iterator<String> getAttributeNames();
137138/***139 * Returns the names of the local attributes, i.e. the one that have not140 * been cascaded.141 *142 * @return The local attribute names.143 * @since 2.1.0144 */145 Set<String> getLocalAttributeNames();
146147/***148 * Returns the names of the cascaded attributes.149 *150 * @return The cascaded attribute names.151 * @since 2.1.0152 */153 Set<String> getCascadedAttributeNames();
154155/***156 * Add the specified attribute. The attribute value will be available only157 * in the current context, i.e. it is like calling158 * {@link AttributeContext#putAttribute(String, Attribute, boolean)} with159 * <code>cascade = false</code>.160 *161 * @param name name of the attribute162 * @param value value of the attribute163 */164void putAttribute(String name, Attribute value);
165166/***167 * Add the specified attribute.168 *169 * @param name name of the attribute170 * @param value value of the attribute171 * @param cascade If <code>true</code>, the attribute value will be172 * available in all nested contexts. If <code>false</code>, it will be173 * available only in the current context.174 * @since 2.1.0175 */176void putAttribute(String name, Attribute value, boolean cascade);
177178/***179 * Clear the attributes.180 */181void clear();
182 }