org.apache.log

Class 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.
Author:
Peter Donald

Method Summary

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.

Method Details

clear

public void clear()
Empty the context stack.

get

public Object get(int index)
Get the context at a particular depth.
Parameters:
index - the depth of the context to retrieve
Returns:
the context

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.
Returns:
the current ContextStack

getSize

public int getSize()
Get the number of contexts in stack.
Returns:
the number of contexts in stack

pop

public Object pop()
Remove a context from top of stack and return it.
Returns:
the context that was on top of stack

push

public void push(Object context)
Push the context onto top of context stack.
Parameters:
context - the context to place on stack

set

public void set(ContextStack stack)
Set the current ContextSet to be equl to other ContextStack.
Parameters:
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.
Returns:
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 '_'.
Returns:
the string describing context stack