com.quadrique.jbuildingblocks.core.classLoader
Class JbbClass

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.classLoader.JbbClass

public class JbbClass
extends Object

This class is used to manipulate a java class

Version:
1.0.0
Author:
Hervé Rivere

Constructor Summary
JbbClass()
           
 
Method Summary
 Field[] getClassFields(String fullyQualifiedClassName)
           
 String getClassName(Class<?> zClass)
           
 String getClassPackageName(Class<?> zClass)
           
 String getClassPackageName(String zClassName)
           
 Field getField(Object o, String fieldName)
           
 Field[] getFields(Object o)
          list all the fields of an instance
 Object getInstanceFromClassName(String zClassName)
           
 Field[] getPublicFields(Object o)
          list all the fields of an instance
 void introspectClass(String fullyQualifiedClassName)
           
static JbbClass newInstance()
           
 void setField(Object instance, String fieldName, boolean fieldValue)
           
 void setField(Object instance, String fieldName, Byte fieldValue)
           
 void setField(Object instance, String fieldName, double fieldValue)
           
 void setField(Object instance, String fieldName, float fieldValue)
           
 void setField(Object instance, String fieldName, int fieldValue)
           
 void setField(Object instance, String fieldName, long fieldValue)
           
 void setField(Object instance, String fieldName, Object fieldValue)
           
 void setField(Object instance, String fieldName, short fieldValue)
           
 void setFieldWhenTypeUnknown(Object instance, String fieldName, String fieldValueAsString)
           
 void setPublicField(Object instance, String fieldName, Object fieldValue)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JbbClass

public JbbClass()
Method Detail

newInstance

public static JbbClass newInstance()
Returns:
a new instance

getInstanceFromClassName

public Object getInstanceFromClassName(String zClassName)
                                throws Exception
Parameters:
zClassName - the fully qualified class name (e.g. "com.quadrique.jbuildingblocks.classLoader.ClassHandler"). Please note that the corresponding class file has to be in the class path of the application
Returns:
an instance of the given class name
Throws:
Exception - if a problem occurs

getClassName

public String getClassName(Class<?> zClass)
                    throws Exception
Parameters:
zClass - a Class instance
Returns:
the name (e.g. "com.quadrique.jbuildingblocks.classLoader.ClassHandler") of the class for a given Class instance
Throws:
Exception

getClassPackageName

public String getClassPackageName(Class<?> zClass)
                           throws Exception
Parameters:
zClass - a Class instance
Returns:
the package name (e.g. "com.quadrique.jbuildingblocks.classLoader") for a given Class instance (e.g. com.quadrique.jbuildingblocks.classLoader.ClassHandler.class)
Throws:
Exception

getClassPackageName

public String getClassPackageName(String zClassName)
                           throws Exception
Parameters:
zClassName - the name of a class as a String
Returns:
the package name (e.g. "com.quadrique.jbuildingblocks.classLoader") for a given class name (e.g. com.quadrique.jbuildingblocks.classLoader.ClassHandler)
Throws:
Exception

setPublicField

public void setPublicField(Object instance,
                           String fieldName,
                           Object fieldValue)
                    throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     Object fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     int fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     boolean fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     Byte fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     short fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     long fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     float fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

setField

public void setField(Object instance,
                     String fieldName,
                     double fieldValue)
              throws Exception
Parameters:
instance -
fieldName -
fieldValue -
Throws:
Exception

getFields

public Field[] getFields(Object o)
                  throws Exception
list all the fields of an instance

Parameters:
o -
Returns:
the list of all the fields of an instance
Throws:
Exception

getPublicFields

public Field[] getPublicFields(Object o)
                        throws Exception
list all the fields of an instance

Parameters:
o -
Returns:
the list of all the fields of an instance
Throws:
Exception

getField

public Field getField(Object o,
                      String fieldName)
               throws Exception
Parameters:
o -
fieldName -
Returns:
the field corresponding to the given field name, null otherwise
Throws:
Exception

setFieldWhenTypeUnknown

public void setFieldWhenTypeUnknown(Object instance,
                                    String fieldName,
                                    String fieldValueAsString)
                             throws Exception
Parameters:
instance -
fieldName -
fieldValueAsString -
Throws:
Exception

introspectClass

public void introspectClass(String fullyQualifiedClassName)
                     throws Exception
Parameters:
fullyQualifiedClassName -
Throws:
Exception

getClassFields

public Field[] getClassFields(String fullyQualifiedClassName)
                       throws Exception
Parameters:
fullyQualifiedClassName -
Returns:
array of Field objects
Throws:
Exception


Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.