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.controls.search.persistentSearch;
21
22
23 import org.apache.directory.api.asn1.DecoderException;
24 import org.apache.directory.api.asn1.ber.tlv.BerValue;
25 import org.apache.directory.api.asn1.util.Asn1Buffer;
26 import org.apache.directory.api.ldap.codec.api.AbstractControlFactory;
27 import org.apache.directory.api.ldap.codec.api.LdapApiService;
28 import org.apache.directory.api.ldap.model.message.Control;
29 import org.apache.directory.api.ldap.model.message.controls.PersistentSearch;
30 import org.apache.directory.api.ldap.model.message.controls.PersistentSearchImpl;
31
32
33
34
35
36
37
38
39 public class PersistentSearchFactory extends AbstractControlFactory<PersistentSearch>
40 {
41
42
43
44
45
46 public PersistentSearchFactory( LdapApiService codec )
47 {
48 super( codec, PersistentSearch.OID );
49 }
50
51
52
53
54
55 @Override
56 public PersistentSearch newControl()
57 {
58 return new PersistentSearchImpl();
59 }
60
61
62
63
64
65 @Override
66 public void encodeValue( Asn1Buffer buffer, Control control )
67 {
68 PersistentSearch persistentSearch = ( PersistentSearch ) control;
69 int start = buffer.getPos();
70
71
72 BerValue.encodeBoolean( buffer, persistentSearch.isReturnECs() );
73
74
75 BerValue.encodeBoolean( buffer, persistentSearch.isChangesOnly() );
76
77
78 BerValue.encodeInteger( buffer, persistentSearch.getChangeTypes() );
79
80
81 BerValue.encodeSequence( buffer, start );
82 }
83
84
85
86
87
88 @Override
89 public void decodeValue( Control control, byte[] controlBytes ) throws DecoderException
90 {
91 decodeValue( new PersistentSearchContainer( control ), control, controlBytes );
92 }
93 }