View Javadoc

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 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package openr66.protocol.snmp;
22  
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.Variable;
32  
33  import goldengate.snmp.interf.GgInterfaceVariableFactory;
34  
35  /**
36   * R66 implementation of VariableFactory for SNMP support
37   * 
38   * @author Frederic Bregier
39   *
40   */
41  public class R66VariableFactory implements GgInterfaceVariableFactory {
42  
43      /* (non-Javadoc)
44       * @see goldengate.snmp.interf.GgInterfaceVariableFactory#getVariable(org.snmp4j.smi.OID, int, int, int)
45       */
46      @Override
47      public Variable getVariable(OID oid, int type, int mibLevel, int entry) {
48          Variable var;
49          switch (type) {
50              case SMIConstants.SYNTAX_INTEGER:
51              //case SMIConstants.SYNTAX_INTEGER32:
52                  var = new Integer32();
53                  break;
54              case SMIConstants.SYNTAX_OCTET_STRING:
55              //case SMIConstants.SYNTAX_BITS:
56                  var = new OctetString();
57                  break;
58              case SMIConstants.SYNTAX_NULL:
59                  var = new Null();
60                  break;
61              case SMIConstants.SYNTAX_OBJECT_IDENTIFIER:
62                  var = new OID();
63                  break;
64              case SMIConstants.SYNTAX_IPADDRESS:
65                  var = new IpAddress();
66                  break;
67              case SMIConstants.SYNTAX_COUNTER32:
68                  var = new R66Counter32(mibLevel, entry);
69                  break;
70              case SMIConstants.SYNTAX_GAUGE32:
71              //case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
72                  var = new R66Gauge32(mibLevel, entry);
73                  break;
74              case SMIConstants.SYNTAX_TIMETICKS:
75                  var = new R66TimeTicks(mibLevel, entry);
76                  break;
77              case SMIConstants.SYNTAX_OPAQUE:
78                  var = new Opaque();
79                  break;
80              case SMIConstants.SYNTAX_COUNTER64:
81                  var = new Counter64();
82                  break;
83              default:
84                  throw new IllegalArgumentException("Unmanaged Type: " +
85                          type);
86          }
87          return var;
88      }
89  
90  }