1 /**
2 * This file is part of GoldenGate Project (named also GoldenGate or GG).
3 *
4 * Copyright 2009, Frederic Bregier, and individual contributors by the @author
5 * tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 * individual contributors.
7 *
8 * All GoldenGate Project is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * GoldenGate is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * GoldenGate . If not, see <http://www.gnu.org/licenses/>.
19 */
20 package goldengate.snmp.test;
21
22 import org.snmp4j.smi.Counter32;
23 import org.snmp4j.smi.Counter64;
24 import org.snmp4j.smi.Integer32;
25 import org.snmp4j.smi.IpAddress;
26 import org.snmp4j.smi.Null;
27 import org.snmp4j.smi.OID;
28 import org.snmp4j.smi.OctetString;
29 import org.snmp4j.smi.Opaque;
30 import org.snmp4j.smi.SMIConstants;
31 import org.snmp4j.smi.TimeTicks;
32 import org.snmp4j.smi.Variable;
33
34 import goldengate.snmp.interf.GgInterfaceVariableFactory;
35
36 /**
37 * @author Frederic Bregier
38 *
39 */
40 public class GgTestVariableFactory implements GgInterfaceVariableFactory {
41
42 /*
43 * (non-Javadoc)
44 *
45 * @see goldengate.snmp.GgVariableFactory#getVariable(OID, int, int, int)
46 */
47 @Override
48 public Variable getVariable(OID oid, int type, int mibLevel, int entry) {
49 Variable var;
50 switch (type) {
51 case SMIConstants.SYNTAX_INTEGER:
52 // case SMIConstants.SYNTAX_INTEGER32:
53 var = new Integer32();
54 break;
55 case SMIConstants.SYNTAX_OCTET_STRING:
56 // case SMIConstants.SYNTAX_BITS:
57 var = new OctetString();
58 break;
59 case SMIConstants.SYNTAX_NULL:
60 var = new Null();
61 break;
62 case SMIConstants.SYNTAX_OBJECT_IDENTIFIER:
63 var = new OID();
64 break;
65 case SMIConstants.SYNTAX_IPADDRESS:
66 var = new IpAddress();
67 break;
68 case SMIConstants.SYNTAX_COUNTER32:
69 var = new Counter32();
70 break;
71 case SMIConstants.SYNTAX_GAUGE32:
72 // case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
73 var = new ExampleImplGauge32(oid);
74 break;
75 case SMIConstants.SYNTAX_TIMETICKS:
76 var = new TimeTicks();
77 break;
78 case SMIConstants.SYNTAX_OPAQUE:
79 var = new Opaque();
80 break;
81 case SMIConstants.SYNTAX_COUNTER64:
82 var = new Counter64();
83 break;
84 default:
85 throw new IllegalArgumentException("Unmanaged Type: " + type);
86 }
87 return var;
88 }
89
90 }