Class PrototypeFactoryDeprecated
java.lang.Object
org.javarosa.core.util.externalizable.PrototypeFactoryDeprecated
public class PrototypeFactoryDeprecated extends Object
The PrototypeFactory is a factory class for instantiating classes
based on their class name. This class fills a hole created by J2ME's
lack of reflection.
The most common use of PrototypeFactories in JavaRoa is to instantiate
objects in order to deserialize them from RMS.
Note that due to the nature of instantiating classes dynamically,
prototypes registered with this class must maintain a constructor with
no arguments.
- Author:
- Clayton Sims
-
Field Summary
Fields Modifier and Type Field Description Mapprototypes -
Constructor Summary
Constructors Constructor Description PrototypeFactoryDeprecated() -
Method Summary
Modifier and Type Method Description voidaddNewPrototype(String name, Class prototype)Adds a new class to be able to retrieve instances ofObjectgetNewInstance(String prototypeName)
-
Field Details
-
Constructor Details
-
PrototypeFactoryDeprecated
public PrototypeFactoryDeprecated()
-
-
Method Details
-
addNewPrototype
Adds a new class to be able to retrieve instances of- Parameters:
name- The name of the prototype. Generally prototype.getClass().getName()prototype- The class object to be used for instantiation. Should be a class with a constructor that takes 0 arguments.
-
getNewInstance
- Parameters:
prototypeName- The name of the prototype to be instantiated- Returns:
- a new object of the type linked to the name given in this factory. Null if the name is not associated with any class in this factory.
- Throws:
IllegalAccessException- If the empty constructor of the class given is not allowed to be accessed.InstantiationException
-