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
38
39 public class LdapMessageContainer<E extends MessageDecorator<? extends Message>> extends AbstractContainer
40 {
41
42 private E messageDecorator;
43
44
45 private BinaryAttributeDetector binaryAttributeDetector;
46
47
48 private int messageId;
49
50
51 private ControlDecorator<? extends Control> currentControl;
52
53
54 private final LdapApiService codec;
55
56
57
58
59
60
61
62
63 public LdapMessageContainer( LdapApiService codec )
64 {
65 this( codec, new DefaultConfigurableBinaryAttributeDetector() );
66 }
67
68
69
70
71
72
73
74
75
76 public LdapMessageContainer( LdapApiService codec, BinaryAttributeDetector binaryAttributeDetector )
77 {
78 super();
79 this.codec = codec;
80 setGrammar( LdapMessageGrammar.getInstance() );
81 this.binaryAttributeDetector = binaryAttributeDetector;
82 setTransition( LdapStatesEnum.START_STATE );
83 }
84
85
86
87
88
89
90
91 public LdapApiService getLdapCodecService()
92 {
93 return codec;
94 }
95
96
97
98
99
100 public E getMessage()
101 {
102 return messageDecorator;
103 }
104
105
106
107
108
109
110
111
112 public void setMessage( E messageDecorator )
113 {
114 this.messageDecorator = messageDecorator;
115 }
116
117
118
119
120
121 @Override
122 public void clean()
123 {
124 super.clean();
125
126 messageDecorator = null;
127 messageId = 0;
128 currentControl = null;
129 setDecodedBytes( 0 );
130 }
131
132
133
134
135
136
137 public boolean isBinary( String id )
138 {
139 return binaryAttributeDetector.isBinary( id );
140 }
141
142
143
144
145
146 public int getMessageId()
147 {
148 return messageId;
149 }
150
151
152
153
154
155
156 public void setMessageId( int messageId )
157 {
158 this.messageId = messageId;
159 }
160
161
162
163
164
165 public ControlDecorator<? extends Control> getCurrentControl()
166 {
167 return currentControl;
168 }
169
170
171
172
173
174
175 public void setCurrentControl( ControlDecorator<? extends Control> currentControl )
176 {
177 this.currentControl = currentControl;
178 }
179
180
181
182
183
184
185
186 public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
187 {
188 this.binaryAttributeDetector = binaryAttributeDetector;
189 }
190
191
192
193
194
195 public BinaryAttributeDetector getBinaryAttributeDetector()
196 {
197 return binaryAttributeDetector;
198 }
199 }