uk.ltd.getahead.dwr.util
Class LocalUtil

java.lang.Object
  extended byuk.ltd.getahead.dwr.util.LocalUtil

public final class LocalUtil
extends java.lang.Object

Various utilities, mostly to make up for JDK 1.4 functionallity that is not in JDK 1.3

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
static int INBOUND_INDEX_TYPE
          splitInbound() returns the type info in this parameter
static int INBOUND_INDEX_VALUE
          splitInbound() returns the value info in this parameter
 
Method Summary
static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse resp)
          Add headers to prevent browers and proxies from caching this reply.
static java.lang.String decode(java.lang.String value)
          URL decode a value.
static java.lang.Class getNonPrimitiveType(java.lang.Class type)
           
static java.lang.String getShortClassName(java.lang.Class clazz)
          Get the short class name (i.e.
static boolean isEquivalent(java.lang.Class c1, java.lang.Class c2)
          True if c1 is java.lang.Boolean and c2 is boolean, etc.
static boolean isServletClass(java.lang.Class paramType)
          Is this class one that we auto fill, so the user can ignore?
static java.lang.String replace(java.lang.String text, java.lang.String repl, java.lang.String with)
          Replacement for String#replaceAll(String, String) in JDK 1.4+
static void setProperty(java.lang.Object object, java.lang.String key, java.lang.Object value)
          Set a property on an object using reflection
static java.lang.String[] splitInbound(java.lang.String data)
          The javascript outbound marshaller prefixes the toString value with a colon and the original type information.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INBOUND_INDEX_TYPE

public static final int INBOUND_INDEX_TYPE
splitInbound() returns the type info in this parameter

See Also:
Constant Field Values

INBOUND_INDEX_VALUE

public static final int INBOUND_INDEX_VALUE
splitInbound() returns the value info in this parameter

See Also:
Constant Field Values
Method Detail

replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String repl,
                                       java.lang.String with)
Replacement for String#replaceAll(String, String) in JDK 1.4+

Parameters:
text - source text
repl - the stuff to get rid of
with - the stuff to replace it with
Returns:
replaced text or null if any args are null

isEquivalent

public static boolean isEquivalent(java.lang.Class c1,
                                   java.lang.Class c2)
True if c1 is java.lang.Boolean and c2 is boolean, etc.

Parameters:
c1 - the first class to test
c2 - the second class to test
Returns:
true if the classes are equivalent

getNonPrimitiveType

public static java.lang.Class getNonPrimitiveType(java.lang.Class type)
Parameters:
type - The class to de-primitivize
Returns:
The non-privitive version of the class

addNoCacheHeaders

public static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse resp)
Add headers to prevent browers and proxies from caching this reply.

Parameters:
resp - The response to add headers to

isServletClass

public static boolean isServletClass(java.lang.Class paramType)
Is this class one that we auto fill, so the user can ignore?

Parameters:
paramType - The type to test
Returns:
true if the type is a Servlet type

decode

public static java.lang.String decode(java.lang.String value)
URL decode a value. This method gets around the lack of a decode(String, String) method in JDK 1.3.

Parameters:
value - The string to decode
Returns:
The decoded string

setProperty

public static void setProperty(java.lang.Object object,
                               java.lang.String key,
                               java.lang.Object value)
                        throws java.lang.NoSuchMethodException,
                               java.lang.SecurityException,
                               java.lang.IllegalAccessException,
                               java.lang.IllegalArgumentException,
                               java.lang.reflect.InvocationTargetException
Set a property on an object using reflection

Parameters:
object - The object to call the setter on
key - The name of the property to set.
value - The new value to use for the property
Throws:
java.lang.NoSuchMethodException - Passed on from reflection code
java.lang.SecurityException - Passed on from reflection code
java.lang.IllegalAccessException - Passed on from reflection code
java.lang.IllegalArgumentException - Passed on from reflection code
java.lang.reflect.InvocationTargetException - Passed on from reflection code

splitInbound

public static java.lang.String[] splitInbound(java.lang.String data)
The javascript outbound marshaller prefixes the toString value with a colon and the original type information. This undoes that.

Parameters:
data - The string to be split up
Returns:
A string array containing the split data

getShortClassName

public static java.lang.String getShortClassName(java.lang.Class clazz)
Get the short class name (i.e. without the package part)

Parameters:
clazz - the class to get the short name of
Returns:
the class name of the class without the package name

Copyright ? 2005