View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.portletbridge.portlet;
17  
18  import java.io.IOException;
19  import java.io.OutputStream;
20  import java.io.PrintWriter;
21  import java.util.Locale;
22  
23  import javax.portlet.PortletURL;
24  import javax.portlet.RenderResponse;
25  
26  /***
27   * TODO: There's a simpler way of doing this.
28   * 
29   * @author jmccrindle
30   */
31  public class PseudoRenderResponse implements RenderResponse {
32      
33      private String namespace;
34      private String start;
35      private String end;
36  
37      public PseudoRenderResponse(String namespace, String currentUrl, String currentId) {
38          this.namespace = namespace;
39          int indexOfCurrentId = currentUrl.indexOf(currentId);
40          if(indexOfCurrentId < 0) {
41              this.start = "";
42              this.end = "";
43          } else {
44              this.start = currentUrl.substring(0, indexOfCurrentId);
45              this.end = currentUrl.substring(indexOfCurrentId + currentId.length());
46          }
47      }
48  
49      public String getContentType() {
50          throw new UnsupportedOperationException();
51      }
52  
53      public PortletURL createRenderURL() {
54          return new PseudoPortletURL(start, end);
55      }
56  
57      public PortletURL createActionURL() {
58          throw new UnsupportedOperationException();
59      }
60  
61      public String getNamespace() {
62          return namespace;
63      }
64  
65      public void setTitle(String arg0) {
66          throw new UnsupportedOperationException();
67      }
68  
69      public void setContentType(String arg0) {
70          throw new UnsupportedOperationException();
71      }
72  
73      public String getCharacterEncoding() {
74          throw new UnsupportedOperationException();
75      }
76  
77      public PrintWriter getWriter() throws IOException {
78          throw new UnsupportedOperationException();
79      }
80  
81      public Locale getLocale() {
82          throw new UnsupportedOperationException();
83      }
84  
85      public void setBufferSize(int arg0) {
86          throw new UnsupportedOperationException();
87      }
88  
89      public int getBufferSize() {
90          throw new UnsupportedOperationException();
91      }
92  
93      public void flushBuffer() throws IOException {
94          throw new UnsupportedOperationException();
95      }
96  
97      public void resetBuffer() {
98          throw new UnsupportedOperationException();
99      }
100 
101     public boolean isCommitted() {
102         throw new UnsupportedOperationException();
103     }
104 
105     public void reset() {
106         throw new UnsupportedOperationException();
107     }
108 
109     public OutputStream getPortletOutputStream() throws IOException {
110         throw new UnsupportedOperationException();
111     }
112 
113     public void addProperty(String arg0, String arg1) {
114         throw new UnsupportedOperationException();
115     }
116 
117     public void setProperty(String arg0, String arg1) {
118         throw new UnsupportedOperationException();
119     }
120 
121     public String encodeURL(String arg0) {
122         throw new UnsupportedOperationException();
123     }
124 
125     public String getEnd() {
126         return end;
127     }
128 
129     public String getStart() {
130         return start;
131     }
132     
133 
134 }