public interface ILcdDataObjectIndexedModel extends ILcdModel
ILcdModel
whose elements can be retrieved efficiently via expression-based indices.
First an index must be created on the model, by specifying the list of expressions on which
the index should be based. The addIndex(java.util.List, boolean)
method will return an
ILcdDataObjectIndexedModel.IndexId
which can be used to identify the index later, when retrieving elements via
retrieveAllByIndex(com.luciad.model.ILcdDataObjectIndexedModel.IndexId, java.util.List)
or retrieveFirstByIndex(com.luciad.model.ILcdDataObjectIndexedModel.IndexId, java.util.List)
.
All elements in this model should implement ILcdDataObject
.
Expressions should be expressed in the data object expression language which is configured on
this
model using setDataObjectExpressionLanguage(com.luciad.datamodel.expression.ALcdDataObjectExpressionLanguage)
.
The model uses the TLcdDataObjectExpressionLanguage
by
default.
Two types of indices are supported:
ILcdModel.elementChanged(Object, int)
method: the evaluated expressions for an element may
already
have changed at the moment the elementChanged
method is called, and can thus not be used
to retrieve the element in the index.Modifier and Type | Interface and Description |
---|---|
static interface |
ILcdDataObjectIndexedModel.IndexId
An identifier for an index in an
ILcdDataObjectIndexedModel . |
ILcdModel.Query
FIRE_LATER, FIRE_NOW, NO_EVENT
Modifier and Type | Method and Description |
---|---|
ILcdDataObjectIndexedModel.IndexId |
addIndex(List<String> aExpressions,
boolean aIsUniqueIndex)
Creates a new index for the given list of expressions.
|
boolean |
canAddElement(Object aElement)
Returns
true if the specified element can be added to this model, false otherwise. |
boolean |
canAddIndex(List<String> aExpressions,
boolean aIsUniqueIndex)
Returns
true if an index can be created for the given list of expressions and
uniqueness flag, false otherwise. |
ALcdDataObjectExpressionLanguage |
getDataObjectExpressionLanguage()
Returns the expression language used to evaluate expressions defined in the indices of the
model.
|
Set<List<Object>> |
getIndexedValues(ILcdDataObjectIndexedModel.IndexId aIndex)
Returns the set of all unique expression value combinations which are present in the specified
index.
|
ILcdDataObjectIndexedModel.IndexId |
getIndexId(Set<String> aExpressions)
Returns the index id which corresponds to the given set of expressions, or
null
if no such index is available on this model. |
Set<ILcdDataObjectIndexedModel.IndexId> |
getIndexIds()
Returns the set of all indices which are currently available on this model.
|
void |
removeAllIndices()
Removes all indices from this model.
|
boolean |
removeIndex(ILcdDataObjectIndexedModel.IndexId aIndexId)
Removes the specified index from this model.
|
Collection<ILcdDataObject> |
retrieveAllByIndex(ILcdDataObjectIndexedModel.IndexId aIndexId,
List aExpressionValues)
Returns all model elements which match the given list of values for the expressions in the
given index.
|
ILcdDataObject |
retrieveFirstByIndex(ILcdDataObjectIndexedModel.IndexId aIndexId,
List aExpressionValues)
Returns a single model element which matches the given list of values for the expressions in
the given index, or
null if no such element exists in the model. |
void |
setDataObjectExpressionLanguage(ALcdDataObjectExpressionLanguage aExpressionLanguage)
Sets the expression language to be used for evaluating expressions defined in the indices of
the model.
|
addElement, addElements, addModelListener, all, canRemoveElement, dispose, elementChanged, elements, elementsChanged, filter, fireCollectedModelChanges, getModelDescriptor, getModelEncoder, getModelMetadata, getModelReference, query, removeAllElements, removeElement, removeElements, removeModelListener
close
boolean canAddElement(Object aElement)
true
if the specified element can be added to this model, false
otherwise.
Note that this method generally does not validate whether the specified element is expressed in the same model reference as this model. It is the responsibility of the user of this model to make sure this precondition is fulfilled when an element is added to this model.
In addition to any constraints imposed byILcdModel.canAddElement(Object)
, this method
also verifies whether:
ILcdDataObject
canAddElement
in interface ILcdModel
aElement
- the element to be verified.true
if the specified element can be added to this model, false
otherwise.Set<ILcdDataObjectIndexedModel.IndexId> getIndexIds()
addIndex(java.util.List,
boolean)
.addIndex(java.util.List, boolean)
ILcdDataObjectIndexedModel.IndexId getIndexId(Set<String> aExpressions)
null
if no such index is available on this model.
Note that, in case the set would be sorted, the order of expressions in the returned index id
may be different from the order in the set. It is the order of expressions in the returned
index id which determines the order of expression values to be passed to retrieveAllByIndex(com.luciad.model.ILcdDataObjectIndexedModel.IndexId, java.util.List)
and retrieveFirstByIndex(com.luciad.model.ILcdDataObjectIndexedModel.IndexId,
java.util.List)
.aExpressions
- the expressions for which an index id should be returned.null
if no
such index is available.boolean canAddIndex(List<String> aExpressions, boolean aIsUniqueIndex)
true
if an index can be created for the given list of expressions and
uniqueness flag, false
otherwise.
An index can be created if:
aExpressions
- a set of expressions defining the index.aIsUniqueIndex
- boolean flag indicating whether the index is unique (has at most one
element for each unique combination of expression values) or not.true
if an index can be created for the given list of expressions and
uniqueness flag, false
otherwise.NullPointerException
- if aExpressions == null
or one of the expressions in
aExpressions
is null
.ILcdDataObjectIndexedModel.IndexId addIndex(List<String> aExpressions, boolean aIsUniqueIndex)
aExpressions
- a set of expressions defining the index.aIsUniqueIndex
- boolean flag indicating whether the index is unique (has at most one
element for each unique combination of expression values) or not.NullPointerException
- if aExpressions == null
or one of the expressions in
aExpressions
is null
.IllegalArgumentException
- if !canAddIndex(aExpressions, aIsUniqueIndex)
boolean removeIndex(ILcdDataObjectIndexedModel.IndexId aIndexId)
aIndexId
- the index to be removed.true
if the specified index was successfully removed from this model, false
otherwise.NullPointerException
- if aIndexId == null
void removeAllIndices()
Collection<ILcdDataObject> retrieveAllByIndex(ILcdDataObjectIndexedModel.IndexId aIndexId, List aExpressionValues)
aExpressionValues
should contain a value for each expression in
aIndexId.getExpressions()
, where the value at position i specifies the value to which
the expression at position i, evaluated for each model element, should be compared to.
aExpressionValues
may contain null
values. A null
value will be
considered a match if the corresponding expression for the tested model element also evaluates
to null
.
If no elements match the specified expression values, an empty collection is returned.aIndexId
- the index describing the expressions to test for.aExpressionValues
- the list of values to be compared with the list of evaluated
expressions.NullPointerException
- if one of the arguments is null
.IllegalArgumentException
- if the specified index does not exist on this model, or
if aIndexId.getExpressions().size() !=
aExpressionValues().size()
ILcdDataObjectIndexedModel.IndexId.isUnique()
ILcdDataObject retrieveFirstByIndex(ILcdDataObjectIndexedModel.IndexId aIndexId, List aExpressionValues)
null
if no such element exists in the model.
The list of values in aExpressionValues
should contain a value for each expression in
aIndexId.getExpressions()
, where the value at position i specifies the value to which
the expression at position i, evaluated for each model element, should be compared to.
aExpressionValues
may contain null
values. A null
value will be
considered a match if the corresponding expression for the tested model element also evaluates
to null
.aIndexId
- the index describing the expressions to test for.aExpressionValues
- the list of values to be compared with the list of evaluated
expressions.null
if no such element exists in the model.NullPointerException
- if one of the arguments is null
.IllegalArgumentException
- if the specified index does not exist on this model, or if
aIndexId.getExpressions().size() !=
aExpressionValues().size()
ILcdDataObjectIndexedModel.IndexId.isUnique()
Set<List<Object>> getIndexedValues(ILcdDataObjectIndexedModel.IndexId aIndex)
aIndex
- the index for which to return the set of expression value combinations.IllegalArgumentException
- if the specified index does not exist on this model.ALcdDataObjectExpressionLanguage getDataObjectExpressionLanguage()
void setDataObjectExpressionLanguage(ALcdDataObjectExpressionLanguage aExpressionLanguage)
aExpressionLanguage
- the expression language used to evaluate expressions defined in the
indices of the model.IllegalArgumentException
- if one or more of the existing indices could not be rebuilt
with the specified expression language, either because the
expression language cannot parse one or more of the
expressions, or the new expression language maps multiple
objects on a single entry in a unique index.