1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.codec.api;
21
22
23 import org.apache.directory.api.asn1.ber.AbstractContainer;
24 import org.apache.directory.api.ldap.codec.LdapMessageGrammar;
25 import org.apache.directory.api.ldap.codec.LdapStatesEnum;
26 import org.apache.directory.api.ldap.model.message.Control;
27 import org.apache.directory.api.ldap.model.message.Message;
28
29
30
31
32
33
34
35
36
37 public class LdapMessageContainer<E extends MessageDecorator<? extends Message>> extends AbstractContainer
38 {
39
40 private E messageDecorator;
41
42
43 private BinaryAttributeDetector binaryAttributeDetector;
44
45
46 private int messageId;
47
48
49 private ControlDecorator<? extends Control> currentControl;
50
51
52 private final LdapApiService codec;
53
54
55
56
57
58
59 public LdapMessageContainer( LdapApiService codec )
60 {
61 this( codec, new DefaultConfigurableBinaryAttributeDetector() );
62 }
63
64
65
66
67
68
69
70
71 public LdapMessageContainer( LdapApiService codec, BinaryAttributeDetector binaryAttributeDetector )
72 {
73 super();
74 this.codec = codec;
75 this.grammar = LdapMessageGrammar.getInstance();
76 this.binaryAttributeDetector = binaryAttributeDetector;
77 setTransition( LdapStatesEnum.START_STATE );
78 }
79
80
81
82
83
84
85
86 public LdapApiService getLdapCodecService()
87 {
88 return codec;
89 }
90
91
92
93
94
95 public E getMessage()
96 {
97 return messageDecorator;
98 }
99
100
101
102
103
104
105
106
107 public void setMessage( E messageDecorator )
108 {
109 this.messageDecorator = messageDecorator;
110 }
111
112
113
114
115
116 @Override
117 public void clean()
118 {
119 super.clean();
120
121 messageDecorator = null;
122 messageId = 0;
123 currentControl = null;
124 decodeBytes = 0;
125 }
126
127
128
129
130
131
132 public boolean isBinary( String id )
133 {
134 return binaryAttributeDetector.isBinary( id );
135 }
136
137
138
139
140
141 public int getMessageId()
142 {
143 return messageId;
144 }
145
146
147
148
149
150
151 public void setMessageId( int messageId )
152 {
153 this.messageId = messageId;
154 }
155
156
157
158
159
160 public ControlDecorator<? extends Control> getCurrentControl()
161 {
162 return currentControl;
163 }
164
165
166
167
168
169
170 public void setCurrentControl( ControlDecorator<? extends Control> currentControl )
171 {
172 this.currentControl = currentControl;
173 }
174
175
176
177
178
179
180
181 public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
182 {
183 this.binaryAttributeDetector = binaryAttributeDetector;
184 }
185
186
187
188
189
190 public BinaryAttributeDetector getBinaryAttributeDetector()
191 {
192 return binaryAttributeDetector;
193 }
194 }