public abstract class DBObjectFactory
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <C> C |
getObject(Tuple tuple,
java.lang.Class<C> objectClass)
Get an objects holding the same information as that which is held in this tuple.
|
static <C> C |
getObject(Tuple tuple,
java.lang.Class<C> objectClass,
java.util.Map<java.lang.String,java.lang.reflect.Method> setterMethods)
Gets an object of the given class, using the given set of setter methods and the attribute values from this tuple
|
static <C> C[] |
getObjectArray(TupleContainer c,
java.lang.Class<C> objectClass)
Get an array of objects holding the same information as that which is held in this TupleContainer.
|
static <C> C[] |
getObjectArrayIgnoringMissingSetters(TupleContainer c,
java.lang.Class<C> objectClass)
Get an array of objects holding a (potentially proper) subset of the information held in this TupleContainer.
|
static <C> java.util.Collection<C> |
getObjectCollection(TupleContainer tupleContainer,
java.lang.Class<C> objectClass)
Get a collection of objects holding the same information as that which is held in this TupleContainer.
|
static <C> java.util.Collection<C> |
getObjectCollectionIgnoringMissingSetters(TupleContainer tupleContainer,
java.lang.Class<C> objectClass)
Get a collection of objects holding a (potentially proper) subset of the information held in this TupleContainer.
|
static <C> C |
getObjectIgnoringMissingSetters(Tuple tuple,
java.lang.Class<C> objectClass)
Get an objects holding the same information as that which is held in this tuple.
|
static java.util.Map<java.lang.Class<?>,java.lang.Object> |
getObjects(Tuple tuple,
java.lang.Class<?>[] objectClass)
Get a Map of objects holding the same information as that which is held in this Tuple.
|
static java.util.Collection<java.util.Map<java.lang.Class<?>,java.lang.Object>> |
getObjectsCollection(TupleContainer tupleContainer,
java.lang.Class<?>[] objectClasses)
Get a collection of Maps of objects holding the same information as that which is held in this TupleContainer.
|
static java.lang.reflect.Constructor<?> |
getPublicNoArgConstructor(java.lang.Class<?> objectClass)
Gets the public no-arg constructor from a class
|
static java.util.HashMap<java.lang.String,java.lang.reflect.Method> |
getSetterMethods(java.lang.Class<?> objectClass)
Gets the setter methods from a class applicable for the given set of attribute names
|
static java.util.Map<java.lang.Class<?>,java.lang.Object> |
toObjects(Tuple tuple,
java.util.Map<java.lang.Class<?>,java.util.HashMap<java.lang.String,java.lang.reflect.Method>> classesProcessingMap)
Gets a Map of objects holding the same information as that which is held in this tuple.
|
public static <C> C getObject(Tuple tuple, java.lang.Class<C> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException, SettersMissingException
C
- the object type to returntuple
- The tuple from which an object is to be builtobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), the attribute name (capitalized), and the suffix "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.SettersMissingException
- if a needed setter is missing in the class denoted by objectClassConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static final <C> C getObject(Tuple tuple, java.lang.Class<C> objectClass, java.util.Map<java.lang.String,java.lang.reflect.Method> setterMethods)
C
- -tuple
- The tuple from which an object is to be builtobjectClass
- The Class of the object to be created and returnedsetterMethods
- The setter methods to be invoked to set attribute values in the returned objectpublic static <C> C[] getObjectArray(TupleContainer c, java.lang.Class<C> objectClass) throws SettersMissingException, ConstructorMissingException, ClassDoesNotImplementDBObjectException
C
- The name of the objectClass, also naming the class/object type of the objects making up the returned arrayc
- The tuple container whose tuples are to be 'transformed' into objectsobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), followed by the uppercased attribute name (i.e. first character uppercase, all others lowercase), followed by "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorSettersMissingException
- if a needed setter is missing in the class denoted by objectClassClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static <C> C[] getObjectArrayIgnoringMissingSetters(TupleContainer c, java.lang.Class<C> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException
C
- The name of the objectClass, also naming the class/object type of the objects making up the returned arrayc
- The tuple container whose tuples are to be 'transformed' into objects of the given classobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has at most one unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), followed by the uppercased attribute name (i.e. first character uppercase, all others lowercase), followed by "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfaceConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static <C> java.util.Collection<C> getObjectCollection(TupleContainer tupleContainer, java.lang.Class<C> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException, SettersMissingException
C
- -tupleContainer
- The TupleContainer holding the tuples to be used for constructing DBObjectsobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), followed by the uppercased attribute name (i.e. first character uppercase, all others lowercase), followed by "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorSettersMissingException
- if any attribute in the tuplecontainer does not correspond to a setter method in the objectClassClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static <C> java.util.Collection<C> getObjectCollectionIgnoringMissingSetters(TupleContainer tupleContainer, java.lang.Class<C> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException
C
- the object type to returntupleContainer
- The tupleContainer, each contained tuple of which is to be "converted" into an object of the given classobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has at most one unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), followed by the uppercased attribute name (i.e. first character uppercase, all others lowercase), followed by "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static final <C> C getObjectIgnoringMissingSetters(Tuple tuple, java.lang.Class<C> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException
C
- -tuple
- The tuple from which an Object is to be builtobjectClass
- A Class object denoting the class of the objects to be returned. objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for each attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), the attribute name (capitalized), and the suffix "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static java.util.Map<java.lang.Class<?>,java.lang.Object> getObjects(Tuple tuple, java.lang.Class<?>[] objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException, SettersMissingException
tuple
- The tuple from which objects are to be contructedobjectClass
- An array of Class objects denoting the classes of the objects to be returned for each tuple. Each objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for some attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), the attribute name (capitalized), and the suffix "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.SettersMissingException
- if some attribute in the heading exists for which no corresponding setter could be found in any of the classes denoted by objectClass[]ConstructorMissingException
- if objectClass[] contains any class that does not denote a public class, or denotes an abstract class, or does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass[] contains any class that does not implement the required DBObject interfacepublic static java.util.Collection<java.util.Map<java.lang.Class<?>,java.lang.Object>> getObjectsCollection(TupleContainer tupleContainer, java.lang.Class<?>[] objectClasses) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException, SettersMissingException
tupleContainer
- The tupleContainer, each contained tuple of which is to be "converted" into objects of the given classesobjectClasses
- An array of Class objects denoting the classes of the objects to be returned for each tuple. Each objectClass must denote a public, non-abstract class that has a public no-arg constructor, and that has a unique setter method for some attribute in the heading. The name of this unique method must be the concatenation of the word "set" (all lowercase), followed by the uppercased attribute name (i.e. first character uppercase, all others lowercase), followed by "FromDB". The argument list of this setter method must consist of excatly one java.lang.String argument.ConstructorMissingException
- if some objectClass does not denote a public class, or it denotes an abstract class, ordenotes a class that does not have a public no-arg constructorSettersMissingException
- if some attribute in the heading exists for which no corresponding setter could be found in any of the classes denoted by objectClass[]ClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static java.lang.reflect.Constructor<?> getPublicNoArgConstructor(java.lang.Class<?> objectClass) throws ConstructorMissingException, ClassDoesNotImplementDBObjectException
objectClass
- the classConstructorMissingException
- if objectClass does not denote a public class, or it denotes an abstract class, or the class does not have a public no-arg constructorClassDoesNotImplementDBObjectException
- if objectClass does not implement the required DBObject interfacepublic static java.util.HashMap<java.lang.String,java.lang.reflect.Method> getSetterMethods(java.lang.Class<?> objectClass)
objectClass
- The class to extract the setter methods frompublic static final java.util.Map<java.lang.Class<?>,java.lang.Object> toObjects(Tuple tuple, java.util.Map<java.lang.Class<?>,java.util.HashMap<java.lang.String,java.lang.reflect.Method>> classesProcessingMap)
tuple
- The tuple from which objects are to be constrcutedclassesProcessingMap
- The processing map that defines how the conversion of a tuple to a series of objects should proceed. Each entry in the map is a Class object, defining the class of an object to be instantiated for containing values of the tuple. The value mapped to this class object is a Map defining the setter methods to be invoked for setting the appropriate values in the instantiated object.