Java Doc for ClassUtils.java in  » Database-ORM » JPOX » org » jpox » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » JPOX » org.jpox.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jpox.util.ClassUtils

ClassUtils
public class ClassUtils (Code)
Utilities for handling classes. These are to supplement the methods provided by the Class object.
version:
   $Revision: 1.56 $


Field Summary
final protected static  LocaliserLOCALISER
    
protected static  MapconstructorsCache
    


Method Summary
public static  BooleanbooleanValueOf(boolean value)
     Utility to perform the same function as the JDK 1.4 method Boolean.valueOf(boolean), so we have no real dependency on JDK 1.4.
public static  booleanclassesAreDescendents(ClassLoaderResolver clr, String class_name_1, String class_name_2)
     Method to check if 2 classes are direct descendents.
public static  ObjectconvertValue(Object value, Class cls)
     Convenience method to convert the passed value to an object of the specified type (if possible). If no such conversion is supported will return null.
public static  StringcreateFullClassName(String pkg_name, String cls_name)
     Utility to create the full class name given the package and class name. Some examples
 packageName=test className=Test, returns result=test.Test
 packageName=test className=test1.Test, returns result=test1.Test
 packageName=<null> className=Test, returns result=Test
 packageName=<null> className=test1.Test, returns result=test1.Test
 

Parameters:
  pkg_name - package name.
Parameters:
  cls_name - class name.
public static  voiddumpClassInformation(Class cls)
     Utility to use Reflection to dump out the details of a class. Will list all superclasses, interfaces, methods and fields. Can be used, for example, in checking the methods adding by the enhancement process.
public static  CollectiongetClassFilesForDirectory(File dir, boolean normal_classes, boolean inner_classes)
     Method to return the class files below the specified directory.
public static  StringgetClassNameForClass(Class cls)
     Utility to return the class name without the package name for a class.
public static  StringgetClassNameForFileURL(URL fileURL)
     Utility to find the class name of a class given the absolute file name of its class file.
public static  String[]getClassNamesForJarFile(String jarFileName)
     Convenience accessor for the names of all class files in the jar file with the specified name.
public static  String[]getClassNamesForJarFile(URL jarFileURL)
     Convenience accessor for the names of all class files in the jar file with the specified URL.
public static  StringgetClassnameForFilename(String filename, String rootfilename)
     Utility to get the Class name given the file name and the file name of the root of the package structure.
public static  StringgetCollectionElementType(Field field)
     Convenience method to extract the element type of a collection when using JDK1.5 generics given the input field.
public static  StringgetCollectionElementType(Class type, Type genericType)
     Convenience method to extract the element type of a collection when using JDK1.5 generics given the input field.
public static  StringgetCollectionElementType(Method method)
     Convenience method to extract the element type of a collection when using JDK1.5 generics, given the input method (getter).
public static  ConstructorgetConstructorWithArguments(Class cls, Class[] types)
     Convenience method to return the constructor of the passed class that accepts the supplied argument types.
public static  FieldgetFieldForClass(Class cls, String fieldName)
     Obtain a field from a class or superclasses using reflection.
public static  StringgetFieldNameForJavaBeanGetter(String methodName)
    
public static  StringgetFieldNameForJavaBeanSetter(String methodName)
    
public static  StringgetJavaBeanGetterName(String fieldName, boolean isBoolean)
    
public static  StringgetJavaBeanSetterName(String fieldName)
    
public static  StringgetJavaLangClassForType(String type)
     Convenience method to return the passed type as a java.lang type wherever possible. The passed type will be stripped of any package name and will be checked if it is a known java.lang class.
public static  StringgetMapKeyType(Field field)
     Convenience method to extract the key type of a map when using JDK1.5 generics given the input field.
public static  StringgetMapKeyType(Class type, Type genericType)
     Convenience method to extract the key type of a map when using JDK1.5 generics given the input field.
public static  StringgetMapKeyType(Method method)
     Convenience method to extract the key type of a map when using JDK1.5 generics given the input method.
public static  StringgetMapValueType(Field field)
    
public static  StringgetMapValueType(Class type, Type genericType)
    
