001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Nam Nguyen
028: */
029:
030: package com.caucho.server.snmp;
031:
032: import com.caucho.server.snmp.types.SnmpValue;
033:
034: /*
035: * Mapping from from SNMP objects to MBeans.
036: */
037: public class Oid {
038: private String _name;
039:
040: private String _mbean;
041: private String _attribute;
042:
043: private Object _value;
044:
045: // Snmp type for this mbean attribute
046: private int _type = SnmpValue.OCTET_STRING;
047:
048: public Oid() {
049: }
050:
051: public Oid(String name, String mbean, String attribute, int type) {
052: _name = name;
053: _mbean = mbean;
054: _attribute = attribute;
055: _type = type;
056: }
057:
058: public void setName(String name) {
059: _name = name;
060: }
061:
062: public String getName() {
063: return _name;
064: }
065:
066: public String getMbean() {
067: return _mbean;
068: }
069:
070: public void setMbean(String mbean) {
071: _mbean = mbean;
072: }
073:
074: public void setAttribute(String attribute) {
075: _attribute = attribute;
076: }
077:
078: public String getAttribute() {
079: return _attribute;
080: }
081:
082: public int getType() {
083: return _type;
084: }
085:
086: public void setType(int type) {
087: _type = type;
088: }
089:
090: public Object getValue() {
091: return _value;
092: }
093:
094: public void setValue(Object value) {
095: _value = value;
096: }
097:
098: public void setIntegerValue(Integer value) {
099: _value = value;
100:
101: _type = SnmpValue.INTEGER;
102: }
103:
104: public void setOctetStringValue(String value) {
105: _value = value;
106:
107: _type = SnmpValue.OCTET_STRING;
108: }
109:
110: public void setGaugeValue(Long value) {
111: _value = value;
112:
113: _type = SnmpValue.GAUGE;
114: }
115:
116: public void setCounterValue(Long value) {
117: _value = value;
118:
119: _type = SnmpValue.COUNTER;
120: }
121:
122: public void setTimeTicksValue(Long value) {
123: _value = value;
124:
125: _type = SnmpValue.TIME_TICKS;
126: }
127:
128: public void setIpAddressValue(String value) {
129: _value = value;
130:
131: _type = SnmpValue.IP_ADDRESS;
132: }
133:
134: public boolean equals(Object obj) {
135: return obj instanceof Oid
136: && ((Oid) obj).getName().equals(_name);
137: }
138:
139: public String toString() {
140: return "Oid[" + _name + "," + _mbean + "," + _attribute + ","
141: + _type + "]";
142: }
143: }
|