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.BerValue;
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.AbandonRequest;
32 import org.apache.directory.api.ldap.model.message.Control;
33
34
35
36
37
38
39
40 public final class AbandonRequestDecorator extends RequestDecorator<AbandonRequest> implements AbandonRequest
41 {
42
43
44
45
46
47 public AbandonRequestDecorator( LdapApiService codec, AbandonRequest decoratedMessage )
48 {
49 super( codec, decoratedMessage );
50 }
51
52
53
54
55
56
57
58
59
60 public int getAbandoned()
61 {
62 return getDecorated().getAbandoned();
63 }
64
65
66
67
68
69 public AbandonRequest setAbandoned( int requestId )
70 {
71 getDecorated().setAbandoned( requestId );
72
73 return this;
74 }
75
76
77
78
79
80 public AbandonRequest setMessageId( int messageId )
81 {
82 super.setMessageId( messageId );
83
84 return this;
85 }
86
87
88
89
90
91 public AbandonRequest addControl( Control control )
92 {
93 return ( AbandonRequest ) super.addControl( control );
94 }
95
96
97
98
99
100 public AbandonRequest addAllControls( Control[] controls )
101 {
102 return ( AbandonRequest ) super.addAllControls( controls );
103 }
104
105
106
107
108
109 public AbandonRequest removeControl( Control control )
110 {
111 return ( AbandonRequest ) super.removeControl( control );
112 }
113
114
115
116
117
118
119
120
121
122 public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
123 {
124 try
125 {
126
127 buffer.put( LdapCodecConstants.ABANDON_REQUEST_TAG );
128
129
130
131 buffer.put( ( byte ) BerValue.getNbBytes( getAbandoned() ) );
132
133
134 buffer.put( BerValue.getBytes( getAbandoned() ) );
135 }
136 catch ( BufferOverflowException boe )
137 {
138 String msg = I18n.err( I18n.ERR_04005 );
139 throw new EncoderException( msg );
140 }
141
142 return buffer;
143 }
144
145
146
147
148
149
150
151
152
153
154 public int computeLength()
155 {
156 int length = 1 + 1 + BerValue.getNbBytes( getAbandoned() );
157
158 return length;
159 }
160 }