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,java.lang.Iterable<P>
- Direct Known Subclasses:
PositionList
public abstract class PositionListBase<T,P extends IPositionHolder<T,P>> extends java.lang.Object implements java.lang.Iterable<P>, IPositionUpdater<T,P>
Iterator for list positions allowing to iterate over current elements while inserting and deleting elements relative to current positionelements 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 Modifier and Type Class Description private static classPositionListBase.FrameLevel
-
Field Summary
Fields Modifier and Type Field Description private @NotNull PositionFactory<T,P>myFactoryprivate @NotNull java.util.Stack<PositionListBase.FrameLevel>myFramesprivate intmyLastFrameIdprivate @NotNull java.util.List<T>myListprivate @NotNull java.util.WeakHashMap<IPositionListener,java.lang.Integer>myListenersprivate intmyMaxListenersprivate @Nullable java.util.WeakHashMap<IPreviewPositionListener,java.lang.Boolean>myPreviewListeners
-
Constructor Summary
Constructors Constructor Description PositionListBase(@NotNull java.util.List<T> list, @NotNull PositionFactory<T,P> factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int index, T element)booleanadd(T element)booleanaddAll(int index, @NotNull PositionListBase<T,P> other)booleanaddAll(int index, @NotNull java.util.Collection<? extends T> elements)booleanaddAll(@NotNull PositionListBase<T,P> other)booleanaddAll(@NotNull java.util.Collection<? extends T> elements)voidaddPositionListener(@NotNull IPositionListener listener)Add list edit listener for notifications of mods to the listvoidchanged(int index, java.lang.Object oldValue, java.lang.Object newValue)After set Notificationjava.lang.Objectchanging(int index, java.lang.Object value)Before set Notificationvoidclear()voidcloseFrame(java.lang.Object frameId)voiddeleted(int index, int count)delete Notificationvoiddeleting(int index, int count)before delete Notificationbooleanequals(java.lang.Object o)Tget(int index)PgetEnd()PgetFirst()PgetLast()@NotNull java.util.List<T>getList()intgetListeners()@NotNull java.lang.StringgetListParentId()intgetMaxListeners()TgetOrNull(int index)<S extends T>
SgetOrNull(int index, java.lang.Class<S> elementClass)PgetPosition(int index, @NotNull PositionAnchor anchor)intgetPreviewListeners()inthashCode()voidinserted(int index, int count)insert NotificationbooleanisEmpty()booleanisNotEmpty()@NotNull java.util.Iterator<P>iterator()@NotNull java.util.Iterator<P>iterator(P position)java.lang.ObjectopenFrame()Tremove(int index)voidremove(int startIndex, int endIndex)voidremovePositionListener(@NotNull IPositionListener listener)Remove list edit listener@NotNull java.lang.Iterable<P>reversed()@NotNull java.util.Iterator<P>reversedIterator()Tset(int index, T value)intsize()private voidthrowIllegalStateWithOpenFrameTrace(@Nullable java.lang.StringBuilder out, PositionListBase.FrameLevel frame)voidunframe(P position)-
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
-
-
-
-
Field Detail
-
myList
@NotNull private final @NotNull java.util.List<T> myList
-
myListeners
@NotNull private final @NotNull java.util.WeakHashMap<IPositionListener,java.lang.Integer> myListeners
-
myPreviewListeners
@Nullable private @Nullable java.util.WeakHashMap<IPreviewPositionListener,java.lang.Boolean> myPreviewListeners
-
myFactory
@NotNull private final @NotNull PositionFactory<T,P extends IPositionHolder<T,P>> myFactory
-
myFrames
@NotNull private final @NotNull java.util.Stack<PositionListBase.FrameLevel> myFrames
-
myLastFrameId
private int myLastFrameId
-
myMaxListeners
private int myMaxListeners
-
-
Constructor Detail
-
PositionListBase
public PositionListBase(@NotNull @NotNull java.util.List<T> list, @NotNull @NotNull PositionFactory<T,P> factory)
-
-
Method Detail
-
getListeners
@TestOnly public int getListeners()
-
getMaxListeners
@TestOnly public int getMaxListeners()
-
getPreviewListeners
@TestOnly public int getPreviewListeners()
-
addPositionListener
public void addPositionListener(@NotNull @NotNull IPositionListener listener)Add list edit listener for notifications of mods to the list- Specified by:
addPositionListenerin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>- Parameters:
listener- listener
-
removePositionListener
public void removePositionListener(@NotNull @NotNull IPositionListener listener)Remove list edit listenerNOTE: removal is optional. Only weak refs are kept for the listener
- Specified by:
removePositionListenerin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>- Parameters:
listener- listener
-
iterator
@NotNull public @NotNull java.util.Iterator<P> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
reversedIterator
@NotNull public @NotNull java.util.Iterator<P> reversedIterator()
-
reversed
@NotNull public @NotNull java.lang.Iterable<P> reversed()
-
iterator
@NotNull public @NotNull java.util.Iterator<P> iterator(@NotNull P position)
- Specified by:
iteratorin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>
-
getList
@NotNull public @NotNull java.util.List<T> getList()
- Specified by:
getListin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>
-
isEmpty
public boolean isEmpty()
-
isNotEmpty
public boolean isNotEmpty()
-
get
public T get(int index)
-
getOrNull
public T getOrNull(int index)
-
getOrNull
public <S extends T> S getOrNull(int index, java.lang.Class<S> elementClass)
-
openFrame
public java.lang.Object openFrame()
-
getListParentId
@NotNull public @NotNull java.lang.String getListParentId()
-
closeFrame
public void closeFrame(java.lang.Object frameId)
-
throwIllegalStateWithOpenFrameTrace
private void throwIllegalStateWithOpenFrameTrace(@Nullable @Nullable java.lang.StringBuilder out, PositionListBase.FrameLevel frame)
-
getPosition
public P getPosition(int index, @NotNull @NotNull PositionAnchor anchor)
- Specified by:
getPositionin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>
-
unframe
public void unframe(P position)
- Specified by:
unframein interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>
-
getFirst
public P getFirst()
-
getLast
public P getLast()
-
getEnd
public P getEnd()
-
clear
public void clear()
- Specified by:
clearin interfaceIPositionUpdater<T,P extends IPositionHolder<T,P>>
-
inserted
public void inserted(int index, int count)Description copied from interface:IPositionListenerinsert Notification- Specified by:
insertedin 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:IPositionListenerdelete Notification- Specified by:
deletedin 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:IPreviewPositionListenerbefore delete Notification- Specified by:
deletingin interfaceIPreviewPositionListener- Parameters:
index- at which delete will be performed, list contents and size at this point have not changedcount- of elements deleted
-
changing
public java.lang.Object changing(int index, java.lang.Object value)Description copied from interface:IPreviewPositionListenerBefore set NotificationNOTE: the returned class should be the same or a subclass of original object's class
- Specified by:
changingin 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
public void changed(int index, java.lang.Object oldValue, java.lang.Object newValue)Description copied from interface:IPreviewPositionListenerAfter set NotificationNOTE: the returned class should be the same or a subclass of original object's class
- Specified by:
changedin 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
-
remove
public T remove(int index)
-
remove
public void remove(int startIndex, int endIndex)
-
add
public boolean add(T element)
-
add
public boolean add(int index, T element)
-
addAll
public boolean addAll(@NotNull @NotNull PositionListBase<T,P> other)
-
addAll
public boolean addAll(int index, @NotNull @NotNull PositionListBase<T,P> other)
-
addAll
public boolean addAll(@NotNull @NotNull java.util.Collection<? extends T> elements)
-
addAll
public boolean addAll(int index, @NotNull @NotNull java.util.Collection<? extends T> elements)
-
size
public int size()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-