Cocoon API: Class Utils

org.apache.cocoon
Class Utils

java.lang.Object
  |
  +--org.apache.cocoon.Utils

public final class Utils
extends java.lang.Object

Utility methods for Cocoon and its classes.

Version:
$Revision: 1.23 $ $Date: 2001/01/19 00:23:48 $
Author:
Stefano Mazzocchi, Robin Green

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String encode(javax.servlet.http.HttpServletRequest req)
          Encodes the given request into a string using the format protocol://serverName:serverPort/requestURI?query
static java.lang.String encode(javax.servlet.http.HttpServletRequest req, boolean agent)
          Encodes the given request into a string using the format userAgent:method:protocol://serverName:serverPort/requestURI?query with the agent flag controlling the presence of the userAgent field.
static java.lang.String encode(javax.servlet.http.HttpServletRequest req, boolean agent, boolean query)
          Encodes the given request into a string using the format userAgent:method:protocol://serverName:serverPort/requestURI?query with the agent flag controlling the presence of the userAgent field and the query flag controlling the query field.
static java.util.Vector getAllPIs(org.w3c.dom.Document document, java.lang.String name)
          This method returns a vector of PI nodes based on the PI target name.
static java.util.Vector getAllPIs(org.w3c.dom.Document document, java.lang.String name, boolean remove)
          This method returns a vector of PI nodes based on the PI target name and removes the found PIs from the document if the remove flag is true.
static java.lang.String getBasename(javax.servlet.http.HttpServletRequest request, java.lang.Object context)
          XXX: This is a dirty hack.
static java.lang.String getBasepath(javax.servlet.http.HttpServletRequest request, java.lang.Object context)
           
static byte[] getBytes(java.lang.String s, java.lang.String encoding)
           
static org.w3c.dom.ProcessingInstruction getFirstPI(org.w3c.dom.Document document, java.lang.String name)
          This method returns the first PI node based on the PI target name.
static org.w3c.dom.ProcessingInstruction getFirstPI(org.w3c.dom.Document document, java.lang.String name, boolean remove)
          This method returns the first PI node based on the PI target name and removes it from the document if the remove flag is true.
static java.lang.Object getLocationResource(java.lang.String location)
           
static java.lang.Object getLocationResource(java.lang.String location, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context)
           
static java.util.Hashtable getPIPseudoAttributes(org.w3c.dom.Document document, java.lang.String name)
          This method returns an hashtable with all the pseudo attributes collected in the document.
static java.util.Hashtable getPIPseudoAttributes(org.w3c.dom.ProcessingInstruction pi)
          This method returns an hashtable of pseudo attributes found in the first occurrence of the PI with the given name in the given document.
static java.lang.String getRootpath(javax.servlet.http.HttpServletRequest request, java.lang.Object context)
           
static java.lang.String getStackTraceAsString(java.lang.Throwable e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getBytes

public static byte[] getBytes(java.lang.String s,
                              java.lang.String encoding)
                       throws java.io.UnsupportedEncodingException

getAllPIs

public static final java.util.Vector getAllPIs(org.w3c.dom.Document document,
                                               java.lang.String name)
This method returns a vector of PI nodes based on the PI target name.

getAllPIs

public static final java.util.Vector getAllPIs(org.w3c.dom.Document document,
                                               java.lang.String name,
                                               boolean remove)
This method returns a vector of PI nodes based on the PI target name and removes the found PIs from the document if the remove flag is true.

getFirstPI

public static final org.w3c.dom.ProcessingInstruction getFirstPI(org.w3c.dom.Document document,
                                                                 java.lang.String name)
This method returns the first PI node based on the PI target name.

getFirstPI

public static final org.w3c.dom.ProcessingInstruction getFirstPI(org.w3c.dom.Document document,
                                                                 java.lang.String name,
                                                                 boolean remove)
This method returns the first PI node based on the PI target name and removes it from the document if the remove flag is true.

getPIPseudoAttributes

public static final java.util.Hashtable getPIPseudoAttributes(org.w3c.dom.Document document,
                                                              java.lang.String name)
This method returns an hashtable with all the pseudo attributes collected in the document. If more PI have the same target, the attributes are all put in the same hashtable. If there are collisions, the last attribute is insered.

getPIPseudoAttributes

public static final java.util.Hashtable getPIPseudoAttributes(org.w3c.dom.ProcessingInstruction pi)
This method returns an hashtable of pseudo attributes found in the first occurrence of the PI with the given name in the given document. No validation is performed on the PI pseudo syntax

encode

public static final java.lang.String encode(javax.servlet.http.HttpServletRequest req)
Encodes the given request into a string using the format protocol://serverName:serverPort/requestURI?query

encode

public static final java.lang.String encode(javax.servlet.http.HttpServletRequest req,
                                            boolean agent)
Encodes the given request into a string using the format userAgent:method:protocol://serverName:serverPort/requestURI?query with the agent flag controlling the presence of the userAgent field.

encode

public static final java.lang.String encode(javax.servlet.http.HttpServletRequest req,
                                            boolean agent,
                                            boolean query)
Encodes the given request into a string using the format userAgent:method:protocol://serverName:serverPort/requestURI?query with the agent flag controlling the presence of the userAgent field and the query flag controlling the query field.

getBasename

public static final java.lang.String getBasename(javax.servlet.http.HttpServletRequest request,
                                                 java.lang.Object context)
XXX: This is a dirty hack. The worst piece of code I ever wrote and it clearly shows how Cocoon must change to support the Servlet API 2.2 which has _much_ better mapping support thru the use of "getResource()" but then, all the file system abstraction should be URL based. So, for now, leave the dirty code even if totally deprecated and work out a better solution in the future.

getBasepath

public static final java.lang.String getBasepath(javax.servlet.http.HttpServletRequest request,
                                                 java.lang.Object context)

getRootpath

public static final java.lang.String getRootpath(javax.servlet.http.HttpServletRequest request,
                                                 java.lang.Object context)

getStackTraceAsString

public static final java.lang.String getStackTraceAsString(java.lang.Throwable e)

getLocationResource

public static final java.lang.Object getLocationResource(java.lang.String location)
                                                  throws java.net.MalformedURLException

getLocationResource

public static final java.lang.Object getLocationResource(java.lang.String location,
                                                         javax.servlet.http.HttpServletRequest request,
                                                         javax.servlet.ServletContext context)
                                                  throws java.lang.Exception


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.