Interface ExtensionFieldHandler
-
public interface ExtensionFieldHandlerExtension field handler - Java API.
Supports custom value retrieval and calculation. Enables to define custom query operators and their evaluation.
Must be implemented as a NetbeansServiceProviderto be found.Example implementation - doubling molecular weight:
@ServiceProvider(service = ExtensionFieldHandler.class) public class DoubleMolWeightField implements ExtensionFieldHandler { private DFField molWeight; @Override public void init(DFField field, Map<String, Object> config) { molWeight = field.getEntity().getFields().findItemByName("Mol Weight"); } @Override public Class<?> getFieldClass() { return Double.class; } @Override public Set<DFField> getFieldDependencies(DFField field) { if (molWeight == null) { return Collections.emptySet(); } HashSet<DFField> ret = new HashSet<>(); ret.add(molWeight); return ret; } @Override public Object getValue(Comparable<?> rowId, Map<String, Object> inputRowData, DFField field) { if (molWeight == null) { return null; } Double value = (Double) inputRowData.get(molWeight.getId()); return value != null ? value * 2.0 : null; } }- Since:
- 21.16.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclearQuery()Called before query execution to clear any cache or previous results.default com.chemaxon.dif.query.spi.ExtensionFieldMatchercreateFieldMatcher(com.im.df.api.ddl.DFField field, com.im.df.api.dml.DFOperator operator, Map<String,Object> options, List<?> operands)Creates field matcher for in-memory operator evaluation.default Set<com.im.df.api.dml.DFOperator>customOperators(com.im.df.api.ddl.DFField field)Set of custom operators used by this field.default booleancustomValueCache()Does this field implement custom value cache?default ImagefindFieldIcon(int iconKind)Enables to define a custom icon.Class<?>getFieldClass()Java type of field values.default Set<com.im.df.api.ddl.DFField>getFieldDependencies(com.im.df.api.ddl.DFField field)Set of fields this Extension field depends on.default ObjectgetValue(Comparable<?> rowId, Map<String,Object> inputRowData, com.im.df.api.ddl.DFField field)Retrieves or calculates field value for given row id.default Map<Comparable<?>,Object>getValues(List<Comparable<?>> rowIds, Map<Comparable<?>,Map<String,Object>> inputData, com.im.df.api.ddl.DFField field)Retrieves field values for all row ids.default voidinit(com.im.df.api.ddl.DFField field, Map<String,Object> config)Passes configuration which was set in Extension field customizer.
-
-
-
Method Detail
-
init
default void init(com.im.df.api.ddl.DFField field, Map<String,Object> config)Passes configuration which was set in Extension field customizer.- Parameters:
field- Extension field which uses this handlerconfig- key-value configuration
-
getFieldClass
Class<?> getFieldClass()
Java type of field values. Type determines column renderer, available query operators, etc.- Returns:
- class of field values
-
getFieldDependencies
default Set<com.im.df.api.ddl.DFField> getFieldDependencies(com.im.df.api.ddl.DFField field)
Set of fields this Extension field depends on. Can be empty.- Parameters:
field- Extension field which uses this handler- Returns:
- set of field dependencies
-
getValue
default Object getValue(Comparable<?> rowId, Map<String,Object> inputRowData, com.im.df.api.ddl.DFField field)
Retrieves or calculates field value for given row id. Either implement this method orgetValues(java.util.List, java.util.Map, com.im.df.api.ddl.DFField).- Parameters:
rowId- row idinputRowData- Mapping of field ids and values. Supplies data from dependent fields.field- Extension field which uses this handler- Returns:
- field value for given row id
-
getValues
default Map<Comparable<?>,Object> getValues(List<Comparable<?>> rowIds, Map<Comparable<?>,Map<String,Object>> inputData, com.im.df.api.ddl.DFField field)
Retrieves field values for all row ids.- Parameters:
rowIds- row idsinputData- Mapping of row ids to fields ids and values. Supplies data from dependent fields.field- Extension field which uses this handler- Returns:
- mapping of row id to field value
-
customValueCache
default boolean customValueCache()
Does this field implement custom value cache?- Returns:
trueif field implements custom value cache,falseotherwise
-
customOperators
default Set<com.im.df.api.dml.DFOperator> customOperators(com.im.df.api.ddl.DFField field)
Set of custom operators used by this field. Can be empty.- Parameters:
field- Extension field which uses this handler- Returns:
- set of custom operators
-
createFieldMatcher
default com.chemaxon.dif.query.spi.ExtensionFieldMatcher createFieldMatcher(com.im.df.api.ddl.DFField field, com.im.df.api.dml.DFOperator operator, Map<String,Object> options, List<?> operands)Creates field matcher for in-memory operator evaluation.- Parameters:
field- Extension field which uses this handleroperator- custom operatoroptions- operator optionsoperands- operator parameters- Returns:
- extension field matcher
-
clearQuery
default void clearQuery()
Called before query execution to clear any cache or previous results.
-
findFieldIcon
default Image findFieldIcon(int iconKind)
Enables to define a custom icon.- Parameters:
iconKind- The kind of icon requested. This should be one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16 or ICON_MONO_32x32.- Returns:
- An image object representing the requested icon.
May return
nullif no suitable icon is available.
-
-