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 public ModifyDnResponseDecorator( LdapApiService codec, ModifyDnResponse decoratedMessage )
52 {
53 super( codec, decoratedMessage );
54 }
55
56
57
58
59
60 public void setModifyDnResponseLength( int modifyDnResponseLength )
61 {
62 this.modifyDnResponseLength = modifyDnResponseLength;
63 }
64
65
66
67
68
69
70 public int getModifyDnResponseLength()
71 {
72 return modifyDnResponseLength;
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 public int computeLength()
93 {
94 int modifyDnResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
95
96 setModifyDnResponseLength( modifyDnResponseLength );
97
98 return 1 + TLV.getNbBytes( modifyDnResponseLength ) + modifyDnResponseLength;
99 }
100
101
102
103
104
105
106
107 public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
108 {
109 try
110 {
111
112 buffer.put( LdapCodecConstants.MODIFY_DN_RESPONSE_TAG );
113 buffer.put( TLV.getBytes( getModifyDnResponseLength() ) );
114
115
116 ( ( LdapResultDecorator ) getLdapResult() ).encode( buffer );
117 }
118 catch ( BufferOverflowException boe )
119 {
120 throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
121 }
122
123 return buffer;
124 }
125 }