public static  StringgetMapValueType(Method method)
     Convenience method to extract the value type of a map when using JDK1.5 generics given the input method.
public static  MethodgetMethodForClass(Class cls, String methodName, Class[] argtypes)
    
public static  MethodgetMethodWithArgument(Class cls, String methodName, Class argType)
     Obtain a method from a class or superclasses using reflection.
public static  intgetModifiersForFieldOfClass(ClassLoaderResolver clr, String className, String fieldName)
     Convenience accessor for the modifiers of a field in a class.
public static  String[]getPackageJdoFilesForJarFile(String jarFileName)
     Convenience accessor for the names of all "package.jdo" files in the jar file with the specified name.
public static  String[]getPackageJdoFilesForJarFile(URL jarFileURL)
     Convenience accessor for the names of all "package.jdo" files in the jar file with the specified URL.
public static  StringgetPackageNameForClass(Class cls)
     Utility to return the package name for a class.
public static  ClassgetPrimitiveTypeForType(Class type)
     Method to return the primitive equivalent of the specified type (if any).
public static  CollectiongetSuperclasses(Class the_class)
     Method to return the superclasses for a class.
public static  CollectiongetSuperinterfaces(Class the_class)
     Method to return the superinterfaces for a class.
public static  String[]getUnsupportedClassNames(TypeManager typeMgr, String[] classNames)
     Convenience method to filter out any supported classes from a list.
public static  ClassgetWrapperTypeForPrimitiveType(Class type)
     Convenience method to return the object wrapper type for a primitive type.
public static  StringgetWrapperTypeNameForPrimitiveTypeName(String typeName)
     Convenience method to return the object wrapper type for a primitive type name.
public static  booleanhasDefaultConstructor(Class the_class)
     Method to check for a default constructor on a class. Particular relevance for JDO is the requirement for a default constructor on all Persistence-Capable classes.
public static  booleanisInnerClass(String class_name)
     Method to check whether a classname is for an inner class.
public static  booleanisPrimitiveArrayType(String typeName)
     Convenience method to return if the passed type (name) is a primitive array type.
public static  booleanisPrimitiveType(String typeName)
     Convenience method to return if the passed type (name) is a primitive type.
public static  booleanisPrimitiveWrapperType(String typeName)
     Convenience method to return if the passed type (name) is a primitive wrapper type.
public static  ObjectnewInstance(Class type, Class[] parameterTypes, Object[] parameters)
     Accessor for a new instance of an object.
public static  booleantypesAreCompatible(Class cls1, String clsName2, ClassLoaderResolver clr)
     Convenience method to return if two types are compatible.
public static  booleantypesAreCompatible(Class cls1, Class cls2)
     Convenience method to return if two types are compatible.

Field Detail
LOCALISER
final protected static Localiser LOCALISER(Code)
Localisation utility for output messages



constructorsCache
protected static Map constructorsCache(Code)
caching for constructors - using caching, the perf is at least doubled *





Method Detail
booleanValueOf
public static Boolean booleanValueOf(boolean value)(Code)
Utility to perform the same function as the JDK 1.4 method Boolean.valueOf(boolean), so we have no real dependency on JDK 1.4. Please remove when our minimum requirement is JDK1.4 or above.
Parameters:
  value - The value The Boolean value



classesAreDescendents
public static boolean classesAreDescendents(ClassLoaderResolver clr, String class_name_1, String class_name_2)(Code)
Method to check if 2 classes are direct descendents. So one of them is a superclass of the other.
Parameters:
  clr - ClassLoaderResolver for loading the classes
Parameters:
  class_name_1 - Name of first class
Parameters:
  class_name_2 - Name of second class Whether they are direct descendents.



convertValue
public static Object convertValue(Object value, Class cls)(Code)
Convenience method to convert the passed value to an object of the specified type (if possible). If no such conversion is supported will return null. If the required type is a primitive will return an object of the wrapper type.
Parameters:
  value - The value
Parameters:
  cls - The class The converted value (or null)



