| java.lang.Object org.directwebremoting.util.LocalUtil
LocalUtil | final public class LocalUtil (Code) | | 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.
author: Joe Walker [joe at getahead dot ltd dot uk] |
Method Summary | |
public static void | addNoCacheHeaders(HttpServletResponse resp) Add headers to prevent browsers and proxies from caching this reply. | public static Class> | classForName(String className) Utility to essentially do Class forName and allow configurable
Classloaders. | public static Class<? extends T> | classForName(String debugContext, String className, 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. | public static T | classNewInstance(String name, String className, 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. | public static void | close(Closeable in) InputStream closer that can cope if the input stream is null. | public static String | decode(String value) URL decode a value. | public static Field[] | getAllFields(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. | public static List<Class<?>> | getAllSuperclasses(Class> clazz) Return a List of super-classes for the given class. | public static Class> | getNonPrimitiveType(Class> type) | public static Object | invoke(Object object, Method method, Object[] params) | public static boolean | isEquivalent(Class> c1, Class> c2) True if c1 is java.lang.Boolean and c2 is boolean, etc. | public static boolean | isJavaIdentifier(String test) Determines if the specified string is permissible as a Java identifier.
Returns true if the string is non-null, non-zero length with a Java
identifier start as the first character and Java identifier parts in all
remaining characters.
Parameters: test - the string to be tested. | public static boolean | isLetterOrDigitOrUnderline(String test) | public static boolean | isServletClass(Class> paramType) | public static boolean | isSimpleName(String name) Is this object property one that we can use in a JSON style or do we need
to get fancy. | public static boolean | isTypeSimplyConvertable(Class> paramType) | public static String | join(Object[] array, String separator) Create a string by joining the array elements together with the separator
in-between each element. | public static void | setParams(Object object, Map<String, ?> params, List<String> ignore) | public static void | setProperty(Object object, String key, Object value) | public static T | simpleConvert(String value, Class<T> paramType) A very simple conversion function for all the IoC style setup and
reflection that we are doing.
Parameters: value - The value to convert Parameters: paramType - The type to convert to. |
INBOUND_INDEX_TYPE | final public static int INBOUND_INDEX_TYPE(Code) | | splitInbound() returns the type info in this parameter
|
INBOUND_INDEX_VALUE | final public static int INBOUND_INDEX_VALUE(Code) | | splitInbound() returns the value info in this parameter
|
addNoCacheHeaders | public static void addNoCacheHeaders(HttpServletResponse resp)(Code) | | Add headers to prevent browsers and proxies from caching this reply.
Parameters: resp - The response to add headers to |
classForName | public static Class> classForName(String className) throws ClassNotFoundException(Code) | | Utility to essentially do Class forName and allow configurable
Classloaders.
The initial implementation makes use of the context classloader for
the current thread.
Parameters: className - The class to create The class if it is safe or null otherwise. throws: ClassNotFoundException - If className is not valid |
classForName | public static Class<? extends T> classForName(String debugContext, String className, Class<T> impl)(Code) | | 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.
< Parameters: T - > The base type that we want a class to implement Parameters: debugContext - The name for debugging purposes Parameters: className - The class to create Parameters: impl - The implementation class - what should className do? The class if it is safe or null otherwise. |
classNewInstance | public static T classNewInstance(String name, String className, Class<T> impl)(Code) | | 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.
< Parameters: T - > The base type that we want a class to implement Parameters: name - The name for debugging purposes Parameters: className - The class to create Parameters: impl - The implementation class - what should className do? The new instance if it is safe or null otherwise. |
close | public static void close(Closeable in)(Code) | | InputStream closer that can cope if the input stream is null.
If anything goes wrong, the errors are logged and ignored.
Parameters: in - The resource to close |
getAllFields | public static Field[] getAllFields(Class> clazz)(Code) | | Return a list of all fields (whatever access status, and on whatever
superclass they were defined) that can be found on this class.
This is like a union of
Class.getDeclaredFields which
ignores and super-classes, and
Class.getFields which ignored
non-public fields
Parameters: clazz - The class to introspect The complete list of fields |
getAllSuperclasses | public static List<Class<?>> getAllSuperclasses(Class> clazz)(Code) | | Return a List of super-classes for the given class.
Parameters: clazz - the class to look up the List of super-classes in order going up from this one |
getNonPrimitiveType | public static Class> getNonPrimitiveType(Class> type)(Code) | | Parameters: type - The class to de-primitivize The non-primitive version of the class |
invoke | public static Object invoke(Object object, Method method, Object[] params) throws IllegalStateException(Code) | | Calling methods using reflection is useful for graceful fallback - this
is a helper method to make this easy
Parameters: object - The object to use as 'this' Parameters: method - The method to call, can be null in which case null is returned Parameters: params - The parameters to pass to the reflection call The results of calling method.invoke() or null throws: IllegalStateException - If anything goes wrong |
isEquivalent | public static boolean isEquivalent(Class> c1, Class> c2)(Code) | | True if c1 is java.lang.Boolean and c2 is boolean, etc.
Parameters: c1 - the first class to test Parameters: c2 - the second class to test true if the classes are equivalent |
isLetterOrDigitOrUnderline | public static boolean isLetterOrDigitOrUnderline(String test)(Code) | | Determines if the specified string contains only Unicode letters or
digits as defined by
Character.isLetterOrDigit(char) Parameters: test - The string to test true if the string is non-null, non-empty and contains onlycharacters that are unicode letters or digits See Also: Character.isLetterOrDigit(char) |
isServletClass | public static boolean isServletClass(Class> paramType)(Code) | | Is this class one that we auto fill, so the user can ignore?
Parameters: paramType - The type to test true if the type is a Servlet type |
isSimpleName | public static boolean isSimpleName(String name)(Code) | | Is this object property one that we can use in a JSON style or do we need
to get fancy. i.e does it contain only letters and numbers with an
initial letter.
Parameters: name - The name to test for JSON compatibility true if the name is simple |
isTypeSimplyConvertable | public static boolean isTypeSimplyConvertable(Class> paramType)(Code) | | Can the type be used in a call to
LocalUtil.simpleConvert(String,Class) ?
Parameters: paramType - The type to test true if the type is acceptable to simpleConvert() |
join | public static String join(Object[] array, String separator)(Code) | | Create a string by joining the array elements together with the separator
in-between each element. A null (in the array or as a separator) is
treated as an empty string.
Parameters: array - The array of elements to join Parameters: separator - The string sequence to place between array elements A string containing the joined elements |
setParams | public static void setParams(Object object, Map<String, ?> params, List<String> ignore)(Code) | | Set use reflection to set the setters on the object called by the keys
in the params map with the corresponding values
Parameters: object - The object to setup Parameters: params - The settings to use Parameters: ignore - List of keys to not warn about if they are not propertiesNote only the warning is skipped, we still try the setter |
simpleConvert | public static T simpleConvert(String value, Class<T> paramType)(Code) | | A very simple conversion function for all the IoC style setup and
reflection that we are doing.
Parameters: value - The value to convert Parameters: paramType - The type to convert to. Currently any primitive types andString are supported. The converted object. |
|
|