KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > webapp > region > RegionStack


1 /*
2  * $Id: RegionStack.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001-2003 Sun Microsystems Inc., published in "Advanced Java Server Pages" by Prentice Hall PTR
5  * Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
22  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  */

26 package org.ofbiz.webapp.region;
27
28 import java.util.Stack JavaDoc;
29 import javax.servlet.ServletRequest JavaDoc;
30
31 public class RegionStack {
32     private RegionStack() {} // no instantiations
33

34     public static Stack JavaDoc getStack(ServletRequest JavaDoc request) {
35         Stack JavaDoc s = (Stack JavaDoc) request.getAttribute("region-stack");
36
37         if (s == null) {
38             s = new Stack JavaDoc();
39             request.setAttribute("region-stack", s);
40         }
41         return s;
42     }
43
44     public static Region peek(ServletRequest JavaDoc request) {
45         return (Region) getStack(request).peek();
46     }
47
48     public static void push(ServletRequest JavaDoc request, Region region) {
49         getStack(request).push(region);
50     }
51
52     public static Region pop(ServletRequest JavaDoc request) {
53         return (Region) getStack(request).pop();
54     }
55 }
56
Popular Tags