Package org.snmp4j.agent.mo.snmp
Class DateAndTime<T extends org.snmp4j.smi.OctetString>
java.lang.Object
org.snmp4j.agent.mo.MOColumn<V>
org.snmp4j.agent.mo.MOMutableColumn<T>
org.snmp4j.agent.mo.snmp.DateAndTime<T>
- All Implemented Interfaces:
Comparable
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 Summary
ConstructorDescriptionDateAndTime
(int columnID, MOAccess access, org.snmp4j.smi.OctetString defaultValue) DateAndTime
(int columnID, MOAccess access, org.snmp4j.smi.OctetString defaultValue, boolean mutableInService) -
Method Summary
Modifier and TypeMethodDescriptionstatic MOScalar<org.snmp4j.smi.OctetString>
createMOScalar
(org.snmp4j.smi.OID oid, MOAccess access, org.snmp4j.smi.OctetString value, boolean localtime) Create aMOScalar
DateAndTime instance.static GregorianCalendar
makeCalendar
(org.snmp4j.smi.OctetString dateAndTimeValue) Creates aGregorianCalendar
from a properly formatted DateAndTimeOctetString
.static org.snmp4j.smi.OctetString
makeDateAndTime
(GregorianCalendar dateAndTime) Creates a DateAndTimeOctetString
value from aGregorianCalendar
.static <T extends org.snmp4j.smi.OctetString>
TmakeDateAndTime
(GregorianCalendar dateAndTime, T os) Creates a DateAndTimeOctetString
value from aGregorianCalendar
.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, getRestoreValue, getStoreValue, getSyntax, getTable, getValue, isVolatile, setAccess, setColumnID, setSyntax, setTable
-
Constructor Details
-
DateAndTime
public DateAndTime(int columnID, MOAccess access, org.snmp4j.smi.OctetString defaultValue, boolean mutableInService) -
DateAndTime
-
-
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
ifdateAndTime
is valid or an appropriate SNMP error code if not.
-
makeDateAndTime
Creates a DateAndTimeOctetString
value from aGregorianCalendar
.- Parameters:
dateAndTime
- aGregorianCalendar
instance.- Returns:
- the corresponding DateAndTime
OctetString
.
-
makeDateAndTime
public static <T extends org.snmp4j.smi.OctetString> T makeDateAndTime(GregorianCalendar dateAndTime, T os) Creates a DateAndTimeOctetString
value from aGregorianCalendar
.- Type Parameters:
T
- theOctetString
type to return and modify.- Parameters:
dateAndTime
- aGregorianCalendar
instance.os
- the OctetString instance where to store the value.- Returns:
- the os instance with the set calendar value.
- Since:
- 2.0.5
-
makeCalendar
Creates aGregorianCalendar
from a properly formatted DateAndTimeOctetString
.- 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 classMOMutableColumn<T extends org.snmp4j.smi.OctetString>
-
createMOScalar
public static MOScalar<org.snmp4j.smi.OctetString> createMOScalar(org.snmp4j.smi.OID oid, MOAccess access, org.snmp4j.smi.OctetString value, boolean localtime) Create aMOScalar
DateAndTime instance.- Parameters:
oid
- the OID of the scalar (including the .0 suffix).access
- theMOAccess
instance defining the maximum access rights.value
- the initial value.localtime
- iftrue
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.
-