createFullClassName
public static String createFullClassName(String pkg_name, String cls_name)(Code)
Utility to create the full class name given the package and class name. Some examples
 packageName=test className=Test, returns result=test.Test
 packageName=test className=test1.Test, returns result=test1.Test
 packageName=<null> className=Test, returns result=Test
 packageName=<null> className=test1.Test, returns result=test1.Test
 

Parameters:
  pkg_name - package name.
Parameters:
  cls_name - class name. generated full class name.



dumpClassInformation
public static void dumpClassInformation(Class cls)(Code)
Utility to use Reflection to dump out the details of a class. Will list all superclasses, interfaces, methods and fields. Can be used, for example, in checking the methods adding by the enhancement process. The information is dumped out the JPOX GENERAL log.
Parameters:
  cls - The class to dump out to the log



getClassFilesForDirectory
public static Collection getClassFilesForDirectory(File dir, boolean normal_classes, boolean inner_classes)(Code)
Method to return the class files below the specified directory.
Parameters:
  dir - The directory
Parameters:
  normal_classes - Whether to include normal classes
Parameters:
  inner_classes - Whether to include inner classes The class files (Collection of File objects).



getClassNameForClass
public static String getClassNameForClass(Class cls)(Code)
Utility to return the class name without the package name for a class.
Parameters:
  cls - The class The name of the class without its package



getClassNameForFileURL
public static String getClassNameForFileURL(URL fileURL) throws ClassNotFoundException(Code)
Utility to find the class name of a class given the absolute file name of its class file. Creates a loader and loads the class directly to find it.
Parameters:
  fileURL - URL for the class file The name of the class
throws:
  ClassNotFoundException - Thrown when the file is not found



getClassNamesForJarFile
public static String[] getClassNamesForJarFile(String jarFileName)(Code)
Convenience accessor for the names of all class files in the jar file with the specified name. The returned class names are of the form "org.jpox.MyClass".
Parameters:
  jarFileName - Name of the jar file The class names



getClassNamesForJarFile
public static String[] getClassNamesForJarFile(URL jarFileURL)(Code)
Convenience accessor for the names of all class files in the jar file with the specified URL. The returned class names are of the form "org.jpox.MyClass".
Parameters:
  jarFileURL - URL for the jar file The class names



getClassnameForFilename
public static String getClassnameForFilename(String filename, String rootfilename)(Code)
Utility to get the Class name given the file name and the file name of the root of the package structure.
Parameters:
  filename - The filename of the class file
Parameters:
  rootfilename - The filename of the root of the package structure The Class name



getCollectionElementType
public static String getCollectionElementType(Field field)(Code)
Convenience method to extract the element type of a collection when using JDK1.5 generics given the input field.
Parameters:
  field - The field The name of the element class



getCollectionElementType
public static String getCollectionElementType(Class type, Type genericType)(Code)
Convenience method to extract the element type of a collection when using JDK1.5 generics given the input field.
Parameters:
  type - the field type
Parameters:
  genericType - the generic type The name of the element class



getCollectionElementType
public static String getCollectionElementType(Method method)(Code)
Convenience method to extract the element type of a collection when using JDK1.5 generics, given the input method (getter).
Parameters:
  method - The method The name of the element class



getConstructorWithArguments
public static Constructor getConstructorWithArguments(Class cls, Class[] types)(Code)
Convenience method to return the constructor of the passed class that accepts the supplied argument types. Allows for primitive to primitive wrapper conversion. Typically used by the JDOQL ResultClass mapping process.
Parameters:
  cls - The class
Parameters:
  types - The constructor argument types The constructor



getFieldForClass
public static Field getFieldForClass(Class cls, String fieldName)(Code)
Obtain a field from a class or superclasses using reflection.
Parameters:
  cls - the class to find the field from
Parameters:
  fieldName - the field name to find The Field



getFieldNameForJavaBeanGetter
public static String getFieldNameForJavaBeanGetter(String methodName)(Code)
Generate a field name for JavaBeans compatible getter method
Parameters:
  methodName - the method name the field name



getFieldNameForJavaBeanSetter
public static String getFieldNameForJavaBeanSetter(String methodName)(Code)
Generate a field name for JavaBeans compatible setter method
Parameters:
  methodName - the method name the field name



