Top Description Inners Fields Constructors Methods
com.vladsch.flexmark.experimental.util.collection.iteration

public abstract Class PositionListBase<T, P extends IPositionHolder<T, P>>

extends Object
implements Iterable<P extends IPositionHolder<T, P>>, IPositionUpdater<T, P extends IPositionHolder<T, P>>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater, com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener, com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener, java.lang.Iterable
Known Direct Subclasses
com.vladsch.flexmark.experimental.util.collection.iteration.PositionList
Type Parameters
<T>
type of position
<P>
type of position holder
Imports
com.vladsch.flexmark.util.misc.Utils, com.vladsch.flexmark.util.sequence.PositionAnchor, .RepeatedSequence, org.jetbrains.annotations.NotNull, .Nullable, .TestOnly, java.util.*

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final @NotNull PositionFactory<T, P>
private final @NotNull Stack<PositionListBase.FrameLevel>
private int
private final @NotNull List<T>
private final @NotNull WeakHashMap<IPositionListener, Integer>
private int
private @Nullable WeakHashMap<IPreviewPositionListener, Boolean>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(T element)

public boolean
add(int index, T element)

public boolean
public boolean
addAll(int index, @NotNull PositionListBase<T, P> other)

public boolean
addAll(@NotNull Collection<? extends T> elements)

public boolean
addAll(int index, @NotNull Collection<? extends T> elements)

public void
addPositionListener(@NotNull IPositionListener
listener
listener
)

Add list edit listener for notifications of mods to the list

