Class Filler<T>
- All Implemented Interfaces:
Executable,Runnable
- Direct Known Subclasses:
ObjectFiller,Test.F
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<L extends StoredObject>
ObjectIterator<L> createLinkData(ODT.Table table) Create the data for a link table.voidcustomizeImage(ODT.Image image) Allows customization of an image before it is generated.voidcustomizeSection(ODT.Section section) Allows customization of a section before it is generated.voidcustomizeTable(ODT.Table table) Allows customization of a table before it is generated.evaluate(ODT.Element element, String variableName) Evaluates a given variable name within the context of a specific element and returns the corresponding value.Evaluates the specified attribute of the object and returns the result.voidexecute()The functional interface method specified by this interface.voidSet and execute the ODT instance associated with this filler.getLinkCondition(Link<?> link) Retrieves the condition associated with the specified link.<L extends StoredObject>
Predicate<L> getLinkFilter(Link<L> link) Generates a filter predicate for the specified link.final ODT<?> getODT()Gets the ODT instance currently associated with this filler.Retrieves the reporting object associated with this instance.final TransactionManagerGet the transaction manager associated with the ODT.voidpopulateData(ODT.Table table) Populates the data of the specified table object by processing its name and attributes.voidsetImageCustomizer(BiConsumer<Filler<?>, ODT.Image> imageCustomizer) Sets a customizer for images that enables tailored modifications or adjustments during their generation.voidsetReportingObject(T reportingObject) Sets the reporting object for this instance.voidsetSectionCustomizer(BiConsumer<Filler<?>, ODT.Section> sectionCustomizer) Sets a customizer for sections that enables tailored modifications or adjustments during their generation.voidsetTableCustomizer(BiConsumer<Filler<?>, ODT.Table> tableCustomizer) Sets a customizer for tables that enables tailored modifications or adjustments during their generation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.common.Executable
act, run
-
Constructor Details
-
Filler
public Filler()
-
-
Method Details
-
execute
public void execute()Description copied from interface:ExecutableThe functional interface method specified by this interface.- Specified by:
executein interfaceExecutable
-
execute
Set and execute the ODT instance associated with this filler.- Parameters:
odt- The ODT instance to set and execute.
-
getReportingObject
Retrieves the reporting object associated with this instance. The reporting object can be of any generic typeT.- Returns:
- The reporting object of type
T.
-
setReportingObject
Sets the reporting object for this instance.- Parameters:
reportingObject- The reporting object to set. It can be of any typeT.
-
getTransactionManager
Get the transaction manager associated with the ODT.- Returns:
- Transaction manager associated with the ODT.
-
getODT
Gets the ODT instance currently associated with this filler.- Returns:
- The active
ODTinstance, ornullif this filler is not attached to one.
-
evaluate
Evaluates the specified attribute of the object and returns the result. The method dynamically invokes the getter method for the specified attribute on the provided object and retrieves its value. If an error occurs during evaluation,nullis returned.Notes:
1. In general, the attribute name should be a valid getter method name without the 'get' prefix. However, it is not mandatory if you handle the evaluation yourself in a derived class
2. The variable name can contain dot-operators to specify a method list
StoredObjectUtility.MethodList.3. This method is invoked internally by the
evaluate(ODT.Element, String)method with the object parameter's value as one of the following. (a) The current reporting object for variables defined at top-level (means, not within anyODT.TableCell) or if the name of the variable starts with "O:" (stands for the reporting object). (b) For variables inside aODT.TableCell, it will pass the data associated with that cell (ODT.TableCell.getData()) if it is not null. Otherwise, the reporting object is passed.- Parameters:
object- The object whose attribute is to be evaluated. Must not be null. See note #3.attribute- The name of the attribute to be evaluated. Must not be null.- Returns:
- The value of the evaluated attribute, or
nullif an error occurs during evaluation.
-
evaluate
Evaluates a given variable name within the context of a specific element and returns the corresponding value. The evaluation process can involve checking system entities, users, reporting objects, table cells, or default fallback cases based on the provided variable name.It internally invokes
evaluate(Object, String)to determine the variable's value. Please see note# 3 ofevaluate(Object, String)for more details.- Parameters:
element- The ODT.Element instance that provides contextual information for evaluation. This can include associated table cells or the overall reporting context.variableName- The name of the variable to evaluate. It may have specific prefixes (e.g., "SystemEntity.", "SystemUser.", "O:") that affect the evaluation process.- Returns:
- The result of the evaluation, or a default string indicating the variable name is unresolved (e.g., "variableName = ?"). The return type depends on the context and the data associated with the variable name.
-
customizeSection
Allows customization of a section before it is generated.Override this method to adjust the section content, remove it, or apply any other document-specific logic.
Note: If a customizer is set, it will be invoked to perform section-specific adjustments.
- Parameters:
section- The section being customized.
-
setSectionCustomizer
Sets a customizer for sections that enables tailored modifications or adjustments during their generation. The customizer is represented as aBiConsumerthat accepts aFillerinstance and anODT.Section.- Parameters:
sectionCustomizer- ABiConsumerthat defines the customization logic for sections. The first parameter is theFillerinstance associated with the operation, and the second parameter is theODT.Sectionto be customized.
-
setTableCustomizer
Sets a customizer for tables that enables tailored modifications or adjustments during their generation. The customizer is represented as aBiConsumerthat accepts aFillerinstance and anODT.Table.- Parameters:
tableCustomizer- ABiConsumerthat defines the customization logic for tables. The first parameter is theFillerinstance associated with the operation, and the second parameter is theODT.Tableto be customized.
-
customizeImage
Allows customization of an image before it is generated.Override this method to modify image handling or remove the image entirely.
Note: If a customizer is set, it will be invoked to perform image-specific adjustments.
- Parameters:
image- The image being customized.
-
customizeTable
Allows customization of a table before it is generated.Override this method to control table output, row counts, blank rows, or remove the table entirely.
By default, this method takes appropriate action if a link object is specified (in that case, the name should be prefixed with "L:" followed by the link's data class) or if the table name starts with "A:" followed by an attribute name of the reporting object. If an attribute name is specified, it can also contain dot-operators.
Note: If a customizer is set, it will be invoked first to perform table-specific adjustments.
- Parameters:
table- The table being customized.
-
populateData
Populates the data of the specified table object by processing its name and attributes. The method validates the table state and processes the table name to derive the necessary attributes or links, which are then used to populate the table.Note: The name of the table should start with "A:", "L:" or "A:L:" to be processed further.
The method first checks if the table is removed or already built and returns if true. It then extracts the table name and checks if it starts with "L:", "A:" or "A:L:". If it starts with "L:", it calls createLinkData to populate the table with link data. If it starts with "A:", it calls theevaluate(Object, String)method to populate the table with attribute data. If it starts with "A:L:", it callscreateLinkData(ODT.Table)to populate the table with the first object from the link data. If none of the above conditions are met, the method returns without populating the table.- Parameters:
table- the table object to populate. The table object must not be removed or already built. The table's name should start with "A:" to be processed further. If conditions are satisfied, attributes or links are derived and used to populate the table.
-
getLinkCondition
Retrieves the condition associated with the specified link.Note: This is invoked when a table is processed for getting data.
- Parameters:
link- the link for which the condition is to be retrieved- Returns:
- the condition of the given link as a string, or null if no condition is associated
-
getLinkFilter
Generates a filter predicate for the specified link.Note: This is invoked when a table is processed for getting data.
- Parameters:
link- the link for which the filter predicate is generated- Returns:
- a predicate that determines whether a given object satisfies the link filter
-
createLinkData
Create the data for a link table.Note: The table name should start with "L:" followed by the link object's class name to be considered a link table.
- Parameters:
table- The table to populate.- Returns:
- List of linked objects or null if unable to create the link or table is invalid.
-
setImageCustomizer
Sets a customizer for images that enables tailored modifications or adjustments during their generation. The customizer is represented as aBiConsumerthat accepts aFillerinstance and anODT.Image.- Parameters:
imageCustomizer- ABiConsumerthat defines the customization logic for images. The first parameter is theFillerinstance associated with the operation, and the second parameter is theODT.Imageto be customized.
-