1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.content2bean.impl;
35
36 import info.magnolia.cms.core.Content;
37 import info.magnolia.content2bean.TransformationState;
38 import info.magnolia.content2bean.TypeDescriptor;
39
40 import org.apache.commons.collections.ArrayStack;
41
42
43 public class TransformationStateImpl implements TransformationState {
44
45 protected ArrayStack typeStack = new ArrayStack();
46
47 protected ArrayStack beanStack = new ArrayStack();
48
49 protected ArrayStack contentStack = new ArrayStack();
50
51 public Object getCurrentBean() {
52 return beanStack.peek();
53 }
54
55 public TypeDescriptor getCurrentType() {
56 return (TypeDescriptor) typeStack.peek();
57 }
58
59 public Content getCurrentContent() {
60 return (Content) contentStack.peek();
61 }
62
63 public Object peekBean(int pos) {
64 return beanStack.peek(pos);
65 }
66
67 public TypeDescriptor peekType(int pos) {
68 return (TypeDescriptor) typeStack.peek(pos);
69 }
70
71 public Content peekContent(int pos) {
72 return (Content) contentStack.peek(pos);
73 }
74
75 public void popBean() {
76 beanStack.pop();
77 }
78
79 public void popType() {
80 typeStack.pop();
81 }
82
83 public void popContent() {
84 contentStack.pop();
85 }
86
87 public void pushBean(Object bean) {
88 beanStack.push(bean);
89 }
90
91 public void pushType(TypeDescriptor type) {
92 typeStack.push(type);
93 }
94
95 public void pushContent(Content node) {
96 contentStack.push(node);
97 }
98
99 public int getLevel() {
100 return Math.max(Math.max(typeStack.size(), beanStack.size()), contentStack.size());
101 }
102 }