01: /*
02: * $Id: RegionStack.java,v 1.2 2003/09/14 05:36:48 jonesde Exp $
03: *
04: * Copyright (c) 2001-2003 Sun Microsystems Inc., published in "Advanced Java Server Pages" by Prentice Hall PTR
05: * Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
06: *
07: * Permission is hereby granted, free of charge, to any person obtaining a
08: * copy of this software and associated documentation files (the "Software"),
09: * 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.content.webapp.region;
27:
28: import java.util.Stack;
29:
30: import javax.servlet.ServletRequest;
31:
32: public class RegionStack {
33: private RegionStack() {
34: } // no instantiations
35:
36: public static Stack getStack(ServletRequest request) {
37: Stack s = (Stack) request.getAttribute("region-stack");
38:
39: if (s == null) {
40: s = new Stack();
41: request.setAttribute("region-stack", s);
42: }
43: return s;
44: }
45:
46: public static Region peek(ServletRequest request) {
47: return (Region) getStack(request).peek();
48: }
49:
50: public static void push(ServletRequest request, Region region) {
51: getStack(request).push(region);
52: }
53:
54: public static Region pop(ServletRequest request) {
55: return (Region) getStack(request).pop();
56: }
57: }
|