|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.specrunner.parameters.core.ParameterHolder
org.specrunner.plugins.core.AbstractPlugin
org.specrunner.plugins.core.AbstractPluginNamed
org.specrunner.plugins.core.AbstractPluginScoped
org.specrunner.plugins.core.AbstractPluginTable
org.specrunner.plugins.core.objects.AbstractPluginObject
public abstract class AbstractPluginObject
Generic object plugin. To write object plugins override method
isMapped() and action(...). i.e.
SpecRunner-Hibernate3 extends the object manipulation to save/update/delete
data using Hibernate3 infra-structure.
| Nested Class Summary | |
|---|---|
static class |
AbstractPluginObject.Field
Hold column information. |
| Field Summary | |
|---|---|
protected String |
creator
Object creator name. |
protected IObjectCreator |
creatorInstance
Object creator instance. |
protected List<AbstractPluginObject.Field> |
fields
List of fields. |
protected Map<String,AbstractPluginObject.Field> |
generic
List of generic definition fields. |
protected Map<String,Object> |
instances
Mapping of identifiers to object instances. |
protected Map<String,String> |
keysBefore
Mapping of key before processing to the ones after processing. |
protected String |
mapping
The map of generic fields to be used as reference. |
protected String |
reference
The identification fields. |
protected List<String> |
references
The identification fields list. |
protected String |
separator
Separator of identification attributes. |
protected String |
type
Object class name. |
protected Class<?> |
typeInstance
Object class. |
| Fields inherited from class org.specrunner.plugins.core.AbstractPlugin |
|---|
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAIT |
| Constructor Summary | |
|---|---|
AbstractPluginObject()
|
|
| Method Summary | |
|---|---|
protected abstract void |
action(IContext context,
Object instance,
RowAdapter row,
IResultSet result)
This method can be and should be overridden to perform save, comparison, etc for updates. |
protected Object |
create(RowAdapter row)
Create the object based on a row. |
void |
doEnd(IContext context,
IResultSet result,
TableAdapter table)
Perform an ending action. |
String |
getCreator()
Returns the object creator of embeddable objects. |
IObjectCreator |
getCreatorInstance()
Object creator type. |
String |
getMapping()
Return the map of field information. |
Object |
getObject(String key)
Given a key, returns the corresponding object instance. |
String |
getReference()
Sets the attribute which represents the keys of the entity. |
String |
getSeparator()
Gets the string used to separate fields of reference. i.e. if reference='id,name' and separator='/', the
object instance corresponding to a given line will be 'id/name'. |
String |
getType()
The object type of the plugin. i.e. |
Class<?> |
getTypeInstance()
Gets the corresponding class to type. |
void |
initialize(IContext context,
TableAdapter table)
Initialize helper. |
protected abstract boolean |
isMapped()
Says if the instance show be mapped or not. |
protected void |
loadFields(IContext context,
RowAdapter row,
List<AbstractPluginObject.Field> list)
Load fields based on th tags. |
protected void |
loadMapping(IContext context,
TableAdapter table)
Load mapping with predefined values. |
String |
makeKey(Object instance)
Creates the key to be used for storing/recovering object information. |
void |
mapObject(Object instance,
String keyBefore,
String keyAfter)
Maps the object using the keys before and after Hibernate saving. |
AbstractPluginObject |
merge(AbstractPluginObject old)
Merge to equivalent plugins. |
protected boolean |
populate(Object instance,
IContext context,
RowAdapter row,
IResultSet result)
Populate the object instance with row information. |
protected void |
processLine(IContext context,
RowAdapter row,
IResultSet result)
Process a given row. |
Object |
removeObject(String key)
Remove an object from mapping. |
protected void |
setBoolean(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a boolean to a field. |
protected void |
setChar(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a char to a field. |
void |
setCreator(String creator)
Sets the creator class. |
void |
setCreatorInstance(IObjectCreator creatorInstance)
Sets the creator. |
protected void |
setDouble(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a double to a field. |
protected void |
setEntity(Object instance,
AbstractPluginObject.Field f,
Object value)
If there is some plugin of the object type specified in field, use the plugin object version. |
protected void |
setFloat(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a float to a field. |
protected void |
setInteger(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets an integer to a field. |
protected void |
setLong(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a long to a field. |
void |
setMapping(String mapping)
Sets the object mapping. |
protected void |
setObject(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets an object to a field. |
protected void |
setObjectInformation()
Set object and/or creator information. |
void |
setReference(String reference)
Sets the references. |
void |
setSeparator(String separator)
Sets identifier separator. |
protected void |
setShort(Object instance,
AbstractPluginObject.Field f,
Object value)
Sets a short to a field. |
void |
setType(String type)
Set the type. |
void |
setTypeInstance(Class<?> typeInstance)
Sets the instance type. |
protected void |
setValue(RowAdapter row,
Object instance,
AbstractPluginObject.Field f,
Object value)
Set the field with the given value. |
| Methods inherited from class org.specrunner.plugins.core.AbstractPluginTable |
|---|
doEnd, doStart, doStart, initialize, toString |
| Methods inherited from class org.specrunner.plugins.core.AbstractPluginScoped |
|---|
getScope, saveGlobal, saveLocal, saveStrict, setScope |
| Methods inherited from class org.specrunner.plugins.core.AbstractPluginNamed |
|---|
getName, setName |
| Methods inherited from class org.specrunner.plugins.core.AbstractPlugin |
|---|
copy, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel |
| Methods inherited from class org.specrunner.parameters.core.ParameterHolder |
|---|
getParameters, setParameters |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.specrunner.parameters.IParameterHolder |
|---|
getParameters, setParameters |
| Methods inherited from interface org.specrunner.plugins.IActionType |
|---|
getActionType |
| Field Detail |
|---|
protected String type
protected Class<?> typeInstance
protected String creator
protected IObjectCreator creatorInstance
protected String reference
protected List<String> references
protected String separator
protected String mapping
protected Map<String,AbstractPluginObject.Field> generic
protected List<AbstractPluginObject.Field> fields
protected Map<String,String> keysBefore
protected Map<String,Object> instances
| Constructor Detail |
|---|
public AbstractPluginObject()
| Method Detail |
|---|
public String getType()
type='system.entity.Person'.
public void setType(String type)
type - A new type.public Class<?> getTypeInstance()
public void setTypeInstance(Class<?> typeInstance)
typeInstance - A new type.public String getCreator()
public void setCreator(String creator)
creator - A new creator class name.public IObjectCreator getCreatorInstance()
public void setCreatorInstance(IObjectCreator creatorInstance)
creatorInstance - A new creator instance.public String getReference()
reference='id,name' is used, the 'id' attribute and 'name'
attribute are used as the object key, separated by 'separator' field.
public void setReference(String reference)
reference - A new reference list.public String getSeparator()
reference='id,name' and separator='/', the
object instance corresponding to a given line will be 'id/name'.
public void setSeparator(String separator)
separator - The separator.public String getMapping()
public void setMapping(String mapping)
mapping - The mapping.
public void initialize(IContext context,
TableAdapter table)
throws PluginException
AbstractPluginTable
initialize in class AbstractPluginTablecontext - The context.table - The adapter.
PluginException - On initialization errors.
protected void loadMapping(IContext context,
TableAdapter table)
throws PluginException
context - The context.table - The table.
PluginException - On mapping errors.
protected void setObjectInformation()
throws PluginException
PluginException - On setting errors.
public void doEnd(IContext context,
IResultSet result,
TableAdapter table)
throws PluginException
AbstractPluginTable
doEnd in class AbstractPluginTablecontext - The context.result - The result set.table - The adapter.
PluginException - On plugin errors.
protected void loadFields(IContext context,
RowAdapter row,
List<AbstractPluginObject.Field> list)
throws PluginException
th tags.
context - The context.row - The row.list - List of fields.
PluginException - On load errors.protected abstract boolean isMapped()
protected void processLine(IContext context,
RowAdapter row,
IResultSet result)
throws Exception
context - The context.row - The row.result - The result set.
Exception - On processing errors.
protected Object create(RowAdapter row)
throws Exception
row - The row.
Exception - On creation errors.
protected boolean populate(Object instance,
IContext context,
RowAdapter row,
IResultSet result)
throws Exception
instance - The object instance.context - The test context.row - The row with attribute informations.result - The result set.
Exception - On population errors.
protected void setValue(RowAdapter row,
Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
row - The row corresponding to the object.instance - The object instance.f - The field information.value - The value to be set in instance for field 'f'.
Exception - On set value erros.
protected void setBoolean(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setChar(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setShort(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setInteger(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setLong(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setFloat(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setDouble(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected void setEntity(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field metadata.value - The value to be set.
Exception - On set errors.
protected void setObject(Object instance,
AbstractPluginObject.Field f,
Object value)
throws Exception
instance - The object instance.f - The field information.value - The value to be set.
Exception - On setting errors.
protected abstract void action(IContext context,
Object instance,
RowAdapter row,
IResultSet result)
throws Exception
context - Test context.instance - The object instance.row - The row adapter.result - The result set.
Exception - On action errors.
public String makeKey(Object instance)
throws Exception
instance - The object instance.
Exception - On key generation errors.
public void mapObject(Object instance,
String keyBefore,
String keyAfter)
instance - The object instance.keyBefore - The key before saving.keyAfter - The key after saving.public AbstractPluginObject merge(AbstractPluginObject old)
old - Source of copy.
public Object getObject(String key)
throws PluginException
key - The object key.
PluginException - If object with the given key is not present in plugin.
public Object removeObject(String key)
throws PluginException
key - The key.
PluginException - On lookup errors.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||