public class FilterReasoner extends java.lang.Object implements RecordReasoner, java.io.Serializable
Reasoner which uses a DataFilter to determine when to augment a DataRecord. The record can be augmented in two ways - adding field values or setting them to preset values. The FilterReasoner maintains two DataRecords, the AddFields record and the SetFields record.
If a record is accepted by the DataFilter, it will augment the record. First, any field value from the AddFields record will be added to the record. Second, any field values which occur in the SetFields record will replace those in the original record. Therefore, if a field occurs in both the AddFields and SetFields records, the SetFields record takes precedence.
As an option, the FilterReasoner includes a clearSetFields
flag. If this flag is set, when a record does NOT match the data filter, it
will clear the field values matching the fields from the SetFields record.
This is particularly useful when the filter is a dynamic filter, such as a
GuiDataFilter.
Constructor and Description |
---|
FilterReasoner(DataFilter dataFilter)
Initialize the FilterReasoner with the data filter provided
|
Modifier and Type | Method and Description |
---|---|
boolean |
augmentRecord(DataRecord rec)
Augment the DataRecord.
|
void |
setAddFieldsRecord(DataRecord rec)
Set the AddFields record
|
void |
setClearSetFields(boolean flag)
Set a flag whether to clear the Set fields if a record does not match.
|
void |
setSetFieldsRecord(DataRecord rec)
Set the SetFields record
|
public FilterReasoner(DataFilter dataFilter)
dataFilter
- the DataFilter to use as a filter.public boolean augmentRecord(DataRecord rec)
augmentRecord
in interface RecordReasoner
rec
- the DataRecord to augmentpublic void setAddFieldsRecord(DataRecord rec)
rec
- the AddFields recordpublic void setClearSetFields(boolean flag)
GuiDataFilter
.flag
- if true, and a record does not match the filter, any record
fields which occur in the SetFields record will be cleared. Tpublic void setSetFieldsRecord(DataRecord rec)
rec
- the SetFields record