org.apache.sling.engine
Class RequestUtil

java.lang.Object
  extended by org.apache.sling.engine.RequestUtil

public class RequestUtil
extends java.lang.Object


Constructor Summary
RequestUtil()
           
 
Method Summary
static java.lang.String getServletName(javax.servlet.Servlet servlet)
          Utility method to return a name for the given servlet.
static java.util.Map<java.lang.String,java.lang.Double> parserAcceptHeader(java.lang.String value)
          Parses an Accept-* header of the form: Header = Token { "," Token } .
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parserHeader(java.lang.String value)
          Parses a header of the form: Header = Token { "," Token } .
static java.lang.Object setRequestAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.Object value)
          Sets the named request attribute to the new value and returns the previous value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestUtil

public RequestUtil()
Method Detail

parserHeader

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parserHeader(java.lang.String value)
Parses a header of the form:
            Header = Token { "," Token } .
            Token = name { ";" Parameter } .
            Paramter = name [ "=" value ] .
 
"," and ";" are not allowed within name and value

Parameters:
value -
Returns:
A Map indexed by the Token names where the values are Map instances indexed by parameter name

parserAcceptHeader

public static java.util.Map<java.lang.String,java.lang.Double> parserAcceptHeader(java.lang.String value)
Parses an Accept-* header of the form:
            Header = Token { "," Token } .
            Token = name { ";" "q" [ "=" value ] } .
            Paramter =  .
 
"," and ";" are not allowed within name and value

Parameters:
value -
Returns:
A Map indexed by the Token names where the values are Double instances providing the value of the q parameter.

getServletName

public static java.lang.String getServletName(javax.servlet.Servlet servlet)
Utility method to return a name for the given servlet. This method applies the following algorithm to find a non-null, non-empty name:
  1. If the servlet has a servlet config, the servlet name from the servlet config is taken.
  2. Otherwise check the servlet info
  3. Otherwise use the fully qualified name of the servlet class


setRequestAttribute

public static java.lang.Object setRequestAttribute(javax.servlet.http.HttpServletRequest request,
                                                   java.lang.String name,
                                                   java.lang.Object value)
Sets the named request attribute to the new value and returns the previous value.

Parameters:
request - The request object whose attribute is to be set.
name - The name of the attribute to be set.
value - The new value of the attribute. If this is null the attribte is actually removed from the request.
Returns:
The previous value of the named request attribute or null if it was not set.


Copyright © 2007-2009. All Rights Reserved.