Files
HRMS/hrmsEjb/net/sf/jasperreports/engine/util/ThreadLocalStack.java
2025-07-28 13:56:49 +05:30

38 lines
856 B
Java

package net.sf.jasperreports.engine.util;
import java.util.LinkedList;
public class ThreadLocalStack {
private final ThreadLocal threadStack = new ThreadLocal();
public void push(Object o) {
LinkedList stack = this.threadStack.get();
if (stack == null) {
stack = new LinkedList();
this.threadStack.set(stack);
}
stack.addFirst(o);
}
public Object top() {
Object o = null;
LinkedList stack = this.threadStack.get();
if (stack != null && !stack.isEmpty())
o = stack.getFirst();
return o;
}
public Object pop() {
Object o = null;
LinkedList stack = this.threadStack.get();
if (stack != null)
o = stack.removeFirst();
return o;
}
public boolean empty() {
LinkedList stack = this.threadStack.get();
return (stack == null || stack.isEmpty());
}
}