Class MutableThreadContextStack

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, ThreadContextStack, ThreadContext.ContextStack, org.apache.logging.log4j.util.StringBuilderFormattable

    public class MutableThreadContextStack
    extends java.lang.Object
    implements ThreadContextStack, org.apache.logging.log4j.util.StringBuilderFormattable
    TODO
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.String s)  
      boolean addAll​(java.util.Collection<? extends java.lang.String> strings)  
      java.util.List<java.lang.String> asList()
      Returns all the elements in the stack in a List.
      void clear()  
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> objects)  
      ThreadContextStack copy()
      Returns a copy of the ContextStack.
      boolean equals​(java.lang.Object obj)  
      void formatTo​(java.lang.StringBuilder buffer)  
      void freeze()
      "Freezes" this context stack so it becomes immutable: all mutator methods will throw an exception from now on.
      int getDepth()
      Returns the number of elements in the stack.
      ThreadContext.ContextStack getImmutableStackOrNull()
      Returns a ContextStack with the same contents as this ContextStack or null.
      int hashCode()  
      boolean isEmpty()  
      boolean isFrozen()
      Returns whether this context stack is frozen.
      java.util.Iterator<java.lang.String> iterator()  
      java.lang.String peek()
      Returns the element at the top of the stack without removing it or null if the stack is empty.
      java.lang.String pop()
      Returns the element at the top of the stack.
      void push​(java.lang.String message)
      Pushes an element onto the stack.
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> objects)  
      boolean retainAll​(java.util.Collection<?> objects)  
      int size()  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] ts)  
      java.lang.String toString()  
      void trim​(int depth)
      Trims elements from the end of the stack.
      • Methods inherited from class java.lang.Object

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

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

        forEach
    • Constructor Detail

      • MutableThreadContextStack

        public MutableThreadContextStack()
        Constructs an empty MutableThreadContextStack.
      • MutableThreadContextStack

        public MutableThreadContextStack​(java.util.List<java.lang.String> list)
        Constructs a new instance.
        Parameters:
        list -
    • Method Detail

      • peek

        public java.lang.String peek()
        Description copied from interface: ThreadContext.ContextStack
        Returns the element at the top of the stack without removing it or null if the stack is empty.
        Specified by:
        peek in interface ThreadContext.ContextStack
        Returns:
        the element at the top of the stack or null if the stack is empty.
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.String>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.String>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<java.lang.String>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<java.lang.String>
      • 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.lang.Iterable<java.lang.String>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<java.lang.String>
      • toArray

        public <T> T[] toArray​(T[] ts)
        Specified by:
        toArray in interface java.util.Collection<java.lang.String>
      • add

        public boolean add​(java.lang.String s)
        Specified by:
        add in interface java.util.Collection<java.lang.String>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<java.lang.String>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> objects)
        Specified by:
        containsAll in interface java.util.Collection<java.lang.String>
      • addAll

        public boolean addAll​(java.util.Collection<? extends java.lang.String> strings)
        Specified by:
        addAll in interface java.util.Collection<java.lang.String>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> objects)
        Specified by:
        removeAll in interface java.util.Collection<java.lang.String>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> objects)
        Specified by:
        retainAll in interface java.util.Collection<java.lang.String>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • formatTo

        public void formatTo​(java.lang.StringBuilder buffer)
        Specified by:
        formatTo in interface org.apache.logging.log4j.util.StringBuilderFormattable
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<java.lang.String>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<java.lang.String>
        Overrides:
        equals in class java.lang.Object
      • getImmutableStackOrNull

        public ThreadContext.ContextStack getImmutableStackOrNull()
        Description copied from interface: ThreadContext.ContextStack
        Returns a ContextStack with the same contents as this ContextStack or null. Attempts to modify the returned stack may or may not throw an exception, but will not affect the contents of this ContextStack.
        Specified by:
        getImmutableStackOrNull in interface ThreadContext.ContextStack
        Returns:
        a ContextStack with the same contents as this ContextStack or null.
      • freeze

        public void freeze()
        "Freezes" this context stack so it becomes immutable: all mutator methods will throw an exception from now on.
      • isFrozen

        public boolean isFrozen()
        Returns whether this context stack is frozen.
        Returns:
        whether this context stack is frozen.