public class DefaultThreadContextStack extends Objectimplements ThreadContextStack
org.apache.logging.log4j.spi.ThreadContextStack in which all mutative operations (add, pop, and so on) are implemented by making a fresh copy of the underlying list.
| Constructor and Description |
|---|
DefaultThreadContextStack(boolean useStack)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(String
|
boolean |
addAll(Collection
|
List |
asList()
Returns all the elements in the stack in a List.
|
void |
clear()
|
boolean |
contains(Object
|
boolean |
containsAll(Collection
|
ThreadContextStack |
copy()
Returns a copy of the ContextStack.
|
boolean |
equals(Object
|
int |
getDepth()
Returns the number of elements in the stack.
|
ThreadContext |
getImmutableStackOrNull()
Returns a ContextStack with the same contents as this ContextStack or
null.
|
int |
hashCode()
|
boolean |
isEmpty()
|
Iterator |
iterator()
|
String |
peek()
Returns the element at the top of the stack without removing it or null if the stack is empty.
|
String |
pop()
Returns the element at the top of the stack.
|
void |
push(String
Pushes an element onto the stack.
|
boolean |
remove(Object
|
boolean |
removeAll(Collection
|
boolean |
retainAll(Collection
|
int |
size()
|
Object |
toArray()
|
<T> T[] |
toArray(T[] ts)
|
String |
toString()
|
void |
trim(int depth)
Trims elements from the end of the stack.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitparallelStream, removeIf, spliterator, streampublic boolean add(Strings)
public boolean addAll(Collection<? extends String > strings)
public List<String > asList()
ThreadContext.ContextStack
asList in interface
ThreadContext.ContextStack
public void clear()
public boolean contains(Objecto)
public boolean containsAll(Collection<?> objects)
public ThreadContextStackcopy()
ThreadContext.ContextStack
copy in interface
ThreadContext.ContextStack
public boolean equals(Objectobj)
public int getDepth()
ThreadContext.ContextStack
getDepth in interface
ThreadContext.ContextStack
public int hashCode()
public boolean isEmpty()
public Stringpeek()
ThreadContext.ContextStack
peek in interface
ThreadContext.ContextStack
public Stringpop()
ThreadContext.ContextStack
pop in interface
ThreadContext.ContextStack
public void push(Stringmessage)
ThreadContext.ContextStack
push in interface
ThreadContext.ContextStack
message - The element to add.
public boolean remove(Objecto)
public boolean removeAll(Collection<?> objects)
public boolean retainAll(Collection<?> objects)
public int size()
public Object[] toArray()
public <T> T[] toArray(T[] ts)
public StringtoString()
public void trim(int depth)
ThreadContext.ContextStack
trim in interface
ThreadContext.ContextStack
depth - The maximum number of items in the stack to keep.
public ThreadContext.ContextStack getImmutableStackOrNull()
ThreadContext.ContextStack
null. Attempts to modify the returned stack may or may not throw an exception, but will not affect the contents of this ContextStack.
getImmutableStackOrNull in interface
ThreadContext.ContextStack
null.