Package org.daisy.dotify.common.splitter
Class SplitPointDataList<T extends SplitPointUnit>
- java.lang.Object
-
- org.daisy.dotify.common.splitter.SplitPointDataList<T>
-
- Type Parameters:
T- the type of split point units
- All Implemented Interfaces:
SplitPointDataSource<T,SplitPointDataList<T>>
public final class SplitPointDataList<T extends SplitPointUnit> extends Object implements SplitPointDataSource<T,SplitPointDataList<T>>
Provides split point data.
-
-
Field Summary
Fields Modifier and Type Field Description static SplitPointDataListEMPTY_MANAGERProvides an empty manager.
-
Constructor Summary
Constructors Constructor Description SplitPointDataList()Creates a new instance with no units.SplitPointDataList(List<T> units)Creates a new instance with the specified units.SplitPointDataList(List<T> units, Supplements<T> supplements)Creates a new instance with the specified units and supplements.SplitPointDataList(T... units)Creates a new instance with the specified units.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SplitPointDataList<T>createEmpty()Creates a new empty data source of the implementing type.static <T extends SplitPointUnit>
SplitPointDataList<T>emptyManager()Returns an empty manager.Tget(int n)Gets the item at index.SplitPointDataList<T>getDataSource()Gets the data source as is, typically "return this".List<T>getRemaining()Gets all remaining items.intgetSize(int limit)Gets the size of the manager or the limit if the number of items is greater than the limit.Supplements<T>getSupplements()Gets the split point data source supplements.booleanhasElementAt(int index)Returns true if the manager has an element at the specified index.List<T>head(int toIndex)Gets the items before index.booleanisEmpty()Returns true if the manager contains no items.SplitResult<T,SplitPointDataList<T>>splitInRange(int atIndex)Gets the result of splitting at the specified index.SplitPointDataList<T>tail(int fromIndex)Gets a tail list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.daisy.dotify.common.splitter.SplitPointDataSource
split
-
-
-
-
Field Detail
-
EMPTY_MANAGER
public static final SplitPointDataList EMPTY_MANAGER
Provides an empty manager.
-
-
Constructor Detail
-
SplitPointDataList
@SafeVarargs public SplitPointDataList(T... units)
Creates a new instance with the specified units.- Parameters:
units- the units
-
SplitPointDataList
public SplitPointDataList(List<T> units)
Creates a new instance with the specified units.- Parameters:
units- the units
-
SplitPointDataList
public SplitPointDataList()
Creates a new instance with no units.
-
SplitPointDataList
public SplitPointDataList(List<T> units, Supplements<T> supplements)
Creates a new instance with the specified units and supplements.- Parameters:
units- the unitssupplements- the supplements
-
-
Method Detail
-
emptyManager
public static final <T extends SplitPointUnit> SplitPointDataList<T> emptyManager()
Returns an empty manager.- Type Parameters:
T- the type of split point units- Returns:
- returns an empty manager
-
getSupplements
public Supplements<T> getSupplements()
Description copied from interface:SplitPointDataSourceGets the split point data source supplements.- Specified by:
getSupplementsin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Returns:
- the supplements
-
hasElementAt
public boolean hasElementAt(int index)
Description copied from interface:SplitPointDataSourceReturns true if the manager has an element at the specified index.- Specified by:
hasElementAtin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Parameters:
index- the index- Returns:
- returns true if the manager has an element at the specified index, false otherwise
-
isEmpty
public boolean isEmpty()
Description copied from interface:SplitPointDataSourceReturns true if the manager contains no items. Note that this method can returns true, even ifSplitPointDataSource.getSupplements()is non-empty.- Specified by:
isEmptyin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Returns:
- returns true if the manager has no items, false otherwise
-
get
public T get(int n)
Description copied from interface:SplitPointDataSourceGets the item at index.- Specified by:
getin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Parameters:
n- the index- Returns:
- returns the item
-
head
public List<T> head(int toIndex)
Gets the items before index.- Parameters:
toIndex- the index, exclusive- Returns:
- returns a head list
- Throws:
IndexOutOfBoundsException- if the index is beyond the end of the stream
-
getRemaining
public List<T> getRemaining()
Description copied from interface:SplitPointDataSourceGets all remaining items. Note that using this method will result in all elements being computed, if this is not what is needed. Consider usingSplitPointDataSource.split(int)instead.- Specified by:
getRemainingin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Returns:
- returns all remaining items
-
tail
public SplitPointDataList<T> tail(int fromIndex)
Gets a tail list.- Parameters:
fromIndex- the starting index, inclusive- Returns:
- returns a new split point data source starting from fromIndex
- Throws:
IndexOutOfBoundsException- if the index is beyond the end of the stream
-
splitInRange
public SplitResult<T,SplitPointDataList<T>> splitInRange(int atIndex)
Description copied from interface:SplitPointDataSourceGets the result of splitting at the specified index.- Specified by:
splitInRangein interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Parameters:
atIndex- the index where the tail starts- Returns:
- returns a split result at the specified index
-
getSize
public int getSize(int limit)
Description copied from interface:SplitPointDataSourceGets the size of the manager or the limit if the number of items is greater than the limit.- Specified by:
getSizein interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Parameters:
limit- the limit- Returns:
- returns the size, or the limit
-
createEmpty
public SplitPointDataList<T> createEmpty()
Description copied from interface:SplitPointDataSourceCreates a new empty data source of the implementing type.- Specified by:
createEmptyin interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Returns:
- returns a new empty data source of the implementing type
-
getDataSource
public SplitPointDataList<T> getDataSource()
Description copied from interface:SplitPointDataSourceGets the data source as is, typically "return this".- Specified by:
getDataSourcein interfaceSplitPointDataSource<T extends SplitPointUnit,SplitPointDataList<T extends SplitPointUnit>>- Returns:
- returns the data source
-
-