public void
changed(int
at which set is being performed, list contents and size at this point are already updated
index
,
Object
value at index before setting
oldValue
,
Object
value at index before setting
newValue
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changed.

After set Notification

Note

the returned class should be the same or a subclass of original object's class

public Object
changing(int
at which set is being performed, list contents and size at this point are not updated
index
,
Object
new value for the element
value
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changing.

Before set Notification

Note

the returned class should be the same or a subclass of original object's class

public void
public void
closeFrame(Object frameId)

public void
deleted(int
at which delete was performed, list contents and size at this point are already updated
index
,
int
of elements deleted
count
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.deleted.

delete Notification

public void
deleting(int
at which delete will be performed, list contents and size at this point have not changed
index
,
int
of elements deleted
count
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.deleting.

before delete Notification

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public T
get(int index)

public P
public P
public P
public @NotNull List<T>
public int
public @NotNull String
public int
public T
getOrNull(int index)

public <S extends T> S
getOrNull(int index, Class<S> elementClass)

public P
getPosition(int index, @NotNull PositionAnchor anchor)

public int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
inserted(int
at which insert was performed, list contents and size at this point are already updated
index
,
int
of elements inserted
count
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.inserted.

insert Notification

public boolean
public boolean
public @NotNull Iterator<P>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public @NotNull Iterator<P>
public Object
public T
remove(int index)

public void
remove(int startIndex, int endIndex)

public void
removePositionListener(@NotNull IPositionListener
listener
listener
)

Remove list edit listener

Note

removal is optional.

public @NotNull Iterable<P>
public @NotNull Iterator<P>
public T
set(int index, T value)

public int
size()

private void
public void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

myFactoryback to summary
private final @NotNull PositionFactory<T, P> myFactory
Annotations
@NotNull
myFramesback to summary
private final @NotNull Stack<PositionListBase.FrameLevel> myFrames
Annotations
@NotNull
myLastFrameIdback to summary
private int myLastFrameId
myListback to summary
private final @NotNull List<T> myList
Annotations
@NotNull
myListenersback to summary
private final @NotNull WeakHashMap<IPositionListener, Integer> myListeners
Annotations
@NotNull
myMaxListenersback to summary
private int myMaxListeners
myPreviewListenersback to summary
private @Nullable WeakHashMap<IPreviewPositionListener, Boolean> myPreviewListeners
Annotations
@Nullable

Constructor Detail

PositionListBaseback to summary
public PositionListBase(@NotNull List<T> list, @NotNull PositionFactory<T, P> factory)

Method Detail

addback to summary
public boolean add(T element)
addback to summary
public boolean add(int index, T element)
Annotations
@SuppressWarnings:UnusedReturnValue
addAllback to summary
public boolean addAll(@NotNull PositionListBase<T, P> other)
addAllback to summary
public boolean addAll(int index, @NotNull PositionListBase<T, P> other)
addAllback to summary
public boolean addAll(@NotNull Collection<? extends T> elements)
addAllback to summary
public boolean addAll(int index, @NotNull Collection<? extends T> elements)
addPositionListenerback to summary
public void addPositionListener(@NotNull IPositionListener listener)

Add list edit listener for notifications of mods to the list

Parameters
listener:@NotNull IPositionListener

listener

Annotations
@Override
changedback to summary
public void changed(int index, Object oldValue, Object newValue)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changed.

Doc from com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changed.

After set Notification

Note

the returned class should be the same or a subclass of original object's class

Parameters
index:int

at which set is being performed, list contents and size at this point are already updated

oldValue:Object

value at index before setting

newValue:Object

value at index before setting

Annotations
@Override
changingback to summary
public Object changing(int index, Object value)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changing.

Doc from com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.changing.

Before set Notification

Note

the returned class should be the same or a subclass of original object's class

Parameters
index:int

at which set is being performed, list contents and size at this point are not updated

value:Object

new value for the element

Returns:Object

value to use for setting the element

Annotations
@Override
clearback to summary
public void clear()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater.clear.

Annotations
@Override
closeFrameback to summary
public void closeFrame(Object frameId)
deletedback to summary
public void deleted(int index, int count)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.deleted.

Doc from com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.deleted.

delete Notification

Parameters
index:int

at which delete was performed, list contents and size at this point are already updated

count:int

of elements deleted

Annotations
@Override
deletingback to summary
public void deleting(int index, int count)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.deleting.

Doc from com.vladsch.flexmark.experimental.util.collection.iteration.IPreviewPositionListener.deleting.

before delete Notification

Parameters
index:int

at which delete will be performed, list contents and size at this point have not changed

count:int

of elements deleted

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public T get(int index)
getEndback to summary
public P getEnd()
getFirstback to summary
public P getFirst()
getLastback to summary
public P getLast()
getListback to summary
public @NotNull List<T> getList()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater.getList.

Annotations
@NotNull
getListenersback to summary
public int getListeners()
Annotations
@TestOnly
getListParentIdback to summary
public @NotNull String getListParentId()
Annotations
@NotNull
getMaxListenersback to summary
public int getMaxListeners()
Annotations
@TestOnly
getOrNullback to summary
public T getOrNull(int index)
getOrNullback to summary
public <S extends T> S getOrNull(int index, Class<S> elementClass)
getPositionback to summary
public P getPosition(int index, @NotNull PositionAnchor anchor)
Annotations
@Override
getPreviewListenersback to summary
public int getPreviewListeners()
Annotations
@TestOnly
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
insertedback to summary
public void inserted(int index, int count)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.inserted.

Doc from com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.inserted.

insert Notification

Parameters
index:int

at which insert was performed, list contents and size at this point are already updated

count:int

of elements inserted

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()
isNotEmptyback to summary
public boolean isNotEmpty()
iteratorback to summary
public @NotNull Iterator<P> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:@NotNull Iterator<P>

an Iterator.

Annotations
@NotNull
iteratorback to summary
public @NotNull Iterator<P> iterator(P position)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater.iterator.

Annotations
@NotNull
openFrameback to summary
public Object openFrame()
removeback to summary
public T remove(int index)
removeback to summary
public void remove(int startIndex, int endIndex)
removePositionListenerback to summary
public void removePositionListener(@NotNull IPositionListener listener)

Remove list edit listener

Note

removal is optional. Only weak refs are kept for the listener

Parameters
listener:@NotNull IPositionListener

listener

Annotations
@Override
reversedback to summary
public @NotNull Iterable<P> reversed()
Annotations
@NotNull
reversedIteratorback to summary
public @NotNull Iterator<P> reversedIterator()
Annotations
@NotNull
setback to summary
public T set(int index, T value)
sizeback to summary
public int size()
throwIllegalStateWithOpenFrameTraceback to summary
private void throwIllegalStateWithOpenFrameTrace(@Nullable StringBuilder out, PositionListBase.FrameLevel frame)
unframeback to summary
public void unframe(P position)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionUpdater.unframe.

Annotations
@Override
com.vladsch.flexmark.experimental.util.collection.iteration back to summary

private Class PositionListBase.FrameLevel

extends Object
Class Inheritance
  • java.lang.Object
  • com.vladsch.flexmark.experimental.util.collection.iteration.PositionListBase.FrameLevel

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final int
pack-priv final StackTraceElement[]
pack-priv final @Nullable PositionListBase.FrameLevel
pack-priv final @NotNull String

Constructor Summary

AccessConstructor and Description
public
FrameLevel(@NotNull String parentList, @Nullable PositionListBase.FrameLevel parentFrame, int frameId, StackTraceElement[] openStackTrace)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

frameIdback to summary
pack-priv final int frameId
frameLevelback to summary
pack-priv final int frameLevel
openStackTraceback to summary
pack-priv final StackTraceElement[] openStackTrace
parentFrameback to summary
pack-priv final @Nullable PositionListBase.FrameLevel parentFrame
Annotations
@Nullable
parentListback to summary
pack-priv final @NotNull String parentList
Annotations
@NotNull

Constructor Detail

FrameLevelback to summary
public FrameLevel(@NotNull String parentList, @Nullable PositionListBase.FrameLevel parentFrame, int frameId, StackTraceElement[] openStackTrace)

Method Detail

appendStackTraceback to summary
pack-priv void appendStackTrace(@NotNull StringBuilder out, @NotNull CharSequence indent, int stackOffset)
isDescendantOfback to summary
pack-priv boolean isDescendantOf(@NotNull PositionListBase.FrameLevel parentFrame)