1 5 package com.tonbeller.jpivot.tags; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import java.util.Set ; 10 import java.util.TreeSet ; 11 12 import com.tonbeller.jpivot.tags.StateManager.State; 13 14 public class TestStateLogger extends Log4jStateLogger implements StateLogger { 15 16 Set active = new TreeSet (); 17 List errors = new ArrayList (); 18 19 public void initialize(State s) { 20 String name = s.getName(); 21 if (active.contains(name)) { 22 String msg = "trying to initialize state " + name + " which is already initialized"; 23 errors.add(msg); 24 super.error(msg); 25 } 26 active.add(name); 27 super.initialize(s); 28 } 29 30 public void destroy(State s) { 31 String name = s.getName(); 32 if (!active.contains(name)) { 33 String msg = "trying to destroy state " + name + " which is not initialized"; 34 errors.add(msg); 35 super.error(msg); 36 } 37 active.remove(name); 38 super.destroy(s); 39 } 40 41 public Set getActive() { 42 return active; 43 } 44 45 public List getErrors() { 46 return errors; 47 } 48 } 49 | Popular Tags |