portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r427912 - in /portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems: dojo/DojoSpringMVCPortlet.java util/HttpBufferedResponse.java util/PortletContentImpl.java util/PrintWriterServletOutputStream.java
Date Wed, 02 Aug 2006 06:32:01 GMT
Author: taylor
Date: Tue Aug  1 23:32:01 2006
New Revision: 427912

URL: http://svn.apache.org/viewvc?rev=427912&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-570

Added:
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/dojo/DojoSpringMVCPortlet.java
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/HttpBufferedResponse.java
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PrintWriterServletOutputStream.java

Added: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/dojo/DojoSpringMVCPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/dojo/DojoSpringMVCPortlet.java?rev=427912&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/dojo/DojoSpringMVCPortlet.java
(added)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/dojo/DojoSpringMVCPortlet.java
Tue Aug  1 23:32:01 2006
@@ -0,0 +1,335 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.gems.dojo;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.headerresource.HeaderResource;
+import org.apache.jetspeed.headerresource.HeaderResourceFactory;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.pluto.core.impl.RenderRequestImpl;
+import org.apache.pluto.core.impl.RenderResponseImpl;
+import org.apache.portals.gems.util.HttpBufferedResponse;
+import org.apache.portals.gems.util.PortletContentImpl;
+import org.springframework.beans.BeansException;
+import org.springframework.web.portlet.DispatcherPortlet;
+
+
+/**
+ * Abstract DOJO portlet for inserting in cross context dojo widget includes
+ * 
+ * @author <a href="mailto:smilek@apache.org">Steve Milek</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> 
+ * @version $Id: $
+ */
+public class DojoSpringMVCPortlet extends DispatcherPortlet
+{
+    protected void includeDojoRequires(StringBuffer headerInfoText)
+    {
+    	addDojoRequire(headerInfoText, "dojo.widget.*");
+    	addDojoRequire(headerInfoText, "dojo.widget.Tree");
+    }
+    protected void includeDojoWidgetRequires(StringBuffer headerInfoText)
+    {
+    	addDojoRequire(headerInfoText, "dojo.widget.Manager");
+    }
+    protected void includeDojoCustomWidgetRequires(StringBuffer headerInfoText)
+    {
+        headerInfoText.append("dojo.hostenv.setModulePrefix('jetspeed.ui.widget', '../desktop/widget');\r\n");
+        headerInfoText.append("dojo.hostenv.setModulePrefix('jetspeed.desktop', '../desktop/core');\r\n");
+    }
+    
+    /*
+     * Class specific logger.
+     */
+    private final static Log log = LogFactory.getLog(DojoSpringMVCPortlet.class);
+
+    /*
+     * Jetspeed header resource component
+     */
+    protected HeaderResourceFactory headerResourceFactoryComponent;
+
+    protected String headerPage;
+    
+    /*
+     * Portlet constructor.
+     */
+    public DojoSpringMVCPortlet() 
+    {
+        super();
+    }
+
+    /*
+     * Portlet lifecycle method.
+     */
+    protected void initFrameworkPortlet() throws PortletException, BeansException
+    {
+        super.initFrameworkPortlet();
+
+        // access jetspeed heaader resource component
+        synchronized (this) 
+        {
+            if (headerResourceFactoryComponent == null) 
+            {
+                headerResourceFactoryComponent = (HeaderResourceFactory) 
+                    getPortletContext().getAttribute(CommonPortletServices.CPS_HEADER_RESOURCE_FACTORY);
+            }
+            if (headerResourceFactoryComponent == null) 
+            {
+                throw new PortletException("Failed to find the HeaderResourceFactoryComponent
instance.");
+            }
+            this.headerPage = this.getInitParameter("HeaderPage");
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.portlet.GenericPortlet#doDispatch(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
+     */
+    protected void doRenderService(RenderRequest request, RenderResponse response) throws
Exception
+    {
+        // include header content
+        doHeader(request,response);
+
+        // dispatch normally
+        super.doRenderService(request, response);
+    }
+
+    /*
+     * Include Dojo header content using header resource component.
+     *
+     * @param request render request
+     * @param response render response
+     */    
+    protected void doHeader(RenderRequest request, RenderResponse response)
+    throws PortletException, java.io.IOException
+    {
+        // get portal context path
+        RequestContext requestContext = (RequestContext) request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        String portalContextPath = requestContext.getRequest().getContextPath();
+
+        // use header resource component to ensure header logic is included only once
+        HeaderResource headerResource = headerResourceFactoryComponent.getHeaderResouce(request);
+        StringBuffer headerInfoText = new StringBuffer();
+        Map headerInfoMap = null;
+
+        // detect jetspeed-desktop
+        String requestEncoder = (String)requestContext.getRequest().getParameter("encoder");
+
+        boolean isJetspeedDesktop = ((requestEncoder == null) || !requestEncoder.equals("desktop"))
? false : true;
+
+        // add dojo if not already in use as desktop
+        if (!isJetspeedDesktop) 
+        {
+            // dojo configuration
+            headerInfoText.setLength(0);
+            headerInfoText.append("\r\n");
+            headerInfoText.append("var djConfig = {isDebug: true, debugAtAllCosts: true,
baseScriptUri: '" + portalContextPath + "/javascript/dojo/'};\r\n");
+            headerInfoMap = new HashMap(8);
+            headerInfoMap.put("type", "text/javascript");
+            headerInfoMap.put("language", "JavaScript");
+            headerResource.addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+    
+            // dojo script
+            headerInfoMap = new HashMap(8);
+            headerInfoMap.put("language", "JavaScript");
+            headerInfoMap.put("type", "text/javascript");
+            headerInfoMap.put("src", portalContextPath + "/javascript/dojo/dojo.js");
+            headerResource.addHeaderInfo("script", headerInfoMap, "");
+            
+            // dojo includes
+            headerInfoText.setLength(0);
+            headerInfoText.append("\r\n");
+            includeDojoRequires(headerInfoText);
+            includeDojoWidgetRequires(headerInfoText);
+            includeDojoCustomWidgetRequires(headerInfoText);
+            
+            headerInfoText.append("dojo.require('jetspeed.desktop.compatibility');\r\n");
+
+            headerInfoMap = new HashMap(8);
+            headerInfoMap.put("language", "JavaScript");
+            headerInfoMap.put("type", "text/javascript");
+            headerResource.addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+        }
+        
+        // close DOJO if not already in use as desktop
+        if (!isJetspeedDesktop) 
+        {
+            // complete DoJo includes
+            headerInfoText.setLength(0);
+            headerInfoText.append("\r\n");
+            headerInfoText.append("dojo.hostenv.writeIncludes();\r\n");
+            headerInfoMap = new HashMap(8);
+            headerInfoMap.put("language", "JavaScript");
+            headerInfoMap.put("type", "text/javascript");
+            headerResource.addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+        }
+
+        // add jetspeed widget package if not already in use as desktop
+        if (!isJetspeedDesktop) 
+        {
+            headerInfoText.setLength(0);
+            headerInfoText.append("\r\n");
+            headerInfoText.append("dojo.widget.manager.registerWidgetPackage('jetspeed.ui.widget');\r\n");
+            headerInfoMap = new HashMap(8);
+            headerInfoMap.put("language", "JavaScript");
+            headerInfoMap.put("type", "text/javascript");
+            headerResource.addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+        }
+        
+        if (!isJetspeedDesktop)
+        {
+            headerInfoText.setLength(0);
+            headerInfoText.append("\r\n");
+            headerInfoText.append("html, body\r\n");
+            headerInfoText.append("{\r\n");
+            headerInfoText.append("   width: 100%;\r\n");
+            headerInfoText.append("   height: 100%;\r\n");
+            headerInfoText.append("   margin: 0 0 0 0;\r\n");
+            headerInfoText.append("}\r\n");
+            headerInfoMap = new HashMap(8);
+            headerResource.addHeaderInfo("style", headerInfoMap, headerInfoText.toString());
+        }
+        
+        include(request, response);
+    }
+    
+    public void include(RenderRequest request, RenderResponse response) throws PortletException,
java.io.IOException
+    {
+        HttpServletRequest servletRequest = null;
+        HttpServletResponse servletResponse = null;
+        try
+        {
+            servletRequest = (HttpServletRequest) ((RenderRequestImpl) request).getRequest();
+            servletResponse = (HttpServletResponse) ((RenderResponseImpl) response).getResponse();
+
+            
+            PortletContentImpl content = new PortletContentImpl();
+            content.init();
+            HttpBufferedResponse bufferedResponse = 
+                new HttpBufferedResponse(servletResponse, content.getWriter());
+            
+            RequestDispatcher dispatcher = servletRequest.getRequestDispatcher(this.headerPage);
+            System.out.println("dispatcher:" + dispatcher);
+            if (dispatcher != null)
+                dispatcher.include(servletRequest, bufferedResponse);
+            
+            bufferedResponse.flushBuffer();
+            BufferedReader reader = new BufferedReader(new StringReader(content.getContent()));
+            String buffer;
+            while ((buffer = reader.readLine()) != null)
+            {
+                System.out.println(buffer);                
+            }
+            //System.out.println("dispatched:" + content.getContent());
+        }
+        catch (RuntimeException re)
+        {
+            throw re;
+        }
+        catch (IOException ioe)
+        {
+            throw ioe;
+        }
+        catch (Exception e)
+        {
+            Throwable rootCause = null;
+            if ( e instanceof ServletException)
+            {
+                rootCause = ((ServletException)e).getRootCause();
+            }
+            else
+            {
+                rootCause = e.getCause();
+            }
+            throw new PortletException(rootCause != null ? rootCause : e);
+        }
+    }
+    
+    protected void addDojoRequire(StringBuffer headerInfoText, String header)
+    {
+        headerInfoText.append("dojo.require('" + header + "');\r\n");
+    }
+
+
+	// debugging
+
+	protected void dumpAttributes(RenderRequest request)
+	{
+		Enumeration attrIter = request.getAttributeNames();
+		log.info( "request-attributes:");
+		while ( attrIter.hasMoreElements() )
+		{
+			Object attrNm = attrIter.nextElement();
+			Object attrVal = request.getAttribute(ObjectUtils.toString(attrNm));
+			String attrValDesc = ( attrVal instanceof String ) ? (String)attrVal : (( attrVal == null
) ? "null" : attrVal.getClass().getName() );
+			log.info( "   key=" + ObjectUtils.toString(attrNm,"null") + " value=" + attrValDesc);
+		}
+	}
+	protected void dumpSession(RenderRequest request)
+	{
+		Enumeration attrIter = request.getPortletSession().getAttributeNames();
+		log.info( "session-attributes:");
+		while ( attrIter.hasMoreElements() )
+		{
+			Object attrNm = attrIter.nextElement();
+			Object attrVal = request.getPortletSession().getAttribute(ObjectUtils.toString(attrNm));
+			String attrValDesc = ( attrVal instanceof String ) ? (String)attrVal : (( attrVal == null
) ? "null" : attrVal.getClass().getName() );
+			log.info( "   key=" + ObjectUtils.toString(attrNm,"null") + " value=" + attrValDesc);
+		}
+	}
+	protected void dumpNameValue( Map m  )
+	{
+		if ( m == null )
+		{
+			log.info( "   <null>" );
+			return;
+		}
+		if ( m.size() == 0 )
+		{
+			log.info( "   <empty>" );
+			return;
+		}
+		Iterator entryIter = m.entrySet().iterator();
+		while ( entryIter.hasNext() )
+		{
+			Map.Entry e = (Map.Entry)entryIter.next();
+			Object eKey = e.getKey();
+			Object eVal = e.getValue();
+			String eKeyDesc = ( eKey instanceof String ) ? (String)eKey : (( eKey == null ) ? "null"
: eKey.getClass().getName() );
+			String eValDesc = ( eVal instanceof String ) ? (String)eVal : (( eVal == null ) ? "null"
: eVal.getClass().getName() );
+			log.info( "   key=" + eKeyDesc + " value=" + eValDesc);
+		}
+	}
+}

Added: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/HttpBufferedResponse.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/HttpBufferedResponse.java?rev=427912&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/HttpBufferedResponse.java
(added)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/HttpBufferedResponse.java
Tue Aug  1 23:32:01 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.gems.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+public class HttpBufferedResponse extends javax.servlet.http.HttpServletResponseWrapper
+{
+    private boolean usingWriter;
+    private boolean usingStream;
+
+    /** Commons logging */
+    protected final static Log log = LogFactory.getLog(HttpBufferedResponse.class);
+
+    private ServletOutputStream wrappedStream;
+    private PrintWriter writer;
+
+    public HttpBufferedResponse(HttpServletResponse servletResponse,
+                                PrintWriter writer)
+    {
+        super(servletResponse);
+        this.writer = writer;
+    }
+
+    public ServletOutputStream getOutputStream() throws IllegalStateException, IOException
+    {
+        if (usingWriter)
+        {
+            throw new IllegalStateException("getOutputStream can't be used after getWriter
was invoked");
+        }
+
+        if (wrappedStream == null)
+        {            
+            wrappedStream = new PrintWriterServletOutputStream(writer, getResponse().getCharacterEncoding());
                                                              
+        }
+
+        usingStream = true;
+
+        return wrappedStream;
+    }
+
+    public PrintWriter getWriter() throws UnsupportedEncodingException, IllegalStateException,
IOException {
+
+        if (usingStream)
+        {
+            throw new IllegalStateException("getWriter can't be used after getOutputStream
was invoked");
+        }
+
+        usingWriter = true;
+
+        return writer;
+    }
+
+
+    public void setBufferSize(int size)
+    {
+        // ignore
+    }
+
+    public int getBufferSize()
+    {
+        return 0;
+    }
+
+    public void flushBuffer() throws IOException
+    {
+        writer.flush();
+    }
+
+    public boolean isCommitted()
+    {
+        return false;
+    }
+
+    public void reset()
+    {
+        // ignore right now
+    }
+}

Added: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java?rev=427912&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
(added)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
Tue Aug  1 23:32:01 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.gems.util;
+
+import java.io.CharArrayWriter;
+import java.io.PrintWriter;
+
+import org.apache.jetspeed.aggregator.PortletContent;
+
+
+public class PortletContentImpl implements PortletContent
+{
+    private CharArrayWriter cw;
+    private PrintWriter writer;
+    private boolean complete = false;
+
+    public PortletContentImpl()
+    {
+        init();
+    }
+
+    public PrintWriter getWriter()
+    {
+        return writer;
+    }
+
+    public void init()
+    {
+        cw = new CharArrayWriter();
+        writer = new PrintWriter(cw);
+    }
+
+    public void release()
+    {
+        writer.close();
+    }
+
+    public String toString()
+    {
+        writer.flush();
+        return cw.toString();
+    }
+
+    public void writeTo( java.io.Writer out ) throws java.io.IOException
+    {
+        writer.flush();
+        cw.writeTo(out);
+    }
+
+    public char[] toCharArray()
+    {
+        writer.flush();
+        return cw.toCharArray();
+    }
+
+    public boolean isComplete()
+    {
+        return complete;
+    }
+
+    void setComplete( boolean state )
+    {
+        this.complete = state;
+    }
+    
+    public String getContent()
+    {
+        return toString();
+    }
+    /**
+     * <p>
+     * complete
+     * </p>
+     *
+     * @see org.apache.jetspeed.aggregator.PortletContent#complete()
+     * 
+     */
+    public void complete()
+    {
+       setComplete(true);
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PrintWriterServletOutputStream.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PrintWriterServletOutputStream.java?rev=427912&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PrintWriterServletOutputStream.java
(added)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PrintWriterServletOutputStream.java
Tue Aug  1 23:32:01 2006
@@ -0,0 +1,175 @@
+
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* 
+
+ */
+
+package org.apache.portals.gems.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+
+import javax.servlet.ServletOutputStream;
+
+/**
+ * This is a specialized class implementing a ServletOutputStream that works in
+ * conjunction with a PrintWriter to send data to the browser. It is used when
+ * a J2EE server throws an IllegalStateException when you call getOutputStream
+ * on a response which someone has previously called getWriter on.
+ */
+public class PrintWriterServletOutputStream extends ServletOutputStream
+{
+
+  /**
+   * The PrintWriter that is wrapped on top of the base input stream
+   */
+  PrintWriter mPrintWriter;
+
+  /**
+   * The character encoding of the response.
+   */
+  private String characterEncoding;
+
+  /**
+   * @deprecated since 1.0RC3; use PrintWriterServletOutputStream
+   * <p>
+   * Construct a ServletOutputStream that coordinates output using a base
+   * ServletOutputStream and a PrintWriter that is wrapped on top of that
+   * OutputStream.
+   * </p>
+   */
+  public PrintWriterServletOutputStream(PrintWriter pO)
+  {
+      this(pO, null);
+  }
+
+  public PrintWriterServletOutputStream(PrintWriter pw, String encoding)
+  {
+      super();
+      mPrintWriter = pw;
+      characterEncoding = encoding;
+  }
+
+
+    /**
+     * Writes a single byte to the output stream
+     * This implementation writes the byte to the
+     * underlying PrintWriter.
+     */
+    public void write(int pVal) throws IOException
+    {
+        mPrintWriter.write(pVal);
+    }
+
+  /**
+   * Writes an array of bytes
+   * 
+   * @param pBuf the array to be written
+   * @exception IOException if an I/O error occurred
+   */
+  public void write(byte[] pBuf) throws IOException
+  {
+      this.write(pBuf, 0, pBuf.length);
+  }
+
+  /**
+   * Writes a subarray of bytes
+   * This implementation redirects it's input into the
+   * underlying PrintWriter.
+   * 
+   * @param pBuf the array to be written
+   * @param pOffset the offset into the array
+   * @param pLength the number of bytes to write
+   * @exception IOException if an I/O error occurred
+   */
+  public void write(byte[] pBuf, int pOffset, int pLength) throws IOException
+  {
+    String strValue = null;
+    if(characterEncoding != null && !"".equals(characterEncoding)) {
+        try {
+            strValue = new String(pBuf, pOffset, pLength, characterEncoding);
+        }
+        catch(UnsupportedEncodingException uee) {
+            // ignore and allow the null to handle.
+        }
+    }
+
+    if(strValue == null) {
+        strValue = new String(pBuf, pOffset, pLength);
+    }
+
+    mPrintWriter.write(strValue);
+  }
+
+  /**
+   * Flushes the stream, writing any buffered output bytes
+   *
+   * @exception IOException if an I/O error occurred
+   */
+  public void flush() throws IOException
+  {
+    mPrintWriter.flush();
+  }
+
+  /**
+   * Closes the stream
+   * 
+   * @exception IOException if an I/O error occurred
+   */
+  public void close() throws IOException
+  {
+    mPrintWriter.close();
+  }
+
+  /**
+   * 
+   * Prints a string.
+   * 
+   * @param pVal the String to be printed
+   * @exception IOException if an I/O error has occurred
+   */
+  public void print(String pVal) throws IOException
+  {
+    mPrintWriter.print(pVal);
+  }
+
+  /**
+   * 
+   * Prints an string followed by a CRLF.
+   * 
+   * @param pVal the String to be printed
+   * @exception IOException if an I/O error has occurred
+   */
+  public void println(String pVal) throws IOException
+  {
+    mPrintWriter.println(pVal);
+  }
+
+  /**
+   * 
+   * Prints a CRLF
+   * 
+   * @exception IOException if an I/O error has occurred
+   *  
+   */
+  public void println() throws IOException
+  {
+    mPrintWriter.println();
+  }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message