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.decorators;
21
22
23 import java.nio.BufferOverflowException;
24 import java.nio.ByteBuffer;
25
26 import org.apache.directory.api.asn1.EncoderException;
27 import org.apache.directory.api.asn1.ber.tlv.TLV;
28 import org.apache.directory.api.i18n.I18n;
29 import org.apache.directory.api.ldap.codec.api.LdapApiService;
30 import org.apache.directory.api.ldap.codec.api.LdapCodecConstants;
31 import org.apache.directory.api.ldap.model.message.ModifyDnResponse;
32
33
34
35
36
37
38
39 public class ModifyDnResponseDecorator extends ResponseDecorator<ModifyDnResponse>
40 implements ModifyDnResponse
41 {
42
43 private int modifyDnResponseLength;
44
45
46
47
48
49
50
51
52 public ModifyDnResponseDecorator( LdapApiService codec, ModifyDnResponse decoratedMessage )
53 {
54 super( codec, decoratedMessage );
55 }
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 @Override
75 public int computeLength()
76 {
77 modifyDnResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
78
79 return 1 + TLV.getNbBytes( modifyDnResponseLength ) + modifyDnResponseLength;
80 }
81
82
83
84
85
86
87
88 @Override
89 public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
90 {
91 try
92 {
93
94 buffer.put( LdapCodecConstants.MODIFY_DN_RESPONSE_TAG );
95 buffer.put( TLV.getBytes( modifyDnResponseLength ) );
96
97
98 ( ( LdapResultDecorator ) getLdapResult() ).encode( buffer );
99 }
100 catch ( BufferOverflowException boe )
101 {
102 throw new EncoderException( I18n.err( I18n.ERR_04005 ), boe );
103 }
104
105 return buffer;
106 }
107 }