Package org.snmp4j.agent.mo.jmx

Source Code of org.snmp4j.agent.mo.jmx.JMXSimpleArrayIndexSupport

/*_############################################################################
  _##
  _##  SNMP4J-AgentJMX - JMXSimpleArrayIndexSupport.java 
  _##
  _##  Copyright (C) 2006-2009  Frank Fock (SNMP4J.org)
  _## 
  _##  This program is free software; you can redistribute it and/or modify
  _##  it under the terms of the GNU General Public License version 2 as
  _##  published by the Free Software Foundation.
  _##
  _##  This program is distributed in the hope that it will be useful,
  _##  but WITHOUT ANY WARRANTY; without even the implied warranty of
  _##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  _##  GNU General Public License for more details.
  _##
  _##  You should have received a copy of the GNU General Public License
  _##  along with this program; if not, write to the Free Software
  _##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  _##  MA  02110-1301  USA
  _## 
  _##########################################################################*/
package org.snmp4j.agent.mo.jmx;

import javax.management.ObjectName;

import org.snmp4j.smi.OID;
import org.snmp4j.agent.mo.jmx.util.JMXArrayIndexKey;

/**
* The <code>JMXSimpleArrayIndexSupport</code> provides index support
* for SNMP indexes that are directly related to index values of an array
* provided through a MBean.
* <p>
* This class returns instances of {@link JMXArrayIndexKey} as row identifiers
* and expect instances of the same as row identifiers to be mapped to a SNMP
* index value.
*
* @author Frank Fock
* @version 1.0
*/
public class JMXSimpleArrayIndexSupport implements JMXIndexSupport {

  public JMXSimpleArrayIndexSupport() {
  }

  public Object getRowIdentifier(Object nativeRowId, int nativeIndex) {
    return new JMXArrayIndexKey(nativeIndex);
  }

  public OID mapToIndex(Object rowIdentifier) {
    return new OID(new int[] { ((JMXArrayIndexKey)rowIdentifier).getIndex() });
  }

  public ObjectName mapToRowMBean(Object rowIdentifier) {
    return null;
  }

  public Object mapToRowIdentifier(OID rowIndex) {
    if (rowIndex == null) {
      return new JMXArrayIndexKey(0);
    }
    return new JMXArrayIndexKey(rowIndex.get(0));
  }

}
TOP

Related Classes of org.snmp4j.agent.mo.jmx.JMXSimpleArrayIndexSupport

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.