Asterisk-Java

org.asteriskjava.util
Class ReflectionUtil

java.lang.Object
  extended by org.asteriskjava.util.ReflectionUtil

public class ReflectionUtil
extends java.lang.Object

Utility class that provides helper methods for reflection that is used by the fastagi and manager packages to access getter and setter methods.

Client code is not supposed to use this class.

Author:
srt

Method Summary
static java.util.Map<java.lang.String,java.lang.reflect.Method> getGetters(java.lang.Class clazz)
          Returns a Map of getter methods of the given class.
static java.util.Map<java.lang.String,java.lang.reflect.Method> getSetters(java.lang.Class clazz)
          Returns a Map of setter methods of the given class.
static boolean isClassAvailable(java.lang.String s)
          Checks if the class is available on the current thread's context class loader.
static java.lang.Object newInstance(java.lang.String s)
          Creates a new instance of the given class.
static java.lang.String stripIllegalCharacters(java.lang.String s)
          Strips all illegal charaters from the given lower case string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGetters

public static java.util.Map<java.lang.String,java.lang.reflect.Method> getGetters(java.lang.Class clazz)
Returns a Map of getter methods of the given class.

The key of the map contains the name of the attribute that can be accessed by the getter, the value the getter itself (an instance of java.lang.reflect.Method). A method is considered a getter if its name starts with "get", it is declared public and takes no arguments.

Parameters:
clazz - the class to return the getters for
Returns:
a Map of attributes and their accessor methods (getters)

getSetters

public static java.util.Map<java.lang.String,java.lang.reflect.Method> getSetters(java.lang.Class clazz)
Returns a Map of setter methods of the given class.

The key of the map contains the name of the attribute that can be accessed by the setter, the value the setter itself (an instance of java.lang.reflect.Method). A method is considered a setter if its name starts with "set", it is declared public and takes exactly one argument.

Parameters:
clazz - the class to return the setters for
Returns:
a Map of attributes and their accessor methods (setters)

stripIllegalCharacters

public static java.lang.String stripIllegalCharacters(java.lang.String s)
Strips all illegal charaters from the given lower case string. Illegal characters are all characters that are neither characters ('a' to 'z') nor digits ('0' to '9').

Parameters:
s - the original string
Returns:
the string with all illegal characters stripped

isClassAvailable

public static boolean isClassAvailable(java.lang.String s)
Checks if the class is available on the current thread's context class loader.

Parameters:
s - fully qualified name of the class to check.
Returns:
true if the class is available, false otherwise.

newInstance

public static java.lang.Object newInstance(java.lang.String s)
Creates a new instance of the given class. The class is loaded using the current thread's context class loader and instantiated using its default constructor.

Parameters:
s - fully qualified name of the class to instantiate.
Returns:
the new instance or null on failure.

Asterisk-Java

Copyright © 2004-2009 Stefan Reuter. All Rights Reserved.