src/main/java/org/jboss/util/naming/Util.java
protected static void checkObject(Context context, String name, Object object, Class clazz) throws Exception
   {
      Class objectClass = object.getClass();
      if (clazz.isAssignableFrom(objectClass) == false)
      {
         StringBuffer buffer = new StringBuffer(100);
         buffer.append("Object at '").append(name);
         buffer.append("' in context ").append(context.getEnvironment());
         buffer.append(" is not an instance of ");
         appendClassInfo(buffer, clazz);
         buffer.append(" object class is ");
         appendClassInfo(buffer, object.getClass());
         throw new ClassCastException(buffer.toString());
      }
   }
protected static void checkObject(Context context, String name, Object object, Class clazz) throws Exception
   {
      Class objectClass = object.getClass();
      if (clazz.isAssignableFrom(objectClass) == false)
      {
         StringBuffer buffer = new StringBuffer(100);
         buffer.append("Object at '").append(name);
         buffer.append("' in context ").append(context.getEnvironment());
         buffer.append(" is not an instance of ");
         appendClassInfo(buffer, clazz);
         buffer.append(" object class is ");
         appendClassInfo(buffer, object.getClass());
         throw new ClassCastException(buffer.toString());
      }
   }
protected static void checkObject ( Context context , String name , Object object , Class clazz ) throws Exception { Class objectClass = object . getClass ( ) ; if ( clazz . isAssignableFrom ( objectClass ) == false ) { StringBuffer buffer = new StringBuffer ( 100 ) ; buffer . append ( "Object at '" ) . append ( name ) ; buffer . append ( "' in context " ) . append ( context . getEnvironment ( ) ) ; buffer . append ( " is not an instance of " ) ; appendClassInfo ( buffer , clazz ) ; buffer . append ( " object class is " ) ; appendClassInfo ( buffer , object . getClass ( ) ) ; throw new ClassCastException ( buffer . toString ( ) ) ; } }
Checks an object implements the given class

@param context the context
@param name the name to lookup
@param object the object
@param clazz the expected type
@throws Exception for any error
Checks an object implements the given class