|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.directwebremoting.util.LocalUtil
public final class LocalUtil
Various utilities, stuff that we're still surprised isn't in the JDK, and stuff that perhaps is borderline JDK material, but isn't really pure DWR either.
| 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 browsers and proxies from caching this reply. |
|
static java.lang.Class<?> |
classForName(java.lang.String className)
Utility to essentially do Class forName and allow configurable Classloaders. |
|
static
|
classForName(java.lang.String debugContext,
java.lang.String className,
java.lang.Class<T> impl)
Utility to essentially do Class forName with the assumption that the environment expects failures for missing jar files and can carry on if this process fails. |
|
static
|
classNewInstance(java.lang.String name,
java.lang.String className,
java.lang.Class<T> impl)
Utility to essentially do Class forName and newInstance with the assumption that the environment expects failures for missing jar files and can carry on if this process fails. |
|
static void |
close(java.io.Closeable in)
InputStream closer that can cope if the input stream is null. |
|
static java.lang.String |
decode(java.lang.String value)
URL decode a value. |
|
static java.lang.reflect.Field[] |
getAllFields(java.lang.Class<?> clazz)
Return a list of all fields (whatever access status, and on whatever superclass they were defined) that can be found on this class. |
|
static java.util.List<java.lang.Class<?>> |
getAllSuperclasses(java.lang.Class<?> clazz)
Return a List of super-classes for the given class. |
|
static java.lang.Class<?> |
getNonPrimitiveType(java.lang.Class<?> type)
|
|
static java.lang.Object |
invoke(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] params)
Calling methods using reflection is useful for graceful fallback - this is a helper method to make this easy |
|
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 |
isJavaIdentifier(java.lang.String test)
Determines if the specified string is permissible as a Java identifier. |
|
static boolean |
isLetterOrDigitOrUnderline(java.lang.String test)
Determines if the specified string contains only Unicode letters or digits as defined by Character.isLetterOrDigit(char) |
|
static boolean |
isServletClass(java.lang.Class<?> paramType)
Is this class one that we auto fill, so the user can ignore? |
|
static boolean |
isSimpleName(java.lang.String name)
Is this object property one that we can use in a JSON style or do we need to get fancy. |
|
static boolean |
isTypeSimplyConvertable(java.lang.Class<?> paramType)
Can the type be used in a call to simpleConvert(String, Class)? |
|
static java.lang.String |
join(java.lang.Object[] array,
java.lang.String separator)
Create a string by joining the array elements together with the separator in-between each element. |
|
static void |
setParams(java.lang.Object object,
java.util.Map<java.lang.String,?> params,
java.util.List<java.lang.String> ignore)
Set use reflection to set the setters on the object called by the keys in the params map with the corresponding values |
|
static void |
setProperty(java.lang.Object object,
java.lang.String key,
java.lang.Object value)
Set a property on an object using reflection |
|
static
|
simpleConvert(java.lang.String value,
java.lang.Class<T> paramType)
A very simple conversion function for all the IoC style setup and reflection that we are doing. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int INBOUND_INDEX_TYPE
public static final int INBOUND_INDEX_VALUE
| Method Detail |
|---|
public static java.lang.String join(java.lang.Object[] array,
java.lang.String separator)
array - The array of elements to joinseparator - The string sequence to place between array elements
public static boolean isJavaIdentifier(java.lang.String test)
test - the string to be tested.
Character.isJavaIdentifierPart(char),
Character.isJavaIdentifierStart(char)public static boolean isLetterOrDigitOrUnderline(java.lang.String test)
Character.isLetterOrDigit(char)
test - The string to test
Character.isLetterOrDigit(char)
public static boolean isEquivalent(java.lang.Class<?> c1,
java.lang.Class<?> c2)
c1 - the first class to testc2 - the second class to test
public static java.lang.Class<?> getNonPrimitiveType(java.lang.Class<?> type)
type - The class to de-primitivize
public static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse resp)
resp - The response to add headers topublic static boolean isServletClass(java.lang.Class<?> paramType)
paramType - The type to test
public static java.lang.String decode(java.lang.String value)
URLDecoder.decode(String, String) throws an
UnsupportedEncodingException, which is silly given that the most
common use case will be to pass in "UTF-8"
value - The string to decode
public static void setParams(java.lang.Object object,
java.util.Map<java.lang.String,?> params,
java.util.List<java.lang.String> ignore)
object - The object to setupparams - The settings to useignore - List of keys to not warn about if they are not properties
Note only the warning is skipped, we still try the setter
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
object - The object to call the setter onkey - The name of the property to set.value - The new value to use for the property
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 codepublic static boolean isTypeSimplyConvertable(java.lang.Class<?> paramType)
simpleConvert(String, Class)?
paramType - The type to test
public static <T> T simpleConvert(java.lang.String value,
java.lang.Class<T> paramType)
value - The value to convertparamType - The type to convert to. Currently any primitive types and
String are supported.
public static boolean isSimpleName(java.lang.String name)
name - The name to test for JSON compatibility
public static java.lang.Class<?> classForName(java.lang.String className)
throws java.lang.ClassNotFoundException
The initial implementation makes use of the context classloader for the current thread.
className - The class to create
java.lang.ClassNotFoundException - If className is not valid
public static java.lang.Object invoke(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] params)
throws java.lang.IllegalStateException
object - The object to use as 'this'method - The method to call, can be null in which case null is returnedparams - The parameters to pass to the reflection call
java.lang.IllegalStateException - If anything goes wrong
public static <T> java.lang.Class<? extends T> classForName(java.lang.String debugContext,
java.lang.String className,
java.lang.Class<T> impl)
T - The base type that we want a class to implementdebugContext - The name for debugging purposesclassName - The class to createimpl - The implementation class - what should className do?
public static <T> T classNewInstance(java.lang.String name,
java.lang.String className,
java.lang.Class<T> impl)
T - The base type that we want a class to implementname - The name for debugging purposesclassName - The class to createimpl - The implementation class - what should className do?
public static void close(java.io.Closeable in)
in - The resource to closepublic static java.util.List<java.lang.Class<?>> getAllSuperclasses(java.lang.Class<?> clazz)
clazz - the class to look up
public static java.lang.reflect.Field[] getAllFields(java.lang.Class<?> clazz)
This is like a union of Class.getDeclaredFields() which
ignores and super-classes, and Class.getFields() which ignored
non-public fields
clazz - The class to introspect
|
Copyright ¬ 2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||