1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.mimo.netty.handler.codec.icap;
15
16 import org.jboss.netty.buffer.ChannelBuffer;
17
18
19
20
21
22
23
24
25
26 public class ReadIcapInitialState extends State<Object> {
27
28 public ReadIcapInitialState(String name) {
29 super(name);
30 }
31
32 @Override
33 public void onEntry(ChannelBuffer buffer, IcapMessageDecoder icapMessageDecoder) throws DecodingException {
34
35 }
36
37 @Override
38 public StateReturnValue execute(ChannelBuffer buffer, IcapMessageDecoder icapMessageDecoder) throws DecodingException {
39 String[] initialLine = IcapDecoderUtil.splitInitialLine(IcapDecoderUtil.readLine(buffer,icapMessageDecoder.maxInitialLineLength));
40 icapMessageDecoder.message = icapMessageDecoder.createMessage(initialLine);
41 return StateReturnValue.createIrrelevantResult();
42 }
43
44 @Override
45 public StateEnum onExit(ChannelBuffer buffer, IcapMessageDecoder icapMessageDecoder, Object decisionInformation) throws DecodingException {
46 if(icapMessageDecoder.message == null) {
47 return StateEnum.SKIP_CONTROL_CHARS;
48 }
49 return StateEnum.READ_ICAP_HEADER_STATE;
50 }
51 }