org.snmp4j.agent.mo.snmp
Class DateAndTime

java.lang.Object
  extended by org.snmp4j.agent.mo.MOColumn
      extended by org.snmp4j.agent.mo.MOMutableColumn
          extended by org.snmp4j.agent.mo.snmp.DateAndTime
All Implemented Interfaces:
java.lang.Comparable

public class DateAndTime
extends MOMutableColumn

The DateAndTime implements the DateAndTime textual convention (TC) from the SNMPv2-TC MIB specificion 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 Summary
DateAndTime(int columnID, MOAccess access, org.snmp4j.smi.Variable defaultValue)
           
DateAndTime(int columnID, MOAccess access, org.snmp4j.smi.Variable defaultValue, boolean mutableInService)
           
 
Method Summary
static MOScalar createMOScalar(org.snmp4j.smi.OID oid, MOAccess access, org.snmp4j.smi.OctetString value, boolean localtime)
          Create a MOScalar DateAndTime instance.
static java.util.GregorianCalendar makeCalendar(org.snmp4j.smi.OctetString dateAndTimeValue)
          Creates a GregorianCalendar from a properly formatted DateAndTime OctetString.
static org.snmp4j.smi.OctetString makeDateAndTime(java.util.GregorianCalendar dateAndTime)
          Creates a DatenAndTime OctetString value from a GregorianCalendar.
 int validate(org.snmp4j.smi.Variable newValue, org.snmp4j.smi.Variable oldValue)
           
static int validateDateAndTime(org.snmp4j.smi.Variable dateAndTime)
          Tests a variable for DateAndTime conformance.
 
Methods inherited from class org.snmp4j.agent.mo.MOMutableColumn
addMOValueValidationListener, cleanup, commit, getDefaultValue, isMandatory, isMutableInService, prepare, removeMOValueValidationListener, setDefaultValue, setMandatory, setMutableInService, toString, undo, validateSetRequest
 
Methods inherited from class org.snmp4j.agent.mo.MOColumn
compareTo, get, getAccess, getColumnID, getSyntax, getTable, getValue, isVolatile, setAccess, setColumnID, setSyntax, setTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateAndTime

public DateAndTime(int columnID,
                   MOAccess access,
                   org.snmp4j.smi.Variable defaultValue,
                   boolean mutableInService)

DateAndTime

public DateAndTime(int columnID,
                   MOAccess access,
                   org.snmp4j.smi.Variable defaultValue)
Method Detail

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(java.util.GregorianCalendar dateAndTime)
Creates a DatenAndTime OctetString value from a GregorianCalendar.

Parameters:
dateAndTime - a GregorianCalendar instance.
Returns:
the corresponding DateAndTime OctetString.

makeCalendar

public static java.util.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(org.snmp4j.smi.Variable newValue,
                    org.snmp4j.smi.Variable oldValue)
Overrides:
validate in class MOMutableColumn

createMOScalar

public static MOScalar 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.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.