Class PositionListBase<T,P extends IPositionHolder<T,P>>
java.lang.Object
com.vladsch.flexmark.experimental.util.collection.iteration.PositionListBase<T,P>
- Type Parameters:
T
- type of positionP
- type of position holder
- All Implemented Interfaces:
IPositionListener
,IPositionUpdater<T,
,P> IPreviewPositionListener
,Iterable<P>
- Direct Known Subclasses:
PositionList
public abstract class PositionListBase<T,P extends IPositionHolder<T,P>>
extends Object
implements Iterable<P>, IPositionUpdater<T,P>
Iterator for list positions allowing to iterate over current elements while inserting and deleting elements relative to current position
elements inserted at current position or at current + 1 position will skipped in the iteration allowing adding new elements which will not be part of the iteration
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NotNull PositionFactory<T,
P> private final @NotNull Stack<PositionListBase.FrameLevel>
private int
private final @NotNull WeakHashMap<IPositionListener,
Integer> private int
private @Nullable WeakHashMap<IPreviewPositionListener,
Boolean> -
Constructor Summary
ConstructorsConstructorDescriptionPositionListBase
(@NotNull List<T> list, @NotNull PositionFactory<T, P> factory) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
addAll
(int index, @NotNull PositionListBase<T, P> other) boolean
addAll
(int index, @NotNull Collection<? extends T> elements) boolean
addAll
(@NotNull PositionListBase<T, P> other) boolean
addAll
(@NotNull Collection<? extends T> elements) void
addPositionListener
(@NotNull IPositionListener listener) Add list edit listener for notifications of mods to the listvoid
After set NotificationBefore set Notificationvoid
clear()
void
closeFrame
(Object frameId) void
deleted
(int index, int count) delete Notificationvoid
deleting
(int index, int count) before delete Notificationboolean
get
(int index) getEnd()
getFirst()
getLast()
getList()
int
@NotNull String
int
getOrNull
(int index) <S extends T>
SgetPosition
(int index, @NotNull PositionAnchor anchor) int
int
hashCode()
void
inserted
(int index, int count) insert Notificationboolean
isEmpty()
boolean
iterator()
remove
(int index) void
remove
(int startIndex, int endIndex) void
removePositionListener
(@NotNull IPositionListener listener) Remove list edit listenerreversed()
int
size()
private void
throwIllegalStateWithOpenFrameTrace
(@Nullable StringBuilder out, PositionListBase.FrameLevel frame) void
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater
getPosition
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
myList
-
myListeners
-
myPreviewListeners
-
myFactory
-
myFrames
-
myLastFrameId
private int myLastFrameId -
myMaxListeners
private int myMaxListeners
-
-
Constructor Details
-
PositionListBase
public PositionListBase(@NotNull @NotNull List<T> list, @NotNull @NotNull PositionFactory<T, P> factory)
-
-
Method Details
-
getListeners
@TestOnly public int getListeners() -
getMaxListeners
@TestOnly public int getMaxListeners() -
getPreviewListeners
@TestOnly public int getPreviewListeners() -
addPositionListener
Add list edit listener for notifications of mods to the list- Specified by:
addPositionListener
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>> - Parameters:
listener
- listener
-
removePositionListener
Remove list edit listenerNOTE: removal is optional. Only weak refs are kept for the listener
- Specified by:
removePositionListener
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>> - Parameters:
listener
- listener
-
iterator
-
reversedIterator
-
reversed
-
iterator
- Specified by:
iterator
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>>
-
getList
- Specified by:
getList
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>>
-
isEmpty
public boolean isEmpty() -
isNotEmpty
public boolean isNotEmpty() -
get
-
getOrNull
-
getOrNull
-
openFrame
-
getListParentId
-
closeFrame
-
throwIllegalStateWithOpenFrameTrace
private void throwIllegalStateWithOpenFrameTrace(@Nullable @Nullable StringBuilder out, PositionListBase.FrameLevel frame) -
getPosition
- Specified by:
getPosition
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>>
-
unframe
- Specified by:
unframe
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>>
-
getFirst
-
getLast
-
getEnd
-
clear
public void clear()- Specified by:
clear
in interfaceIPositionUpdater<T,
P extends IPositionHolder<T, P>>
-
inserted
public void inserted(int index, int count) Description copied from interface:IPositionListener
insert Notification- Specified by:
inserted
in interfaceIPositionListener
- Parameters:
index
- at which insert was performed, list contents and size at this point are already updatedcount
- of elements inserted
-
deleted
public void deleted(int index, int count) Description copied from interface:IPositionListener
delete Notification- Specified by:
deleted
in interfaceIPositionListener
- Parameters:
index
- at which delete was performed, list contents and size at this point are already updatedcount
- of elements deleted
-
deleting
public void deleting(int index, int count) Description copied from interface:IPreviewPositionListener
before delete Notification- Specified by:
deleting
in interfaceIPreviewPositionListener
- Parameters:
index
- at which delete will be performed, list contents and size at this point have not changedcount
- of elements deleted
-
changing
Description copied from interface:IPreviewPositionListener
Before set NotificationNOTE: the returned class should be the same or a subclass of original object's class
- Specified by:
changing
in interfaceIPreviewPositionListener
- Parameters:
index
- at which set is being performed, list contents and size at this point are not updatedvalue
- new value for the element- Returns:
- value to use for setting the element
-
changed
Description copied from interface:IPreviewPositionListener
After set NotificationNOTE: the returned class should be the same or a subclass of original object's class
- Specified by:
changed
in interfaceIPreviewPositionListener
- Parameters:
index
- at which set is being performed, list contents and size at this point are already updatedoldValue
- value at index before settingnewValue
- value at index before setting
-
set
-
remove
-
remove
public void remove(int startIndex, int endIndex) -
add
-
add
-
addAll
-
addAll
-
addAll
-
addAll
-
size
public int size() -
equals
-
hashCode
public int hashCode()
-