1. /*
  2. * @(#)file SnmpMibEntry.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.18
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. */
  10. package com.sun.jmx.snmp.agent;
  11. // java imports
  12. //
  13. import java.io.Serializable;
  14. import java.util.Hashtable;
  15. import java.util.Enumeration;
  16. // jmx imports
  17. //
  18. import com.sun.jmx.snmp.SnmpValue;
  19. import com.sun.jmx.snmp.SnmpVarBind;
  20. import com.sun.jmx.snmp.SnmpStatusException;
  21. import com.sun.jmx.snmp.agent.SnmpMibOid;
  22. import com.sun.jmx.snmp.agent.SnmpMibNode;
  23. /**
  24. * Represents a node in an SNMP MIB which corresponds to a table entry
  25. * meta node.
  26. * <P>
  27. * This class is used by the class generated by <CODE>mibgen</CODE>.
  28. * You should not need to use this class directly.
  29. *
  30. * <p><b>This API is a Sun Microsystems internal API and is subject
  31. * to change without notice.</b></p>
  32. * @version 4.3 10/29/99
  33. * @author Sun Microsystems, Inc
  34. */
  35. public abstract class SnmpMibEntry extends SnmpMibNode
  36. implements Serializable {
  37. /**
  38. * Tells whether the given arc identifies a variable (scalar object) in
  39. * this entry.
  40. *
  41. * @param arc An OID arc.
  42. *
  43. * @return <CODE>true</CODE> if `arc' leads to a variable.
  44. */
  45. public abstract boolean isVariable(long arc);
  46. /**
  47. * Tells whether the given arc identifies a readable scalar object in
  48. * this entry.
  49. *
  50. * @param arc An OID arc.
  51. *
  52. * @return <CODE>true</CODE> if `arc' leads to a readable variable.
  53. */
  54. public abstract boolean isReadable(long arc);
  55. /**
  56. * Get the next OID arc corresponding to a readable scalar variable.
  57. *
  58. */
  59. public long getNextVarId(long id, Object userData)
  60. throws SnmpStatusException {
  61. long nextvar = super.getNextVarId(id,userData);
  62. while (!isReadable(nextvar))
  63. nextvar = super.getNextVarId(nextvar,userData);
  64. return nextvar;
  65. }
  66. /**
  67. * Checks whether the given OID arc identifies a variable (columnar
  68. * object).
  69. *
  70. * @param userData A contextual object containing user-data.
  71. * This object is allocated through the <code>
  72. * {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
  73. * for each incoming SNMP request.
  74. *
  75. * @exception If the given `arc' does not identify any variable in this
  76. * group, throws an SnmpStatusException.
  77. */
  78. public void validateVarId(long arc, Object userData)
  79. throws SnmpStatusException {
  80. if (isVariable(arc) == false) throw noSuchNameException;
  81. }
  82. /**
  83. * Generic handling of the <CODE>get</CODE> operation.
  84. * <p>The actual implementation of this method will be generated
  85. * by mibgen. Usually, this implementation only delegates the
  86. * job to some other provided runtime class, which knows how to
  87. * access the MBean. The current toolkit thus provides two
  88. * implementations:
  89. * <ul><li>The standard implementation will directly access the
  90. * MBean through a java reference,</li>
  91. * <li>The generic implementation will access the MBean through
  92. * the MBean server.</li>
  93. * </ul>
  94. * <p>Both implementations rely upon specific - and distinct, set of
  95. * mibgen generated methods.
  96. * <p> You can override this method if you need to implement some
  97. * specific policies for minimizing the accesses made to some remote
  98. * underlying resources.
  99. * <p>
  100. *
  101. * @param req The sub-request that must be handled by this node.
  102. *
  103. * @param depth The depth reached in the OID tree.
  104. *
  105. * @exception SnmpStatusException An error occurred while accessing
  106. * the MIB node.
  107. */
  108. abstract public void get(SnmpMibSubRequest req, int depth)
  109. throws SnmpStatusException;
  110. /**
  111. * Generic handling of the <CODE>set</CODE> operation.
  112. * <p>The actual implementation of this method will be generated
  113. * by mibgen. Usually, this implementation only delegates the
  114. * job to some other provided runtime class, which knows how to
  115. * access the MBean. The current toolkit thus provides two
  116. * implementations:
  117. * <ul><li>The standard implementation will directly access the
  118. * MBean through a java reference,</li>
  119. * <li>The generic implementation will access the MBean through
  120. * the MBean server.</li>
  121. * </ul>
  122. * <p>Both implementations rely upon specific - and distinct, set of
  123. * mibgen generated methods.
  124. * <p> You can override this method if you need to implement some
  125. * specific policies for minimizing the accesses made to some remote
  126. * underlying resources.
  127. * <p>
  128. *
  129. * @param req The sub-request that must be handled by this node.
  130. *
  131. * @param depth The depth reached in the OID tree.
  132. *
  133. * @exception SnmpStatusException An error occurred while accessing
  134. * the MIB node.
  135. */
  136. abstract public void set(SnmpMibSubRequest req, int depth)
  137. throws SnmpStatusException;
  138. /**
  139. * Generic handling of the <CODE>check</CODE> operation.
  140. *
  141. * <p>The actual implementation of this method will be generated
  142. * by mibgen. Usually, this implementation only delegates the
  143. * job to some other provided runtime class, which knows how to
  144. * access the MBean. The current toolkit thus provides two
  145. * implementations:
  146. * <ul><li>The standard implementation will directly access the
  147. * MBean through a java reference,</li>
  148. * <li>The generic implementation will access the MBean through
  149. * the MBean server.</li>
  150. * </ul>
  151. * <p>Both implementations rely upon specific - and distinct, set of
  152. * mibgen generated methods.
  153. * <p> You can override this method if you need to implement some
  154. * specific policies for minimizing the accesses made to some remote
  155. * underlying resources, or if you need to implement some consistency
  156. * checks between the different values provided in the varbind list.
  157. * <p>
  158. *
  159. * @param req The sub-request that must be handled by this node.
  160. *
  161. * @param depth The depth reached in the OID tree.
  162. *
  163. * @exception SnmpStatusException An error occurred while accessing
  164. * the MIB node.
  165. */
  166. abstract public void check(SnmpMibSubRequest req, int depth)
  167. throws SnmpStatusException;
  168. }