1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.dexterim.oscar.io;
20
21 import net.sf.dexterim.oscar.entity.Snac;
22 import net.sf.dexterim.oscar.entity.SnacFamiliesVersions;
23 import net.sf.dexterim.oscar.server.GenericSnacResponse;
24 import net.sf.dexterim.oscar.server.MessageOfTheDayResponse;
25 import net.sf.dexterim.oscar.server.RateInfoResponse;
26 import net.sf.dexterim.oscar.server.Response;
27 import net.sf.dexterim.oscar.server.SupportedSnacFamilies;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 /***
33 * @author christoph
34 */
35 public class GenericServiceControlsParser implements SnacParserDelegate {
36
37 private static final int SNAC_FAMILIES = 0x0003;
38 private static final int SNAC_FAMILIES_VERSIONS = 0x0018;
39 private static final int SNAC_MOTD = 0x0013;
40 private static final int SNAC_RATE_INFO_RESPONSE = 0x0007;
41
42 private Log log;
43
44 public GenericServiceControlsParser() {
45 log = LogFactory.getLog(getClass());
46 }
47
48
49
50
51
52
53 public Response parse(Snac snac) throws ParserException {
54 switch (snac.getType()) {
55 case SNAC_FAMILIES:
56 return SupportedSnacFamilies.create(snac);
57
58 case SNAC_FAMILIES_VERSIONS:
59 return SnacFamiliesVersions.create(snac);
60
61 case SNAC_MOTD:
62 return MessageOfTheDayResponse.create(snac);
63
64 case SNAC_RATE_INFO_RESPONSE:
65 return RateInfoResponse.create(snac);
66
67 default:
68 if (log.isDebugEnabled()) {
69 log.debug("No Parser for subType " + snac.getType() + " available");
70 }
71
72 return new GenericSnacResponse(snac);
73 }
74 }
75
76 }