Class FeatureIterator
java.lang.Object
org.apache.sis.internal.storage.csv.FeatureIterator
- All Implemented Interfaces:
Spliterator<AbstractFeature>
- Direct Known Subclasses:
MovingFeatureIterator
Base implementation of iterators returned by
Store.features(boolean). This base class returns one feature
per line. For example, iteration over the following file will produce 4 Feature instances, even if there is
actually only three distinct instances because the feature "a" is splitted on 2 lines:
Multi-threading: Iter is not thread-safe.
However, many Iter instances can be used concurrently for the same Store instance.- Since:
- 0.7
- Version:
- 0.8
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T extends Object,T_CONS extends Object, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ObjectConverter<String,?>[] Converters from string representations to the values to store in thevaluesarray.(package private) final String[]Name of the property where to store a value.private AtomicIntegerNumber of calls totrySplit().(package private) final StoreConnection to the CSV file.(package private) static final intIndex of the column containing trajectory coordinates.(package private) final Object[]All values found in a row.Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateFeatureIterator(FeatureIterator other) Creates a new iterator using the same configuration than the given iterator.(package private)FeatureIterator(Store store) Creates a new iterator. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the characteristics of the iteration over feature instances.longWe do not know the number of features.voidforEachRemaining(Consumer<? super AbstractFeature> action) Executes the given action on all remaining features.private booleanread(Consumer<? super AbstractFeature> action, boolean all) Executes the given action for the next feature or for all remaining features.booleantryAdvance(Consumer<? super AbstractFeature> action) Executes the given action only on the next feature, if any.trySplit()If this spliterator can be partitioned, returns aSpliteratorcovering elements.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
TRAJECTORY_COLUMN
static final int TRAJECTORY_COLUMNIndex of the column containing trajectory coordinates. Columns before the trajectory are Moving Feature identifiermfIdRef, start time and end time.- See Also:
-
store
Connection to the CSV file. -
propertyNames
Name of the property where to store a value. This array be considered unmodifiable and may be shared between manyIterinstances. -
converters
Converters from string representations to the values to store in thevaluesarray. This array be considered unmodifiable and may be shared between manyIterinstances. -
values
All values found in a row. We need to remember those values between different executions of thetryAdvance(Consumer)method because the Moving Feature Specification said: "If the value equals the previous value, the text for the value can be omitted." -
splitCount
Number of calls totrySplit(). Created only if needed.
-
-
Constructor Details
-
FeatureIterator
FeatureIterator(Store store) Creates a new iterator. -
FeatureIterator
Creates a new iterator using the same configuration than the given iterator. This constructor is fortrySplit()implementation only.
-
-
Method Details
-
trySplit
If this spliterator can be partitioned, returns aSpliteratorcovering elements. This method does not make any guarantees about iteration order; i.e. the returned iterator is not guaranteed to cover a strict prefix of the elements.- Specified by:
trySplitin interfaceSpliterator<AbstractFeature>
-
tryAdvance
Executes the given action only on the next feature, if any.- Specified by:
tryAdvancein interfaceSpliterator<AbstractFeature>
-
forEachRemaining
Executes the given action on all remaining features.- Specified by:
forEachRemainingin interfaceSpliterator<AbstractFeature>
-
read
Executes the given action for the next feature or for all remaining features. The features are assumed static, with one feature per line. This method is fortryAdvance(Consumer)andforEachRemaining(Consumer)implementations.Multi-threading
Iterdoes not need to be thread-safe, so we do not perform synchronization for itsvalues. Accesses toStorefields need to be thread-safe, but this method uses only immutable or thread-safe objects fromStore, so there is no need forsynchronize(Store.this)statement. The only object that need synchronization isStore.source, which is already synchronized.- Parameters:
action- the action to execute.all-truefor executing the given action on all remaining features.- Returns:
falseif there are no remaining features after this method call.- Throws:
IOException- if an I/O error occurred while reading a feature.IllegalArgumentException- if parsing of a number failed, or other error.DateTimeException- if parsing of a date failed.
-
estimateSize
public long estimateSize()We do not know the number of features.- Specified by:
estimateSizein interfaceSpliterator<AbstractFeature>
-
characteristics
public int characteristics()Returns the characteristics of the iteration over feature instances. The iteration isSpliterator.NONNULL(i.e.tryAdvance(Consumer)is not allowed to return null value) andSpliterator.IMMUTABLE(i.e. we do not support modification of the CSV file while an iteration is in progress). The iteration is not declaredSpliterator.ORDEREDbecausetrySplit()does not return a strict prefix of the elements.- Specified by:
characteristicsin interfaceSpliterator<AbstractFeature>- Returns:
- characteristics of iteration over the features in the CSV file.
-