1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1.ber ;
18
19
20 import java.nio.ByteBuffer;
21
22 import org.apache.asn1.codec.DecoderException;
23 import org.apache.asn1.codec.stateful.AbstractStatefulDecoder;
24
25
26 /***
27 * A BER TLV Tag component decoder. This decoder delivers a Tag instance
28 * to its callback. For efficiency the same Tag object is reused. Callback
29 * implementations should not copy the handle to the Tag object delivered but
30 * should copy the data if they need it over the long term.
31 *
32 *
33 * @author <a href="mailto:dev@directory.apache.org">
34 * Apache Directory Project</a>
35 * @version $Rev: 157644 $
36 */
37 public class TagDecoder extends AbstractStatefulDecoder
38 {
39 private final Tag tag = new Tag() ;
40
41
42
43
44
45
46 public void decode( Object encoded ) throws DecoderException
47 {
48 ByteBuffer buf = ( ByteBuffer ) encoded ;
49
50 while ( buf.hasRemaining() )
51 {
52 byte octet = buf.get() ;
53 tag.add( octet ) ;
54
55 if ( tag.isFixated() )
56 {
57 decodeOccurred( tag ) ;
58 tag.clear() ;
59 return ;
60 }
61 }
62 }
63 }