KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portletcontainer > impl > portletAPIImp > PortletURLImp


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 package org.exoplatform.services.portletcontainer.impl.portletAPIImp;
6
7
8 import java.net.URLEncoder JavaDoc;
9 import java.util.Enumeration JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12 import java.util.Set JavaDoc;
13 import org.exoplatform.Constants;
14 import org.exoplatform.services.portletcontainer.helper.BasePortletURL;
15 import org.exoplatform.services.portletcontainer.pci.WindowID;
16 /**
17  * Created by The eXo Platform SARL
18  * Author : Mestrallet Benjamin
19  * benjmestrallet@users.sourceforge.net
20  * Date: Jul 29, 2003
21  * Time: 11:13:44 PM
22  */

23 public class PortletURLImp extends BasePortletURL {
24
25   private WindowID windowID;
26
27   private String JavaDoc baseURL;
28
29   public PortletURLImp(String JavaDoc type, String JavaDoc markup,
30                       List JavaDoc supports,
31                       boolean isCurrentlySecured,
32                       List JavaDoc customWindowStates,
33                       Enumeration JavaDoc supportedWindowState,
34                       String JavaDoc baseURL, WindowID windowID){
35     super(type, markup, supports, isCurrentlySecured,
36           customWindowStates, supportedWindowState);
37     this.baseURL = baseURL;
38     this.windowID = windowID;
39   }
40
41   public String JavaDoc toString() {
42     if(!setSecureCalled && isCurrentlySecured)
43       isSecure = true;
44
45     StringBuffer JavaDoc sB = new StringBuffer JavaDoc();
46     sB.append(baseURL);
47     //sB.append(Constants.AMPERSAND);
48
//sB.append(Constants.COMPONENT_PARAMETER);
49
//sB.append("=");
50
//sB.append(windowID.generateKey());
51
sB.append(Constants.AMPERSAND);
52     sB.append(Constants.TYPE_PARAMETER);
53     sB.append("=");
54     sB.append(type);
55     sB.append(Constants.AMPERSAND);
56     sB.append(Constants.SECURE_PARAMETER);
57     sB.append("=");
58     sB.append(isSecure);
59
60     if (requiredPortletMode != null) {
61       sB.append(Constants.AMPERSAND);
62       sB.append(Constants.PORTLET_MODE_PARAMETER);
63       sB.append("=");
64       sB.append(requiredPortletMode);
65     }
66     if (requiredWindowState != null) {
67       sB.append(Constants.AMPERSAND);
68       sB.append(Constants.WINDOW_STATE_PARAMETER);
69       sB.append("=");
70       sB.append(requiredWindowState);
71     }
72
73     Set JavaDoc names = parameters.keySet();
74     for (Iterator JavaDoc iterator = names.iterator(); iterator.hasNext();) {
75       String JavaDoc name = (String JavaDoc) iterator.next() ;
76       Object JavaDoc obj = parameters.get(name) ;
77       if (obj instanceof String JavaDoc) {
78         String JavaDoc value = (String JavaDoc) obj ;
79         sB.append(Constants.AMPERSAND);
80         sB.append(URLEncoder.encode(name));
81         sB.append("=");
82         sB.append(URLEncoder.encode(value));
83       } else {
84         String JavaDoc[] values = (String JavaDoc[]) obj ;
85         for (int i=0; i < values.length ; i++) {
86           sB.append(Constants.AMPERSAND);
87           sB.append(URLEncoder.encode(name));
88           sB.append("=");
89           sB.append(URLEncoder.encode(values[i]));
90         }
91       }
92     }
93     return sB.toString();
94   }
95
96 }
97
Popular Tags