getJavaBeanGetterName
public static String getJavaBeanGetterName(String fieldName, boolean isBoolean)(Code)
Generate a JavaBeans compatible getter name
Parameters:
  fieldName - the field name
Parameters:
  isBoolean - whether the field is primitive boolean type the getter name



getJavaBeanSetterName
public static String getJavaBeanSetterName(String fieldName)(Code)
Generate a JavaBeans compatible setter name
Parameters:
  fieldName - the field name the setter name



getJavaLangClassForType
public static String getJavaLangClassForType(String type)(Code)
Convenience method to return the passed type as a java.lang type wherever possible. The passed type will be stripped of any package name and will be checked if it is a known java.lang class. This is used where the user has specified a class name for a collection or map element/key/value type and meant a java.lang class but didn't fully qualify it.
Parameters:
  type - The type name The java.lang equivalent (or the input type if not possible)



getMapKeyType
public static String getMapKeyType(Field field)(Code)
Convenience method to extract the key type of a map when using JDK1.5 generics given the input field.
Parameters:
  field - The field The name of the key class



getMapKeyType
public static String getMapKeyType(Class type, Type genericType)(Code)
Convenience method to extract the key type of a map when using JDK1.5 generics given the input field.
Parameters:
  type - the field type
Parameters:
  genericType - the generic type The name of the key class



getMapKeyType
public static String getMapKeyType(Method method)(Code)
Convenience method to extract the key type of a map when using JDK1.5 generics given the input method.
Parameters:
  method - The method The name of the key class



getMapValueType
public static String getMapValueType(Field field)(Code)
Convenience method to extract the value type of a map when using JDK1.5 generics given the input field
Parameters:
  field - The field The name of the value class



getMapValueType
public static String getMapValueType(Class type, Type genericType)(Code)
Convenience method to extract the value type of a map when using JDK1.5 generics given the input field
Parameters:
  type - the field type
Parameters:
  genericType - the generic type The name of the value class



getMapValueType
public static String getMapValueType(Method method)(Code)
Convenience method to extract the value type of a map when using JDK1.5 generics given the input method.
Parameters:
  method - The method The name of the value class



getMethodForClass
public static Method getMethodForClass(Class cls, String methodName, Class[] argtypes)(Code)
Obtain a method from a class or superclasses using reflection
Parameters:
  cls - the class where to look for the method
Parameters:
  methodName - the method name to find
Parameters:
  argtypes - the classes argument of the method The Method



getMethodWithArgument
public static Method getMethodWithArgument(Class cls, String methodName, Class argType)(Code)
Obtain a method from a class or superclasses using reflection. The method will have the specified name and will take a single argument. Allows for the argument type being primitive or its associated wrapper.
Parameters:
  cls - the class to find the declared fields and populate the map
Parameters:
  methodName - the method name to find
Parameters:
  argType - the argument type



getModifiersForFieldOfClass
public static int getModifiersForFieldOfClass(ClassLoaderResolver clr, String className, String fieldName)(Code)
Convenience accessor for the modifiers of a field in a class.
Parameters:
  clr - ClassLoader resolver
Parameters:
  className - Name of the class
Parameters:
  fieldName - Name of the field The modifiers



getPackageJdoFilesForJarFile
public static String[] getPackageJdoFilesForJarFile(String jarFileName)(Code)
Convenience accessor for the names of all "package.jdo" files in the jar file with the specified name.
Parameters:
  jarFileName - Name of the jar file The "package.jdo" file names



getPackageJdoFilesForJarFile
public static String[] getPackageJdoFilesForJarFile(URL jarFileURL)(Code)
Convenience accessor for the names of all "package.jdo" files in the jar file with the specified URL.
Parameters:
  jarFileURL - URL for the jar file The "package.jdo" file names



getPackageNameForClass
public static String getPackageNameForClass(Class cls)(Code)
Utility to return the package name for a class. Allows for the result of class.getPackage() being null.
Parameters:
  cls - The class The name of its package (or null if no package e.g a primitive)



