public class DefaultThreadContextStack extends Object implements ThreadContextStack, StringBuilderFormattable
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 s) |
boolean |
addAll(Collection<? extends String> strings) |
List<String> |
asList()
Returns all the elements in the stack in a List.
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> objects) |
ThreadContextStack |
copy()
Returns a copy of the ContextStack.
|
boolean |
equals(Object obj) |
void |
formatTo(StringBuilder buffer)
Writes a text representation of this object into the specified
StringBuilder , ideally without allocating
temporary objects. |
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() |
Iterator<String> |
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 message)
Pushes an element onto the stack.
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> objects) |
boolean |
retainAll(Collection<?> objects) |
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, wait
parallelStream, removeIf, spliterator, stream
public boolean add(String s)
add
in interface Collection<String>
public boolean addAll(Collection<? extends String> strings)
addAll
in interface Collection<String>
public List<String> asList()
ThreadContext.ContextStack
asList
in interface ThreadContext.ContextStack
public void clear()
clear
in interface Collection<String>
public boolean contains(Object o)
contains
in interface Collection<String>
public boolean containsAll(Collection<?> objects)
containsAll
in interface Collection<String>
public ThreadContextStack copy()
ThreadContext.ContextStack
copy
in interface ThreadContext.ContextStack
public boolean equals(Object obj)
equals
in interface Collection<String>
equals
in class Object
public int getDepth()
ThreadContext.ContextStack
getDepth
in interface ThreadContext.ContextStack
public int hashCode()
hashCode
in interface Collection<String>
hashCode
in class Object
public boolean isEmpty()
isEmpty
in interface Collection<String>
public String peek()
ThreadContext.ContextStack
peek
in interface ThreadContext.ContextStack
public String pop()
ThreadContext.ContextStack
pop
in interface ThreadContext.ContextStack
public void push(String message)
ThreadContext.ContextStack
push
in interface ThreadContext.ContextStack
message
- The element to add.public boolean remove(Object o)
remove
in interface Collection<String>
public boolean removeAll(Collection<?> objects)
removeAll
in interface Collection<String>
public boolean retainAll(Collection<?> objects)
retainAll
in interface Collection<String>
public int size()
size
in interface Collection<String>
public Object[] toArray()
toArray
in interface Collection<String>
public <T> T[] toArray(T[] ts)
toArray
in interface Collection<String>
public void formatTo(StringBuilder buffer)
StringBuilderFormattable
StringBuilder
, ideally without allocating
temporary objects.formatTo
in interface StringBuilderFormattable
buffer
- the StringBuilder to write intopublic 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
.Copyright © 2021 JBoss by Red Hat. All rights reserved.