public class DefaultFeatureIndex extends AbstractDisposable implements FeatureIndexProviderServices, WeakReferencingObservable
Constructor and Description |
---|
DefaultFeatureIndex(FeatureStoreProviderServices featureStore,
FeatureType featureType,
FeatureIndexProvider indexProvider,
String attributeName,
String indexName) |
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer observer) |
void |
delete(Feature feat)
Deletes a Feature in the index.
|
void |
delete(FeatureSet data)
Deletes a FeatureSet from this index
FeatureType is not checked so it will accept any FeatureType
as long as exists a column with a valid name
|
void |
deleteObserver(Observer observer) |
void |
deleteObservers() |
protected void |
doDispose()
Internal implementation for the
AbstractDisposable.dispose() method, to be
implemented by child classes. |
void |
fill()
Fills this index with the store's data.
|
void |
fill(boolean background,
Observer observer)
Fills this index with the store's data.
|
String |
getAttributeName() |
List |
getAttributeNames()
Attribute names
|
int |
getDataType()
Data type
|
FeatureAttributeDescriptor |
getFeatureAttributeDescriptor()
Column to which belongs this index
|
FeatureIndexProvider |
getFeatureIndexProvider() |
FeatureStoreProviderServices |
getFeatureStoreProviderServices()
FeatureStore to which belongs this index
|
FeatureType |
getFeatureType()
FeatureType to which belongs this index
|
String |
getFileName()
Returns the absolute path (directory + filename) where this index is or
will be stored
|
FeatureSet |
getMatchFeatureSet(Object value)
Returns a FeatureSet with the set of values that match the given value.
|
String |
getName()
Index name
|
FeatureSet |
getNearestFeatureSet(int count,
Object value)
Returns a FeatureSet with the set of up to
count values that are nearest to the given value. |
FeatureSet |
getNearestFeatureSet(int count,
Object value,
Object tolerance)
Returns a FeatureSet with the set of up to
count values whose distance to the given value
is not greater than tolerance |
String |
getNewFileName(String prefix,
String sufix)
Calculates and returns a new filename for an index, using the given
prefix and suffix
|
FeatureSet |
getRangeFeatureSet(Object value1,
Object value2)
Returns a FeatureSet with the set of values that belong to the range defined by value1 and value2.
|
String |
getTemporaryFileName()
Returns a temporary absolute path (directory + filename) according to the
system environment
|
void |
initialize()
Initializes this provider
|
void |
insert(Feature feat)
Inserts a Feature in the index.
|
void |
insert(FeatureSet data)
Inserts a FeatureSet into this index
FeatureType is not checked so it will accept any FeatureType
as long as exists a column with a valid name
|
boolean |
isFilling()
Returns if the index is in the process of being filled with the Features
of a store.
|
boolean |
isValid()
Returns if the index is valid and might be used to get Features.
|
void |
notifyObservers(Object notification) |
void |
setValid(boolean valid)
Sets the index as valid or invalid, so it may be used or not.
|
String |
toString() |
void |
waitForIndex()
If the index is in the process of being filled by a background task,
synchronize this method or add some mechanism for external callers to
block on it.
|
dispose, dispose
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dispose
public DefaultFeatureIndex(FeatureStoreProviderServices featureStore, FeatureType featureType, FeatureIndexProvider indexProvider, String attributeName, String indexName)
public final FeatureAttributeDescriptor getFeatureAttributeDescriptor()
FeatureIndexProviderServices
getFeatureAttributeDescriptor
in interface FeatureIndexProviderServices
public final FeatureStoreProviderServices getFeatureStoreProviderServices()
FeatureIndexProviderServices
getFeatureStoreProviderServices
in interface FeatureIndexProviderServices
public final FeatureType getFeatureType()
FeatureIndexProviderServices
getFeatureType
in interface FeatureIndexProviderServices
public final String getAttributeName()
public final int getDataType()
FeatureIndex
getDataType
in interface FeatureIndex
public void fill() throws FeatureIndexException
FeatureIndexProviderServices
fill
in interface FeatureIndexProviderServices
FeatureIndexException
- if there is an error while filling the indexpublic void fill(boolean background, Observer observer) throws FeatureIndexException
FeatureIndexProviderServices
fill
in interface FeatureIndexProviderServices
background
- if the filling must be performed in backgroundobserver
- optional observer to be notified when the
fill index operation finishesFeatureIndexException
- if there is an error while filling the indexFeatureStoreNotification.INDEX_FILLING_STARTED
,
FeatureStoreNotification.INDEX_FILLING_SUCCESS
,
FeatureStoreNotification.INDEX_FILLING_CANCELLED
,
FeatureStoreNotification.INDEX_FILLING_ERROR
public final void insert(FeatureSet data) throws DataException
FeatureIndex
insert
in interface FeatureIndex
DataException
public final void insert(Feature feat) throws DataException
FeatureIndex
insert
in interface FeatureIndex
DataException
public final void delete(FeatureSet data) throws FeatureIndexException
FeatureIndex
delete
in interface FeatureIndex
FeatureIndexException
public final void delete(Feature feat) throws DataException
FeatureIndex
delete
in interface FeatureIndex
DataException
public FeatureSet getMatchFeatureSet(Object value) throws FeatureIndexException
FeatureIndex
getMatchFeatureSet
in interface FeatureIndex
value
- is the value to match.FeatureIndexException
public FeatureSet getRangeFeatureSet(Object value1, Object value2) throws FeatureIndexException
FeatureIndex
getRangeFeatureSet
in interface FeatureIndex
value1
- range lower limit.value2
- range higher limit.FeatureIndexException
public FeatureSet getNearestFeatureSet(int count, Object value) throws FeatureIndexException
FeatureIndex
count
values that are nearest to the given value.getNearestFeatureSet
in interface FeatureIndex
count
- maximum number of values that their resulting FeatureSet will returnvalue
- the value around which the nearest count
will be looked up.count
values that are nearest to the given value.FeatureIndexException
public FeatureSet getNearestFeatureSet(int count, Object value, Object tolerance) throws FeatureIndexException
FeatureIndex
count
values whose distance to the given value
is not greater than tolerance
getNearestFeatureSet
in interface FeatureIndex
count
- maximum number of values that their resulting FeatureSet will returnvalue
- the value around which the nearest count
will be looked up.tolerance
- maximum distance from the given value.count
values that are nearest to the given value.FeatureIndexException
public void initialize() throws InitializeException
FeatureIndexProviderServices
initialize
in interface FeatureIndexProviderServices
InitializeException
public List getAttributeNames()
FeatureIndex
getAttributeNames
in interface FeatureIndex
public String getNewFileName(String prefix, String sufix)
FeatureIndexProviderServices
getNewFileName
in interface FeatureIndexProviderServices
public String getFileName()
FeatureIndexProviderServices
getFileName
in interface FeatureIndexProviderServices
public String getTemporaryFileName()
FeatureIndexProviderServices
getTemporaryFileName
in interface FeatureIndexProviderServices
public FeatureIndexProvider getFeatureIndexProvider()
public boolean isFilling()
FeatureIndex
isFilling
in interface FeatureIndex
public boolean isValid()
FeatureIndex
isValid
in interface FeatureIndex
public void waitForIndex()
FeatureIndexProviderServices
waitForIndex
in interface FeatureIndexProviderServices
public void setValid(boolean valid)
FeatureIndexProviderServices
setValid
in interface FeatureIndexProviderServices
valid
- status to set the index toprotected void doDispose() throws BaseException
AbstractDisposable
AbstractDisposable.dispose()
method, to be
implemented by child classes.doDispose
in class AbstractDisposable
BaseException
AbstractDisposable.dispose()
public void notifyObservers(Object notification)
public String getName()
FeatureIndex
getName
in interface FeatureIndex
public void addObserver(Observer observer)
addObserver
in interface Observable
public void deleteObserver(Observer observer)
deleteObserver
in interface Observable
public void deleteObservers()
deleteObservers
in interface Observable