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 Details

  • Constructor Details

  • Method Details

    • addNewPrototype

      public void addNewPrototype​(String name, Class prototype)
      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

      public Object getNewInstance​(String prototypeName)
      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