1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.joran.replay;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.xml.sax.Attributes;
20
21 import ch.qos.logback.core.joran.action.Action;
22 import ch.qos.logback.core.joran.event.InPlayListener;
23 import ch.qos.logback.core.joran.event.SaxEvent;
24 import ch.qos.logback.core.joran.spi.ActionException;
25 import ch.qos.logback.core.joran.spi.InterpretationContext;
26
27 public class FruitFactoryAction extends Action implements InPlayListener {
28
29 List<SaxEvent> seList = new ArrayList<SaxEvent>();
30
31 @Override
32 public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
33 ec.addInPlayListener(this);
34 }
35
36 @Override
37 public void end(InterpretationContext ec, String name) throws ActionException {
38 ec.removeInPlayListener(this);
39
40 Object o = ec.peekObject();
41 if (o instanceof FruitShell) {
42 FruitShell fs = (FruitShell) o;
43 FruitFactory fruitFactory = new FruitFactory();
44 fruitFactory.setEventList(new ArrayList<SaxEvent>(seList));
45 fs.setFruitFactory(fruitFactory);
46 }
47 }
48
49 public void inPlay(SaxEvent event) {
50 seList.add(event);
51 }
52
53 public List<SaxEvent> getSeList() {
54 return seList;
55 }
56
57 }