KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > IllegalAccessException

java.lang
Class IllegalAccessException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.IllegalAccessException
All Implemented Interfaces:
Serializable
See Also:
Top Examples, Source Code, Class.newInstance(), Field.set(Object, Object), Field.setBoolean(Object, boolean), Field.setByte(Object, byte), Field.setShort(Object, short), Field.setChar(Object, char), Field.setInt(Object, int), Field.setLong(Object, long), Field.setFloat(Object, float), Field.setDouble(Object, double), Field.get(Object), Field.getBoolean(Object), Field.getByte(Object), Field.getShort(Object), Field.getChar(Object), Field.getInt(Object), Field.getLong(Object), Field.getFloat(Object), Field.getDouble(Object), Method.invoke(Object, Object[]), Constructor.newInstance(Object[])

public IllegalAccessException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1508]A more flexible way of implementing GOF factory pattern
By Anonymous on 2005/08/04 09:55:56  Rate
//A more flexible way of implementing GOF factory pattern 
  
  
 public class myFactory  {  
     public static Object getObject ( String classname, Class requiredType )  
             throws FactoryException  {  
         try  {  
             Class clazz = Class.forName ( classname ) ; 
             Object o = clazz.newInstance (  ) ; 
             if  ( !requiredType.isAssignableFrom ( clazz )  )  
                 throw new FactoryException ( "Class '" + classname 
                         + "' not of required type " + requiredType ) ; 
             // Configure the object... 
             return o; 
          }  catch  ( ClassNotFoundException ex )   {  
             throw new FactoryException ( "Couldn't load class '" + classname 
                     + "'", ex ) ; 
          }  catch  ( IllegalAccessException ex )   {  
             throw new FactoryException ( "Couldn't construct class '" + classname 
                     + "': is the no arg constructor public?", ex ) ; 
          }  catch  ( InstantiationException ex )   {  
             throw new FactoryException ( "Couldn't construct class '" + classname 
                     + "': does it have a no arg constructor", ex ) ; 
          }  
      }  
  
  
  
  } 


public IllegalAccessException(String s)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags