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.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
52 public ModifyResponseDecorator( LdapApiService codec, ModifyResponse 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
75 @Override
76 public int computeLength()
77 {
78 modifyResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
79
80 return 1 + TLV.getNbBytes( modifyResponseLength ) + modifyResponseLength;
81 }
82
83
84
85
86
87
88
89 @Override
90 public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
91 {
92 try
93 {
94
95 buffer.put( LdapCodecConstants.MODIFY_RESPONSE_TAG );
96 buffer.put( TLV.getBytes( modifyResponseLength ) );
97
98
99 ( ( LdapResultDecorator ) getLdapResult() ).encode( buffer );
100 }
101 catch ( BufferOverflowException boe )
102 {
103 throw new EncoderException( I18n.err( I18n.ERR_04005 ), boe );
104 }
105
106 return buffer;
107 }
108 }