T
- the type of LocalAbstractObject
to create by this factorypublic static class LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>
extends java.lang.Object
text stream
.Constructor and Description |
---|
LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass,
boolean convertStringArguments,
java.util.Map<java.lang.String,java.lang.Object> namedInstances,
java.lang.Object[] additionalArguments)
Creates a new factory for creating instances of T from text.
|
LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass,
java.util.Map<java.lang.String,java.lang.Object> namedInstances,
java.lang.String... additionalArguments)
Creates a new factory for creating instances of T from text.
|
LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass,
java.lang.Object... additionalArguments)
Creates a new factory for creating instances of T from text.
|
LocalAbstractObject.TextStreamFactory(LocalAbstractObject.TextStreamFactory<? extends T> sourceFactory)
Creates a new factory from another text stream factory.
|
Modifier and Type | Method and Description |
---|---|
T |
create(java.io.BufferedReader dataReader)
Creates a new instance of T using the text data read from the
dataReader . |
T |
create(java.lang.String data)
Creates a new instance of T using the text
data . |
java.lang.Class<?> |
getConstructorParameterClass(int index)
Returns the class of the
index th additional argument of this factory constructor. |
java.lang.Class<? extends T> |
getCreatedClass()
Returns the class created by this factory.
|
void |
setConstructorParameter(int index,
java.lang.Object paramValue)
Sets the value of this factory's constructor argument.
|
void |
setConstructorParameterFromString(int index,
java.lang.String paramValue,
java.util.Map<java.lang.String,java.lang.Object> namedInstances)
Sets the value of this factory's constructor argument from a string value.
|
java.lang.String |
toString() |
public LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass, boolean convertStringArguments, java.util.Map<java.lang.String,java.lang.Object> namedInstances, java.lang.Object[] additionalArguments)
objectClass
- the type of LocalAbstractObject
to createconvertStringArguments
- if true the string values from the additional arguments are converted using Convert.stringToType(java.lang.String, java.lang.Class<E>, java.util.Map<java.lang.String, ? extends java.lang.Object>)
namedInstances
- map of named instances - an instance from this map is returned if the string
matches a key in the mapadditionalArguments
- additional arguments for the constructor of T (excluding the first BufferedReader
)public LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass, java.lang.Object... additionalArguments)
objectClass
- the type of LocalAbstractObject
to createadditionalArguments
- additional arguments for the constructor of T (excluding the first BufferedReader
)public LocalAbstractObject.TextStreamFactory(java.lang.Class<? extends T> objectClass, java.util.Map<java.lang.String,java.lang.Object> namedInstances, java.lang.String... additionalArguments)
Convert.stringToType(java.lang.String, java.lang.Class<E>, java.util.Map<java.lang.String, ? extends java.lang.Object>)
.objectClass
- the type of LocalAbstractObject
to createnamedInstances
- map of named instances for the Convert.stringToType(java.lang.String, java.lang.Class<E>, java.util.Map<java.lang.String, ? extends java.lang.Object>)
conversionadditionalArguments
- additional arguments for the constructor of T (excluding the first BufferedReader
)public LocalAbstractObject.TextStreamFactory(LocalAbstractObject.TextStreamFactory<? extends T> sourceFactory)
sourceFactory
- the text stream factory to copy frompublic void setConstructorParameter(int index, java.lang.Object paramValue) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
additionalArguments
.index
- the parameter index to change (zero-based)paramValue
- the changed value to pass to the constructorjava.lang.IllegalArgumentException
- when the passed object is incompatible with the constructor's parameterjava.lang.IndexOutOfBoundsException
- if the index parameter is out of boundspublic void setConstructorParameterFromString(int index, java.lang.String paramValue, java.util.Map<java.lang.String,java.lang.Object> namedInstances) throws java.lang.IndexOutOfBoundsException, java.lang.InstantiationException
additionalArguments
.index
- the parameter index to change (zero-based)paramValue
- the changed value to pass to the constructornamedInstances
- map of named instances for the Convert.stringToType(java.lang.String, java.lang.Class<E>, java.util.Map<java.lang.String, ? extends java.lang.Object>)
conversionjava.lang.IndexOutOfBoundsException
- if the index parameter is out of boundsjava.lang.InstantiationException
- if the value passed is string that is not convertible to the constructor classpublic java.lang.Class<?> getConstructorParameterClass(int index) throws java.lang.IndexOutOfBoundsException
index
th additional argument of this factory constructor.index
- the argument index the class of which to get (zero-based)index
th additional argumentjava.lang.IndexOutOfBoundsException
public T create(java.io.BufferedReader dataReader) throws java.lang.reflect.InvocationTargetException
dataReader
.dataReader
- the text stream from which to read object's datajava.lang.reflect.InvocationTargetException
- if there was an exception while creating the objectpublic T create(java.lang.String data) throws java.lang.reflect.InvocationTargetException
data
.data
- the text from which create the objectjava.lang.reflect.InvocationTargetException
- if there was an exception while creating the objectpublic java.lang.Class<? extends T> getCreatedClass()
public java.lang.String toString()
toString
in class java.lang.Object