Class DateAndTime<T extends org.snmp4j.smi.OctetString>

All Implemented Interfaces:
Comparable<MOColumn<T>>

public class DateAndTime<T extends org.snmp4j.smi.OctetString> extends MOMutableColumn<T>
The DateAndTime implements the DateAndTime textual convention (TC) from the SNMPv2-TC MIB specification for columnar objects.

DateAndTime subclasses MOMutableColumn and can thus directly be used with tables. To use this TC implementation as MOScalar create the corresponding instance using createMOScalar(org.snmp4j.smi.OID, org.snmp4j.agent.MOAccess, org.snmp4j.smi.OctetString, boolean) or even better use the DateAndTimeTC textual convention in conjunction with a MOFactory.

Version:
1.0
Author:
Frank Fock
  • Constructor Details

    • DateAndTime

      public DateAndTime(int columnID, MOAccess access, T defaultValue, boolean mutableInService)
    • DateAndTime

      public DateAndTime(int columnID, MOAccess access, T defaultValue)
  • Method Details

    • 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.
    • 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 corresponding DateAndTime OctetString.
    • makeDateAndTime

      public static <T extends org.snmp4j.smi.OctetString> T makeDateAndTime(GregorianCalendar dateAndTime, T os)
      Creates a DateAndTime OctetString value from a GregorianCalendar.
      Type Parameters:
      T - the OctetString type to return and modify.
      Parameters:
      dateAndTime - a GregorianCalendar instance.
      os - the OctetString instance where to store the value.
      Returns:
      the os instance with the set calendar value.
      Since:
      2.0.5
    • 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.
    • validate

      public int validate(T newValue, T oldValue, org.snmp4j.smi.OID instanceOID)
      Description copied from class: MOMutableColumn
      Validate the new value for a mutable column based on old value and (new in v3.7.0) the instance OID.
      Overrides:
      validate in class MOMutableColumn<T extends org.snmp4j.smi.OctetString>
      Parameters:
      newValue - the new value to be set.
      oldValue - the existing value.
      instanceOID - the instance OID of the table cell to be modified.
      Returns:
      SnmpConstants.SNMP_ERROR_SUCCESS if the change is OK, otherwise a SNMP error status.
    • createMOScalar

      public static MOScalar<org.snmp4j.smi.OctetString> createMOScalar(org.snmp4j.smi.OID oid, MOAccess access, org.snmp4j.smi.OctetString value, boolean localtime)
      Create a MOScalar DateAndTime instance.
      Parameters:
      oid - the OID of the scalar (including the .0 suffix).
      access - the MOAccess instance defining the maximum access rights.
      value - the initial value.
      localtime - if true the returned DateAndTime instance will always return the local time (does only makes sense for a read-only instance). Otherwise the value last set will be returned on GET like requests.
      Returns:
      the MOScalar instance.