KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portletcontainer > impl > portletAPIImp > utils > PortletSessionImpUtil


1 /**
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5
6 /**
7  * Created by The eXo Platform SARL
8  * Author : Mestrallet Benjamin
9  * benjmestrallet@users.sourceforge.net
10  * Date: Jul 26, 2003
11  * Time: 4:54:01 PM
12  */

13 package org.exoplatform.services.portletcontainer.impl.portletAPIImp.utils;
14
15 import javax.portlet.PortletSession;
16
17
18 /**
19  *
20  * The attribute name may be encoded according to its scope (application or portlet)
21  * using
22  * javax.portlet.p.<ID>?attributeName (for portlet scope)
23  */

24 public class PortletSessionImpUtil {
25
26   private static final String JavaDoc PORTLET_SCOPE_NAMESPACE = "javax.portlet.p.";
27
28   public static String JavaDoc encodePortletSessionAttribute(String JavaDoc id,
29                                                      String JavaDoc attributeName,
30                                                      int scope) {
31     StringBuffer JavaDoc sB = new StringBuffer JavaDoc();
32     if (PortletSession.APPLICATION_SCOPE == scope) {
33       sB.append(attributeName);
34       return sB.toString();
35     } else if (PortletSession.PORTLET_SCOPE == scope) {
36       sB.append(PORTLET_SCOPE_NAMESPACE);
37       sB.append(id);
38       sB.append("?");
39       sB.append(attributeName);
40       return sB.toString();
41     } else {
42       return null;
43     }
44   }
45
46 }
47
Popular Tags