Facemorph.DataBase
Class ObjectFactory

java.lang.Object
  extended by Facemorph.DataBase.ObjectFactory
Direct Known Subclasses:
FileObjectFactory, IniObjectFactory

public class ObjectFactory
extends java.lang.Object


Nested Class Summary
static class ObjectFactory.DefaultFactoryMeme
           
static class ObjectFactory.FactoryMeme
          All Classes included in the factory system must have an assosiated FactoryMeme class This allows the Factory Object Class to be queried to suitability for particular data.
protected static class ObjectFactory.NoHandlerFoundException
           
protected static class ObjectFactory.ObjectFactoryException
           
 
Constructor Summary
ObjectFactory()
           
 
Method Summary
static boolean addObjectType(ObjectFactory.FactoryMeme newType)
          Adds a new type to the factory system
static java.util.Vector<ObjectFactory.FactoryMeme> findClassesThatExtend(java.lang.Class c)
          Return all instanced classes that extend the given class
static java.lang.Class findFirstClassThatHandles(java.lang.String typeInfo, boolean fully)
          Returns the first class in the list (order undefined) that can handle the given type info
static ObjectFactory.FactoryMeme findFirstFactoryMemeThatHandles(java.lang.String typeInfo, boolean fully)
          Returns the first factory meme in the list (order undefined) that can handle the given type info
static java.util.Vector<ObjectFactory.FactoryMeme> findHandlers(java.lang.String typeInfo, boolean fully)
          Returns a list of all factory memes in the list (order undefined) that can handle the given type info
static boolean hasObjectType(ObjectFactory.FactoryMeme type)
           
static java.lang.Object instantiate(java.lang.String typeInfo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectFactory

public ObjectFactory()
Method Detail

addObjectType

public static boolean addObjectType(ObjectFactory.FactoryMeme newType)
Adds a new type to the factory system

Parameters:
newType - the FactoryMeme associated with the new type
Returns:
true if successfully add (or was already in system).

hasObjectType

public static boolean hasObjectType(ObjectFactory.FactoryMeme type)

instantiate

public static java.lang.Object instantiate(java.lang.String typeInfo)
                                    throws java.lang.InstantiationException,
                                           java.lang.IllegalAccessException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

findFirstFactoryMemeThatHandles

public static ObjectFactory.FactoryMeme findFirstFactoryMemeThatHandles(java.lang.String typeInfo,
                                                                        boolean fully)
Returns the first factory meme in the list (order undefined) that can handle the given type info

Parameters:
typeInfo - a string of type data
fully - true if the class must be able to fully instantiate the data, false if a super-class will suffice
Returns:
the factory meme of the handling class (if found) null otherwise.

findHandlers

public static java.util.Vector<ObjectFactory.FactoryMeme> findHandlers(java.lang.String typeInfo,
                                                                       boolean fully)
Returns a list of all factory memes in the list (order undefined) that can handle the given type info

Parameters:
typeInfo - a string of type data
fully - true if the class must be able to fully instantiate the data, false if a super-class will suffice
Returns:
the factory memes of the handling classes (if found) empty otherwise.

findFirstClassThatHandles

public static java.lang.Class findFirstClassThatHandles(java.lang.String typeInfo,
                                                        boolean fully)
Returns the first class in the list (order undefined) that can handle the given type info

Parameters:
typeInfo - a string of type data
fully - true if the class must be able to fully instantiate the data, false if a super-class will suffice
Returns:
the class of the handling class (if found) null otherwise.

findClassesThatExtend

public static java.util.Vector<ObjectFactory.FactoryMeme> findClassesThatExtend(java.lang.Class c)
Return all instanced classes that extend the given class

Parameters:
c - class to find instances and subclasses of
Returns:
list of classes found