Coverage Report - org.apache.tiles.AttributeContext
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeContext
N/A
N/A
1
 
 1  
 /*
 2  
  * $Id: AttributeContext.java 829574 2009-10-25 14:15:31Z 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;
 22  
 
 23  
 import java.util.Map;
 24  
 import java.util.Set;
 25  
 
 26  
 /**
 27  
  * Encapsulation of the current state of execution.
 28  
  *
 29  
  * @since Tiles 2.0
 30  
  * @version $Rev: 829574 $ $Date: 2009-10-26 01:15:31 +1100 (Mon, 26 Oct 2009) $
 31  
  */
 32  
 public interface AttributeContext {
 33  
 
 34  
     /**
 35  
      * Returns the attribute that will be used to render a template.
 36  
      *
 37  
      * @return The template attribute.
 38  
      * @since 2.1.2
 39  
      */
 40  
     Attribute getTemplateAttribute();
 41  
 
 42  
     /**
 43  
      * Sets the template attribute, that will be used to render the template
 44  
      * page.
 45  
      *
 46  
      * @param templateAttribute The template attribute.
 47  
      * @since 2.1.2
 48  
      */
 49  
     void setTemplateAttribute(Attribute templateAttribute);
 50  
 
 51  
     /**
 52  
      * Get associated preparer instance.
 53  
      *
 54  
      * @return The preparer name.
 55  
      * @since 2.1.0
 56  
      */
 57  
     String getPreparer();
 58  
 
 59  
     /**
 60  
      * Set associated preparer instance.
 61  
      *
 62  
      * @param url The preparer name.
 63  
      * @since 2.1.0
 64  
      */
 65  
     void setPreparer(String url);
 66  
 
 67  
     /**
 68  
      * Add all attributes to the context.
 69  
      *
 70  
      * @param newAttributes the attributes to be added.
 71  
      */
 72  
     void addAll(Map<String, Attribute> newAttributes);
 73  
 
 74  
     /**
 75  
      * Add all attributes to the context.
 76  
      *
 77  
      * @param defaultAttributes attributes which should be present.
 78  
      */
 79  
     void addMissing(Map<String, Attribute> defaultAttributes);
 80  
 
 81  
     /**
 82  
      * Copies the cascaded attributes to this attribute context.
 83  
      *
 84  
      * @param parent The parent context to be used.
 85  
      * @since 2.1.0
 86  
      */
 87  
     void inheritCascadedAttributes(AttributeContext parent);
 88  
 
 89  
     /**
 90  
      * Copies all missing attributes from the <code>parent</code> attribute
 91  
      * context to this one.
 92  
      *
 93  
      * @param parent The attribute context to copy attributes from.
 94  
      * @since 2.1.0
 95  
      */
 96  
     void inherit(AttributeContext parent);
 97  
 
 98  
     /**
 99  
      * Retrieve the named attribute, either cascaded or not.
 100  
      *
 101  
      * @param name key name for the attribute.
 102  
      * @return Attribute associated with the given name.
 103  
      */
 104  
     Attribute getAttribute(String name);
 105  
 
 106  
     /**
 107  
      * Retrieve the attribute that has been defined in this context (i.e. not
 108  
      * cascaded).
 109  
      *
 110  
      * @param name key name for the attribute.
 111  
      * @return Attribute The local attribute associated with the given name, if
 112  
      * present, or <code>null</code> otherwise.
 113  
      * @since 2.1.0
 114  
      */
 115  
     Attribute getLocalAttribute(String name);
 116  
 
 117  
     /**
 118  
      * Retrieve the attribute that has been cascaded at upper levels.
 119  
      *
 120  
      * @param name key name for the attribute.
 121  
      * @return Attribute The cascaded attribute associated with the given name,
 122  
      * if present, or <code>null</code> otherwise.
 123  
      * @since 2.1.0
 124  
      */
 125  
     Attribute getCascadedAttribute(String name);
 126  
 
 127  
     /**
 128  
      * Returns the names of the local attributes, i.e. the one that have not
 129  
      * been cascaded.
 130  
      *
 131  
      * @return The local attribute names.
 132  
      * @since 2.1.0
 133  
      */
 134  
     Set<String> getLocalAttributeNames();
 135  
 
 136  
     /**
 137  
      * Returns the names of the cascaded attributes.
 138  
      *
 139  
      * @return The cascaded attribute names.
 140  
      * @since 2.1.0
 141  
      */
 142  
     Set<String> getCascadedAttributeNames();
 143  
 
 144  
     /**
 145  
      * Add the specified attribute. The attribute value will be available only
 146  
      * in the current context, i.e. it is like calling
 147  
      * {@link AttributeContext#putAttribute(String, Attribute, boolean)} with
 148  
      * <code>cascade = false</code>.
 149  
      *
 150  
      * @param name name of the attribute
 151  
      * @param value value of the attribute
 152  
      */
 153  
     void putAttribute(String name, Attribute value);
 154  
 
 155  
     /**
 156  
      * Add the specified attribute.
 157  
      *
 158  
      * @param name name of the attribute
 159  
      * @param value value of the attribute
 160  
      * @param cascade If <code>true</code>, the attribute value will be
 161  
      * available in all nested contexts. If <code>false</code>, it will be
 162  
      * available only in the current context.
 163  
      * @since 2.1.0
 164  
      */
 165  
     void putAttribute(String name, Attribute value, boolean cascade);
 166  
 
 167  
     /**
 168  
      * Clear the attributes.
 169  
      */
 170  
     void clear();
 171  
 }