org.apache.log
Class ContextStack
java.lang.Object
org.apache.log.ContextStack
public class ContextStack
extends java.lang.Object
The ContextStack records the nested context of an application.
The context is an application defined characteristeric. For instance
a webserver context may be defined as the session that is currently
used to connect to server. A application may have context
defined by current thread. A applet may have it's context defined
by the name of the applet etc.
void | clear() - Empty the context stack.
|
Object | get(int index) - Get the context at a particular depth.
|
static ContextStack | getCurrentContext() - Get the Current ContextStack.
|
int | getSize() - Get the number of contexts in stack.
|
Object | pop() - Remove a context from top of stack and return it.
|
void | push(Object context) - Push the context onto top of context stack.
|
void | set(ContextStack stack) - Set the current ContextSet to be equl to other ContextStack.
|
String | toString() - Format context stack into a string.
|
String | toString(int count) - Format context stack into a string.
|
clear
public void clear()
Empty the context stack.
get
public Object get(int index)
Get the context at a particular depth.
index
- the depth of the context to retrieve
getCurrentContext
public static final ContextStack getCurrentContext()
Get the Current ContextStack.
This method returns a ContextStack associated with current thread. If the
thread doesn't have a ContextStack associated with it then a new
ContextStack is created with the name of thread as base context.
getSize
public int getSize()
Get the number of contexts in stack.
- the number of contexts in stack
pop
public Object pop()
Remove a context from top of stack and return it.
- the context that was on top of stack
push
public void push(Object context)
Push the context onto top of context stack.
context
- the context to place on stack
set
public void set(ContextStack stack)
Set the current ContextSet to be equl to other ContextStack.
stack
- the value to copy
toString
public String toString()
Format context stack into a string.
Each element in stack is printed out, separated by a '.' character.
- the string describing context stack
toString
public String toString(int count)
Format context stack into a string.
Only write a maximum of count elements, separated by '.' separator.
Note that elements in stack will have toString() called and every occurence
of spearator character '.' replaced with '_'.
- the string describing context stack