1/*2 * $Id: BasicAttributeContext.java 637434 2008-03-15 15:48:38Z 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 */2122package org.apache.tiles.context;
2324import java.util.Map;
25import java.util.Stack;
2627import org.apache.tiles.Attribute;
28import org.apache.tiles.AttributeContext;
2930/***31 * Deprecated implementation for <code>AttributeContext</code>, maintained32 * for compatibility reasons.33 *34 * @version $Rev: 637434 $ $Date: 2008-03-15 16:48:38 +0100 (sab, 15 mar 2008) $35 * @deprecated Use {@link org.apache.tiles.BasicAttributeContext}.36 */37 @Deprecated
38publicclassBasicAttributeContextextends39 org.apache.tiles.BasicAttributeContext {
4041/***42 * Name used to store attribute context stack.43 */44privatestaticfinal String ATTRIBUTE_CONTEXT_STACK =
45"org.apache.tiles.AttributeContext.STACK";
4647/***48 * Constructor.49 */50publicBasicAttributeContext() {
51super();
52 }
5354/***55 * Constructor.56 * Create a context and set specified attributes.57 *58 * @param attributes Attributes to initialize context.59 */60publicBasicAttributeContext(Map<String, Attribute> attributes) {
61super(attributes);
62 }
6364/***65 * Copy constructor.66 *67 * @param context The constructor to copy.68 */69publicBasicAttributeContext(AttributeContext context) {
70super(context);
71 }
7273/***74 * Copy constructor.75 *76 * @param context The constructor to copy.77 */78publicBasicAttributeContext(BasicAttributeContext context) {
79super(context);
80 }
8182/***83 * Get attribute context from request.84 *85 * @param tilesContext current Tiles application context.86 * @return BasicAttributeContext or null if context is not found.87 * @deprecated Use {@link TilesContainer#getAttributeContext(Object...)}.88 */89 @Deprecated
90publicstatic AttributeContext getContext(TilesRequestContext tilesContext) {
91 Stack<AttributeContext> contextStack = getContextStack(tilesContext);
92if (!contextStack.isEmpty()) {
93return contextStack.peek();
94 } else {
95returnnull;
96 }
97 }
9899/***100 * Returns the context stack.101 *102 * @param tilesContext The Tiles context object to use.103 * @return The needed stack of contexts.104 * @deprecated Use {@link TilesContainer#getAttributeContext(Object...)},105 * {@link TilesContainer#startContext(Object...)} or106 * {@link TilesContainer#endContext(Object...)}.107 */108 @Deprecated
109 @SuppressWarnings("unchecked")
110publicstatic Stack<AttributeContext> getContextStack(TilesRequestContext tilesContext) {
111 Stack<AttributeContext> contextStack =
112 (Stack<AttributeContext>) tilesContext.getRequestScope().get(
113 BasicAttributeContext.ATTRIBUTE_CONTEXT_STACK);
114if (contextStack == null) {
115 contextStack = new Stack<AttributeContext>();
116 tilesContext.getRequestScope().put(BasicAttributeContext.ATTRIBUTE_CONTEXT_STACK,
117 contextStack);
118 }
119120return contextStack;
121 }
122123/***124 * Pushes a context object in the stack.125 *126 * @param context The context to push.127 * @param tilesContext The Tiles context object to use.128 * @deprecated Use {@link TilesContainer#startContext(Object...)}.129 */130 @Deprecated
131publicstaticvoid pushContext(AttributeContext context,
132TilesRequestContext tilesContext) {
133 Stack<AttributeContext> contextStack = getContextStack(tilesContext);
134 contextStack.push(context);
135 }
136137/***138 * Pops a context object out of the stack.139 *140 * @param tilesContext The Tiles context object to use.141 * @return The popped context object.142 * @deprecated Use {@link TilesContainer#endContext(Object...)}.143 */144 @Deprecated
145publicstatic AttributeContext popContext(TilesRequestContext tilesContext) {
146 Stack<AttributeContext> contextStack = getContextStack(tilesContext);
147return contextStack.pop();
148 }
149 }