Class CmsHookList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.Deque<java.lang.String>, java.util.List<java.lang.String>, java.util.Queue<java.lang.String>
    Direct Known Subclasses:
    CmsHookListSearchCategory

    public abstract class CmsHookList
    extends java.util.LinkedList<java.lang.String>
    A list intended for subclassing that triggers "listlet" operations that may access a on a "peer" object that is provided by a template method to implement in subclasses.

    This is intended to react on modifications on List instances performed by CmsWidgetDialogParameter instances linked to them. Using normal list implementations makes it impossible to intervene in those list modification by the widget technology.

    "Listlet" operations are operations that are triggered upon modification of this list. They are called "on<methodName(>[e]d(<peerObject>, <argList>)" where <methodName> is the name of the original list operation that took place, "[e]d" stands for the past (operation took place), <peerObject> is the given class to perform reactions on (see constructors) and <argList> are the arguments of the original list method in that order.

    Currently only the operations used by CmsWidgetDialog (see implementation of CmsWidgetDialog.actionToggleElement()) are supported and sufficient for this purpose. More general usability enforces extending the pattern shown here.

    Since:
    6.0.0
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsHookList​(java.lang.Object peer)
      Creates an empty list.
      CmsHookList​(java.lang.Object peer, java.util.Collection<java.lang.String> c)
      Creates a list filled with all elements of the given argument.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, java.lang.String element)  
      boolean add​(java.lang.String o)  
      void clear()  
      java.lang.String get​(int index)  
      java.util.Iterator<java.lang.String> iterator()  
      protected abstract void onAdded​(java.lang.Object peer, int index, java.lang.Object element)
      React on the performed operation List.add(int, java.lang.Object) by informing argument peer.
      protected abstract void onAdded​(java.lang.Object peer, java.lang.Object o)
      React on the performed operation List.add(java.lang.Object) by informing argument peer.
      protected abstract void onClear​(java.lang.Object peer)
      React on the operation to come List.clear() by informing argument peer.
      protected abstract void onCleared​(java.lang.Object peer)
      React on the performed operation List.clear() by informing argument peer.
      protected abstract void onGetCall​(java.lang.Object peer, int index)
      React on the performed operation List.get(int) by informing argument peer.
      protected abstract void onIteratorCall​(java.lang.Object peer)
      React on the performed operation List.iterator() by informing argument peer.
      protected abstract void onRemoved​(java.lang.Object peer, int index)
      React on the performed operation List.remove(int) by informing argument peer.
      java.lang.String remove​(int index)  
      • Methods inherited from class java.util.LinkedList

        addAll, addAll, addFirst, addLast, clone, contains, descendingIterator, element, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, removeAll, retainAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode, isEmpty, listIterator, removeAll, replaceAll, retainAll, sort, subList
    • Constructor Detail

      • CmsHookList

        public CmsHookList​(java.lang.Object peer)
        Creates an empty list.

        Subclasses should increase "safety by design" by narrowing the type of peer.

        Parameters:
        peer - the object reactions on operations shall be made on in the "listlet" methods of subclasses
      • CmsHookList

        public CmsHookList​(java.lang.Object peer,
                           java.util.Collection<java.lang.String> c)
        Creates a list filled with all elements of the given argument.

        Subclasses should increase "safety by design" by narrowing the type of peer.

        Parameters:
        peer - the object reactions on operations shall be made on in the "listlet" methods of subclasses
        c - a collection with all values for this list
    • Method Detail

      • add

        public void add​(int index,
                        java.lang.String element)
        Specified by:
        add in interface java.util.List<java.lang.String>
        Overrides:
        add in class java.util.LinkedList<java.lang.String>
        See Also:
        List.add(int, java.lang.Object)
      • add

        public boolean add​(java.lang.String o)
        Specified by:
        add in interface java.util.Collection<java.lang.String>
        Specified by:
        add in interface java.util.Deque<java.lang.String>
        Specified by:
        add in interface java.util.List<java.lang.String>
        Specified by:
        add in interface java.util.Queue<java.lang.String>
        Overrides:
        add in class java.util.LinkedList<java.lang.String>
        See Also:
        Collection.add(java.lang.Object)
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.String>
        Specified by:
        clear in interface java.util.List<java.lang.String>
        Overrides:
        clear in class java.util.LinkedList<java.lang.String>
        See Also:
        Collection.clear()
      • get

        public java.lang.String get​(int index)
        Specified by:
        get in interface java.util.List<java.lang.String>
        Overrides:
        get in class java.util.LinkedList<java.lang.String>
        See Also:
        List.get(int)
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Specified by:
        iterator in interface java.util.Collection<java.lang.String>
        Specified by:
        iterator in interface java.util.Deque<java.lang.String>
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
        Specified by:
        iterator in interface java.util.List<java.lang.String>
        Overrides:
        iterator in class java.util.AbstractSequentialList<java.lang.String>
        See Also:
        Collection.iterator()
      • remove

        public java.lang.String remove​(int index)
        Specified by:
        remove in interface java.util.List<java.lang.String>
        Overrides:
        remove in class java.util.LinkedList<java.lang.String>
        See Also:
        List.remove(int)
      • onAdded

        protected abstract void onAdded​(java.lang.Object peer,
                                        int index,
                                        java.lang.Object element)
        React on the performed operation List.add(int, java.lang.Object) by informing argument peer.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index the element was added at
        element - the element that was added
      • onAdded

        protected abstract void onAdded​(java.lang.Object peer,
                                        java.lang.Object o)
        React on the performed operation List.add(java.lang.Object) by informing argument peer.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        o - the element that was successfully added
      • onClear

        protected abstract void onClear​(java.lang.Object peer)
        React on the operation to come List.clear() by informing argument peer.

        This is called before the actual clear operation takes place.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
      • onCleared

        protected abstract void onCleared​(java.lang.Object peer)
        React on the performed operation List.clear() by informing argument peer.

        This is called after the actual clear operation has taken place.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
      • onGetCall

        protected abstract void onGetCall​(java.lang.Object peer,
                                          int index)
        React on the performed operation List.get(int) by informing argument peer.

        Note that the call reult is only obtained in this instance but not given to the requesting client when this handler is invoked.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index of the Object to get
      • onIteratorCall

        protected abstract void onIteratorCall​(java.lang.Object peer)
        React on the performed operation List.iterator() by informing argument peer.

        Note that the iterator is only obtained but not given to the requesting client when this handler is invoked.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
      • onRemoved

        protected abstract void onRemoved​(java.lang.Object peer,
                                          int index)
        React on the performed operation List.remove(int) by informing argument peer.

        This is only invoked if the list operation was successful.

        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index where the value has been removed