getPrimitiveTypeForType
public static Class getPrimitiveTypeForType(Class type)(Code)
Method to return the primitive equivalent of the specified type (if any). Returns null if there is no primitive equivalent.
Parameters:
  type - The type The primitive equivalent.



getSuperclasses
public static Collection getSuperclasses(Class the_class)(Code)
Method to return the superclasses for a class. The superclasses will be ordered.
Parameters:
  the_class - The class The superclass of this class.



getSuperinterfaces
public static Collection getSuperinterfaces(Class the_class)(Code)
Method to return the superinterfaces for a class. The superinterfaces will be ordered.
Parameters:
  the_class - The class The superinterfaces of this class.



getUnsupportedClassNames
public static String[] getUnsupportedClassNames(TypeManager typeMgr, String[] classNames)(Code)
Convenience method to filter out any supported classes from a list.
Parameters:
  typeMgr - TypeManager defining the types supported
Parameters:
  classNames - Names of the classes Names of the classes (omitting supported types)



getWrapperTypeForPrimitiveType
public static Class getWrapperTypeForPrimitiveType(Class type)(Code)
Convenience method to return the object wrapper type for a primitive type.
Parameters:
  type - The primitive type The object wrapper type for this primitive



getWrapperTypeNameForPrimitiveTypeName
public static String getWrapperTypeNameForPrimitiveTypeName(String typeName)(Code)
Convenience method to return the object wrapper type for a primitive type name. If the type is not a primitive then just returns the type name
Parameters:
  typeName - The primitive type name The object wrapper type name for this primitive



hasDefaultConstructor
public static boolean hasDefaultConstructor(Class the_class)(Code)
Method to check for a default constructor on a class. Particular relevance for JDO is the requirement for a default constructor on all Persistence-Capable classes. Doesn't check superclasses for the default constructor.
Parameters:
  the_class - The class Whether it has a default constructor



isInnerClass
public static boolean isInnerClass(String class_name)(Code)
Method to check whether a classname is for an inner class. Currently checks for the presence of $ in the name.
Parameters:
  class_name - The class name Whether it is an inner class



isPrimitiveArrayType
public static boolean isPrimitiveArrayType(String typeName)(Code)
Convenience method to return if the passed type (name) is a primitive array type.
Parameters:
  typeName - Name of the type Whether it is a primitive array



isPrimitiveType
public static boolean isPrimitiveType(String typeName)(Code)
Convenience method to return if the passed type (name) is a primitive type.
Parameters:
  typeName - Name of the type Whether it is a primitive



isPrimitiveWrapperType
public static boolean isPrimitiveWrapperType(String typeName)(Code)
Convenience method to return if the passed type (name) is a primitive wrapper type.
Parameters:
  typeName - Name of the type Whether it is a primitive wrapper



newInstance
public static Object newInstance(Class type, Class[] parameterTypes, Object[] parameters)(Code)
Accessor for a new instance of an object. Uses reflection to generate the instance using the passed constructor parameter arguments.
Parameters:
  type - Type of object (the class).
Parameters:
  parameterTypes - Classes of params for the constructor
Parameters:
  parameters - The parameters for the constructor The object
throws:
  JPOXException - If an error occurs creating the instance



typesAreCompatible
public static boolean typesAreCompatible(Class cls1, String clsName2, ClassLoaderResolver clr)(Code)
Convenience method to return if two types are compatible. Returns true if both types are primitive/wrappers and are of the same type. Returns true if clsName2 is the same or a subclass of cls1. Otherwise returns false;
Parameters:
  cls1 - First class
Parameters:
  clsName2 - Name of the second class
Parameters:
  clr - ClassLoader resolver to use Whether they are compatible



typesAreCompatible
public static boolean typesAreCompatible(Class cls1, Class cls2)(Code)
Convenience method to return if two types are compatible. Returns true if both types are primitive/wrappers and are of the same type. Returns true if cls2 is the same or a subclass of cls1. Otherwise returns false;
Parameters:
  cls1 - First class
Parameters:
  cls2 - Second class Whether they are compatible



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.