Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 28 package net.sf.jasperreports.engine.util; 29 30 import java.util.LinkedList ; 31 32 33 39 public class ThreadLocalStack 40 { 41 private final ThreadLocal threadStack; 42 43 public ThreadLocalStack() 44 { 45 threadStack = new ThreadLocal (); 46 } 47 48 public void push(Object o) 49 { 50 LinkedList stack = (LinkedList ) threadStack.get(); 51 if (stack == null) 52 { 53 stack = new LinkedList (); 54 threadStack.set(stack); 55 } 56 stack.addFirst(o); 57 } 58 59 public Object top() 60 { 61 Object o = null; 62 LinkedList stack = (LinkedList ) threadStack.get(); 63 if (stack != null && !stack.isEmpty()) 64 { 65 o = stack.getFirst(); 66 } 67 return o; 68 } 69 70 public Object pop() 71 { 72 Object o = null; 73 LinkedList stack = (LinkedList ) threadStack.get(); 74 if (stack != null) 75 { 76 o = stack.removeFirst(); 77 } 78 return o; 79 } 80 81 public boolean empty() 82 { 83 LinkedList stack = (LinkedList ) threadStack.get(); 84 return stack == null || stack.isEmpty(); 85 } 86 } 87
| Popular Tags
|