01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.taglib;
06:
07: import java.io.Serializable;
08:
09: import com.sun.portal.providers.Provider;
10: import com.sun.portal.providers.containers.ContainerProvider;
11:
12: public class DesktopTaglibContext implements Serializable {
13: private Provider m_Provider = null;
14: private ContainerProvider m_ContainerProvider = null;
15:
16: static public final int UNDEFINED = 0;
17: static public final int PROVIDER = 1;
18: static public final int CONTAINER = 2;
19: private boolean m_isParentSet = false;
20:
21: public static final String PROVIDER_STACK = "__PROVIDER_STACK__";
22:
23: public void setContainer(ContainerProvider cp)
24: throws DesktopTaglibException {
25: if ((m_ContainerProvider != null && cp != null)
26: || m_Provider != null) {
27: throw new DesktopTaglibException(
28: DesktopTaglibException.INVALID_TAG_SEQUENCE);
29: } else {
30: m_ContainerProvider = cp;
31: }
32: }
33:
34: public ContainerProvider getContainer() {
35: return m_ContainerProvider;
36: }
37:
38: public void setCurrentProvider(Provider p)
39: throws DesktopTaglibException {
40: if (m_Provider != null && p != null) {
41: throw new DesktopTaglibException(
42: DesktopTaglibException.INVALID_TAG_SEQUENCE);
43: } else {
44: m_Provider = p;
45: }
46: }
47:
48: public Provider getCurrentProvider() {
49: return m_Provider;
50: }
51:
52: public void setParentCurrent() throws DesktopTaglibException {
53: if (m_Provider == null || m_ContainerProvider == null) {
54: throw new DesktopTaglibException(
55: DesktopTaglibException.INVALID_TAG_SEQUENCE);
56: } else {
57: m_isParentSet = true;
58: }
59: }
60:
61: public void unsetParentCurrent() throws DesktopTaglibException {
62: if (!m_isParentSet) {
63: throw new DesktopTaglibException(
64: DesktopTaglibException.INVALID_TAG_SEQUENCE);
65: } else {
66: m_isParentSet = false;
67: }
68: }
69:
70: public int getCurrentObjType() {
71: if (m_isParentSet)
72: return CONTAINER;
73: if (m_Provider != null)
74: return PROVIDER;
75: if (m_ContainerProvider != null)
76: return CONTAINER;
77:
78: // none of the case
79: return UNDEFINED;
80: }
81: }
|