1 14 package org.wings.util; 15 16 import org.wings.SimpleURL; 17 18 24 public class AnchorRenderStack { 25 29 private final static int INITIAL_STACK_DEPTH = 10; 30 31 34 private final static ThreadLocal eventURLStack = new ThreadLocal () { 35 protected synchronized Object initialValue() { 36 return new FastStack(INITIAL_STACK_DEPTH); 37 } 38 }; 39 40 45 public static void reset() { 46 ((FastStack) eventURLStack.get()).clear(); 47 } 48 49 52 public static void push(SimpleURL url, String target) { 53 FastStack s = (FastStack) eventURLStack.get(); 54 s.push(new AnchorProperties(url, target)); 55 } 56 57 public static void push(String formEventName, String formEventValue) { 58 FastStack s = (FastStack) eventURLStack.get(); 59 s.push(new AnchorProperties(formEventName, formEventValue)); 60 } 61 62 63 public static void pop() { 64 FastStack s = (FastStack) eventURLStack.get(); 65 s.pop(); 66 } 67 68 72 public static AnchorProperties get() { 73 FastStack s = (FastStack) eventURLStack.get(); 74 return s.isEmpty() ? null : (AnchorProperties) s.peek(); 75 } 76 77 public static Object clear() { 78 Object oldValue = eventURLStack.get(); 79 eventURLStack.set(new FastStack(INITIAL_STACK_DEPTH)); 80 return oldValue; 81 } 82 83 public static void set(Object stack) { 84 eventURLStack.set(stack); 85 } 86 87 88 } 89 90 91 | Popular Tags |