Package org.snmp4j.model.mapper
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatLong
(Long value, String displayHint) Format a Long value as a string according to the given DISPLAY-HINT format.static String
formatString
(org.snmp4j.smi.OctetString value, String displayHint) Formats anOctetString
value using a DISPLAY-HINT format to a String value.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 Long
Scans a String value as a Long using the specified SMIv2 DISPLAY-HINT format specification.static org.snmp4j.smi.OctetString
scanString
(String format, String value) Scans a String representation of anOctetString
using a DISPLAY-HINT format.static int
validateDateAndTime
(org.snmp4j.smi.Variable dateAndTime) Tests a variable for DateAndTime conformance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.snmp4j.model.mapper.VariableBindingMapper
fromBinary, fromDate, fromLong, fromObject, fromString, fromUnsignedLong, toBinary, toDate, toLong, toObject, toString, toUnsignedLong
-
Constructor Details
-
AbstractVariableBindingMapper
public AbstractVariableBindingMapper()
-
-
Method Details
-
formatLong
Format a Long value as a string according to the given DISPLAY-HINT format.- Parameters:
value
- the long value to formatdisplayHint
- the format description as defined by SMIv2 for integer values.- Returns:
- the formatted string representation of the value.
-
formatString
Formats anOctetString
value using a DISPLAY-HINT format to a String value.- Parameters:
value
- anOctetString
instance.displayHint
- a SMIv2 DISPLAY-HINT string format specification.- Returns:
- a String representation of the
value
.
-
scanString
Scans a String representation of anOctetString
using a DISPLAY-HINT format.- Parameters:
format
- the SMIv2 DISPLAY-HINT format.value
- a String representation of anOctetString
that matches the given format.- Returns:
- the
OctetString
representation of the given value.
-
scanLong
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-HINTformat
.- 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
Creates a DateAndTimeOctetString
value from aGregorianCalendar
.- Parameters:
dateAndTime
- aGregorianCalendar
instance.- Returns:
- the
OctetString
instance with the set calendar value.
-
makeCalendar
Creates aGregorianCalendar
from a properly formatted DateAndTimeOctetString
.- 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
ifdateAndTime
is valid or an appropriate SNMP error code if not.
-