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.LdapConstants;
31 import org.apache.directory.api.ldap.model.message.ModifyResponse;
32
33
34
35
36
37
38
39 public class ModifyResponseDecorator extends ResponseDecorator<ModifyResponse>
40 implements ModifyResponse
41 {
42
43 private int modifyResponseLength;
44
45
46
47
48
49
50
51 public ModifyResponseDecorator( LdapApiService codec, ModifyResponse decoratedMessage )
52 {
53 super( codec, decoratedMessage );
54 }
55
56
57
58
59
60
61 public void setModifyResponseLength( int modifyResponseLength )
62 {
63 this.modifyResponseLength = modifyResponseLength;
64 }
65
66
67
68
69
70 public int getModifyResponseLength()
71 {
72 return modifyResponseLength;
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 public int computeLength()
94 {
95 int modifyResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
96
97 setModifyResponseLength( modifyResponseLength );
98
99 return 1 + TLV.getNbBytes( modifyResponseLength ) + modifyResponseLength;
100 }
101
102
103
104
105
106
107
108 public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
109 {
110 try
111 {
112
113 buffer.put( LdapConstants.MODIFY_RESPONSE_TAG );
114 buffer.put( TLV.getBytes( getModifyResponseLength() ) );
115
116
117 ( ( LdapResultDecorator ) getLdapResult() ).encode( buffer );
118 }
119 catch ( BufferOverflowException boe )
120 {
121 throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
122 }
123
124 return buffer;
125 }
126 }