Class AbstractVariableBindingMapper<L,U,S,D,B>

java.lang.Object
org.snmp4j.model.mapper.AbstractVariableBindingMapper<L,U,S,D,B>
All Implemented Interfaces:
VariableBindingMapper<L,U,S,D,B>
Direct Known Subclasses:
VariableBindingMapperJava

public abstract class AbstractVariableBindingMapper<L,U,S,D,B> extends Object implements VariableBindingMapper<L,U,S,D,B>
AbstractVariableBindingMapper provides helper functions to support the conversion between Variable values and native values used in an application.
Version:
1.0
Author:
Frank Fock
  • Constructor Details

    • AbstractVariableBindingMapper

      public AbstractVariableBindingMapper()
  • Method Details

    • formatLong

      public static String formatLong(Long value, String displayHint)
      Format a Long value as a string according to the given DISPLAY-HINT format.
      Parameters:
      value - the long value to format
      displayHint - the format description as defined by SMIv2 for integer values.
      Returns:
      the formatted string representation of the value.
    • formatString

      public static String formatString(org.snmp4j.smi.OctetString value, String displayHint)
      Formats an OctetString value using a DISPLAY-HINT format to a String value.
      Parameters:
      value - an OctetString instance.
      displayHint - a SMIv2 DISPLAY-HINT string format specification.
      Returns:
      a String representation of the value.
    • scanString

      public static org.snmp4j.smi.OctetString scanString(String format, String value)
      Scans a String representation of an OctetString using a DISPLAY-HINT format.
      Parameters:
      format - the SMIv2 DISPLAY-HINT format.
      value - a String representation of an OctetString that matches the given format.
      Returns:
      the OctetString representation of the given value.
    • scanLong

      public static Long scanLong(String format, String value) throws NumberFormatException
      Scans a String value as a Long using the specified SMIv2 DISPLAY-HINT format specification.
      Parameters:
      format - the SMIv2 DISPLAY-HINT format.
      value - a string value representing a number with the DISPLAY-HINT format.
      Returns:
      the Long representation of the given value or null if the value could not by scanned using the given format.
      Throws:
      NumberFormatException - if value and format render a string that cannot be parsed as a long value.
    • makeDateAndTime

      public static org.snmp4j.smi.OctetString makeDateAndTime(GregorianCalendar dateAndTime)
      Creates a DateAndTime OctetString value from a GregorianCalendar.
      Parameters:
      dateAndTime - a GregorianCalendar instance.
      Returns:
      the OctetString instance with the set calendar value.
    • makeCalendar

      public static GregorianCalendar makeCalendar(org.snmp4j.smi.OctetString dateAndTimeValue)
      Creates a GregorianCalendar from a properly formatted DateAndTime OctetString.
      Parameters:
      dateAndTimeValue - an OctetString conforming to the DateAndTime TC.
      Returns:
      the corresponding GregorianCalendar instance.
    • validateDateAndTime

      public static int validateDateAndTime(org.snmp4j.smi.Variable dateAndTime)
      Tests a variable for DateAndTime conformance.
      Parameters:
      dateAndTime - a Variable.
      Returns:
      SnmpConstants.SNMP_ERROR_SUCCESS if dateAndTime is valid or an appropriate SNMP error code if not.