play.utils
Class Java

java.lang.Object
  extended by play.utils.Java

public class Java
extends Object

Java utils


Nested Class Summary
static class Java.FieldWrapper
          Field accessor set and get value for a property, using the getter/setter when it exists or direct access otherwise.
 
Constructor Summary
Java()
           
 
Method Summary
static Object deserialize(byte[] b)
           
static Object extractUnderlyingCallable(FutureTask<?> futureTask)
          Try to discover what is hidden under a FutureTask (hack)
static Method findActionMethod(String name, Class<?> clazz)
          Find the first public static method of a controller class
static List<Method> findAllAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType)
          Find all annotated method from a class
static void findAllFields(Class<?> clazz, Set<Field> found)
           
static Java.FieldWrapper getFieldWrapper(Field field)
           
static Object invokeStatic(Class<?> clazz, String method)
          Invoke a static method
static Object invokeStatic(Class<?> clazz, String method, Object... args)
          Invoke a static method with args
static Object invokeStatic(Method method, Map<String,String[]> args)
           
static Object invokeStatic(Method method, Object[] args)
           
static Object invokeStaticOrParent(Class<?> clazz, String method, Object... args)
           
static String[] parameterNames(Method method)
          Retrieve parameter names of a method
static String rawJavaType(Class<?> clazz)
           
static String rawMethodSignature(Method method)
           
static byte[] serialize(Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Java

public Java()
Method Detail

extractUnderlyingCallable

public static Object extractUnderlyingCallable(FutureTask<?> futureTask)
Try to discover what is hidden under a FutureTask (hack)


findActionMethod

public static Method findActionMethod(String name,
                                      Class<?> clazz)
Find the first public static method of a controller class

Parameters:
name - The method name
clazz - The class
Returns:
The method or null

invokeStatic

public static Object invokeStatic(Class<?> clazz,
                                  String method)
                           throws Exception
Invoke a static method

Parameters:
clazz - The class
method - The method name
Returns:
The result
Throws:
Exception

invokeStatic

public static Object invokeStatic(Class<?> clazz,
                                  String method,
                                  Object... args)
                           throws Exception
Invoke a static method with args

Parameters:
clazz - The class
method - The method name
args - Arguments
Returns:
The result
Throws:
Exception

invokeStaticOrParent

public static Object invokeStaticOrParent(Class<?> clazz,
                                          String method,
                                          Object... args)
                                   throws Exception
Throws:
Exception

invokeStatic

public static Object invokeStatic(Method method,
                                  Map<String,String[]> args)
                           throws Exception
Throws:
Exception

invokeStatic

public static Object invokeStatic(Method method,
                                  Object[] args)
                           throws Exception
Throws:
Exception

parameterNames

public static String[] parameterNames(Method method)
                               throws Exception
Retrieve parameter names of a method

Throws:
Exception

rawMethodSignature

public static String rawMethodSignature(Method method)

rawJavaType

public static String rawJavaType(Class<?> clazz)

findAllAnnotatedMethods

public static List<Method> findAllAnnotatedMethods(Class<?> clazz,
                                                   Class<? extends Annotation> annotationType)
Find all annotated method from a class

Parameters:
clazz - The class
annotationType - The annotation class
Returns:
A list of method object

findAllFields

public static void findAllFields(Class<?> clazz,
                                 Set<Field> found)

getFieldWrapper

public static Java.FieldWrapper getFieldWrapper(Field field)

serialize

public static byte[] serialize(Object o)
                        throws Exception
Throws:
Exception

deserialize

public static Object deserialize(byte[] b)
                          throws Exception
Throws:
Exception


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly