001// Copyright 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry.web;
016
017import java.util.List;
018
019/**
020 * Interface for objects that can hold attributes. Attributes are objects that are stored and
021 * retrieved using unique string names. There may be constraints on when attributes can be accessed
022 * (for example, {@link org.apache.tapestry.web.WebSession}attributes should not be
023 * changed once the response is committed).
024 * 
025 * @author Howard M. Lewis Ship
026 * @since 4.0
027 */
028public interface AttributeHolder
029{
030    /**
031     * Returns a list of all known attributes in ascending alphabetical order. May be empty (but
032     * won't be null).
033     * 
034     * @returns Unmodifiable list of string attribute names.
035     */
036
037    public List getAttributeNames();
038
039    /**
040     * Returns the named object, or null if no attribute has been stored with the given name.
041     */
042
043    public Object getAttribute(String name);
044
045    /**
046     * Updates the attribute, replacing (or removing) its value. For certain implementations, the
047     * attribute may need to be serializable (for example, a {@link WebSession}
048     *  attribute in a clustered application).
049     * 
050     * @param name
051     *            the name of the attribute to update
052     * @param attribute
053     *            the new value for the attribute, or null to delete the attribute entirely.
054     */
055
056    public void setAttribute(String name, Object attribute);
057}