org.apache.tiles.api

## Class BasicAttributeContext

- java.lang.Object
- - org.apache.tiles.api.BasicAttributeContext

- All Implemented Interfaces:
    Serializable, AttributeContext
  Direct Known Subclasses:
    Definition

      public class BasicAttributeContext
      extends Object
      implements AttributeContext, Serializable

  Basic implementation for `AttributeContext`.
  Since:
    2.1.0
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,Attribute>` | `attributes` Template attributes.
    `protected Map<String,Attribute>` | `cascadedAttributes` Cascaded template attributes.
    `protected String` | `preparer` Associated ViewPreparer URL or classname, if defined.
    `protected Attribute` | `templateAttribute` The template attribute, to render a template.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicAttributeContext()` Constructor.
    `BasicAttributeContext(AttributeContext context)` Copy constructor.
    `BasicAttributeContext(BasicAttributeContext context)` Copy constructor.
    `BasicAttributeContext(Map<String,Attribute> attributes)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAll(Map<String,Attribute> newAttributes)` Add all attributes to this context.
    `void` | `clear()` Clear the attributes.
    `boolean` | `equals(Object obj)`
    `Attribute` | `getAttribute(String name)` Retrieve the named attribute, either cascaded or not.
    `Attribute` | `getCascadedAttribute(String name)` Retrieve the attribute that has been cascaded at upper levels.
    `Set<String>` | `getCascadedAttributeNames()` Returns the names of the cascaded attributes.
    `Attribute` | `getLocalAttribute(String name)` Retrieve the attribute that has been defined in this context (i.e.
    `Set<String>` | `getLocalAttributeNames()` Returns the names of the local attributes, i.e.
    `String` | `getPreparer()` Get associated preparer instance.
    `Attribute` | `getTemplateAttribute()` Returns the attribute that will be used to render a template.
    `int` | `hashCode()`
    `void` | `inherit(AttributeContext parent)` Copies all missing attributes from the `parent` attribute context to this one.
    `void` | `inherit(BasicAttributeContext parent)` Inherits the attribute context, inheriting, i.e.
    `void` | `inheritCascadedAttributes(AttributeContext context)` Copies the cascaded attributes to this attribute context.
    `void` | `putAttribute(String name, Attribute value)` Add the specified attribute.
    `void` | `putAttribute(String name, Attribute value, boolean cascade)` Add the specified attribute.
    `void` | `setPreparer(String url)` Set associated preparer instance.
    `void` | `setTemplateAttribute(Attribute templateAttribute)` Sets the template attribute, that will be used to render the template page.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### templateAttribute

          protected Attribute templateAttribute

      The template attribute, to render a template.
      Since:
        2.1.2

    - #### preparer

          protected String preparer

      Associated ViewPreparer URL or classname, if defined.
      Since:
        2.1.0

    - #### attributes

          protected Map<String,Attribute> attributes

      Template attributes.
      Since:
        2.1.0

    - #### cascadedAttributes

          protected Map<String,Attribute> cascadedAttributes

      Cascaded template attributes.
      Since:
        2.1.0

  - ### Constructor Detail

    - #### BasicAttributeContext

          public BasicAttributeContext()

      Constructor.
      Since:
        2.1.0

    - #### BasicAttributeContext

          public BasicAttributeContext(Map<String,Attribute> attributes)

      Constructor. Create a context and set specified attributes.
      Parameters:
        `attributes` - Attributes to initialize context.
      Since:
        2.1.0

    - #### BasicAttributeContext

          public BasicAttributeContext(AttributeContext context)

      Copy constructor.
      Parameters:
        `context` - The constructor to copy.
      Since:
        2.1.0

    - #### BasicAttributeContext

          public BasicAttributeContext(BasicAttributeContext context)

      Copy constructor.
      Parameters:
        `context` - The constructor to copy.
      Since:
        2.1.0

  - ### Method Detail

    - #### getTemplateAttribute

          public Attribute getTemplateAttribute()

      Returns the attribute that will be used to render a template.
      Specified by:
        `getTemplateAttribute` in interface `AttributeContext`
      Returns:
        The template attribute.

    - #### setTemplateAttribute

          public void setTemplateAttribute(Attribute templateAttribute)

      Sets the template attribute, that will be used to render the template page.
      Specified by:
        `setTemplateAttribute` in interface `AttributeContext`
      Parameters:
        `templateAttribute` - The template attribute.

    - #### getPreparer

          public String getPreparer()

      Get associated preparer instance.
      Specified by:
        `getPreparer` in interface `AttributeContext`
      Returns:
        The preparer name.

    - #### setPreparer

          public void setPreparer(String url)

      Set associated preparer instance.
      Specified by:
        `setPreparer` in interface `AttributeContext`
      Parameters:
        `url` - The preparer name.

    - #### inheritCascadedAttributes

          public void inheritCascadedAttributes(AttributeContext context)

      Copies the cascaded attributes to this attribute context.
      Specified by:
        `inheritCascadedAttributes` in interface `AttributeContext`
      Parameters:
        `context` - The parent context to be used.

    - #### inherit

          public void inherit(AttributeContext parent)

      Copies all missing attributes from the `parent` attribute context to this one.
      Specified by:
        `inherit` in interface `AttributeContext`
      Parameters:
        `parent` - The attribute context to copy attributes from.

    - #### inherit

          public void inherit(BasicAttributeContext parent)

      Inherits the attribute context, inheriting, i.e. copying if not present, the attributes.
      Parameters:
        `parent` - The attribute context to inherit.
      Since:
        2.1.0

    - #### addAll

          public void addAll(Map<String,Attribute> newAttributes)

      Add all attributes to this context. Copies all the mappings from the specified attribute map to this context. New attribute mappings will replace any mappings that this context had for any of the keys currently in the specified attribute map.
      Specified by:
        `addAll` in interface `AttributeContext`
      Parameters:
        `newAttributes` - Attributes to add.
      Since:
        2.1.0

    - #### getAttribute

          public Attribute getAttribute(String name)

      Retrieve the named attribute, either cascaded or not.
      Specified by:
        `getAttribute` in interface `AttributeContext`
      Parameters:
        `name` - key name for the attribute.
      Returns:
        Attribute associated with the given name.

    - #### getLocalAttribute

          public Attribute getLocalAttribute(String name)

      Retrieve the attribute that has been defined in this context (i.e. not cascaded).
      Specified by:
        `getLocalAttribute` in interface `AttributeContext`
      Parameters:
        `name` - key name for the attribute.
      Returns:
        Attribute The local attribute associated with the given name, if present, or `null` otherwise.

    - #### getCascadedAttribute

          public Attribute getCascadedAttribute(String name)

      Retrieve the attribute that has been cascaded at upper levels.
      Specified by:
        `getCascadedAttribute` in interface `AttributeContext`
      Parameters:
        `name` - key name for the attribute.
      Returns:
        Attribute The cascaded attribute associated with the given name, if present, or `null` otherwise.

    - #### getLocalAttributeNames

          public Set<String> getLocalAttributeNames()

      Returns the names of the local attributes, i.e. the one that have not been cascaded.
      Specified by:
        `getLocalAttributeNames` in interface `AttributeContext`
      Returns:
        The local attribute names.

    - #### getCascadedAttributeNames

          public Set<String> getCascadedAttributeNames()

      Returns the names of the cascaded attributes.
      Specified by:
        `getCascadedAttributeNames` in interface `AttributeContext`
      Returns:
        The cascaded attribute names.

    - #### putAttribute

          public void putAttribute(String name,
                                   Attribute value)

      Add the specified attribute. The attribute value will be available only in the current context, i.e. it is like calling `AttributeContext.putAttribute(String, Attribute, boolean)` with `cascade = false`.
      Specified by:
        `putAttribute` in interface `AttributeContext`
      Parameters:
        `name` - name of the attribute
        `value` - value of the attribute

    - #### putAttribute

          public void putAttribute(String name,
                                   Attribute value,
                                   boolean cascade)

      Add the specified attribute.
      Specified by:
        `putAttribute` in interface `AttributeContext`
      Parameters:
        `name` - name of the attribute
        `value` - value of the attribute
        `cascade` - If `true`, the attribute value will be available in all nested contexts. If `false`, it will be available only in the current context.

    - #### clear

          public void clear()

      Clear the attributes.
      Specified by:
        `clear` in interface `AttributeContext`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.