java.lang.Object
org.snmp4j.util.SimpleOIDTextFormat
org.snmp4j.util.DictionaryOIDTextFormat
- All Implemented Interfaces:
OIDTextFormat
The
DictionaryOIDTextFormat provides a simple OID formatter based on a dictionary of object name to
object identifier mappings.- Since:
- 3.5.0
- Author:
- Frank Fock
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyDictionaryOIDTextFormatthat acts like its superclassSimpleOIDTextFormatunless dictionary entries are added withput(String)orput(String, String).DictionaryOIDTextFormat(String... objectNameToDottedNumbers) Create a dictionary based OID formatter from a list of object name toOIDmappings of the form 'sysDescr=1.3.6.1.2.1.1.1'. -
Method Summary
Modifier and TypeMethodDescriptionformat(int[] value) Returns a textual representation of a raw object ID as dotted string ("1.3.6.1.4").int[]Parses a textual representation of an object ID as dotted string (e.g.Put an object name to oid mapping into the internal dictionary used for the OID/text formatting that is parsed from a string of the form 'sysDescr = 1.3.6.1.2.1.1.1' or 'sysDescr=1.3.6.1.2.1.1.1'.Put an object name to oid mapping into the internal dictionary used for the OID/text formatting.intsize()Return the size of the dictionary.Methods inherited from class org.snmp4j.util.SimpleOIDTextFormat
formatForRoundTrip, formatOID, parseOID
-
Constructor Details
-
DictionaryOIDTextFormat
public DictionaryOIDTextFormat()Creates an emptyDictionaryOIDTextFormatthat acts like its superclassSimpleOIDTextFormatunless dictionary entries are added withput(String)orput(String, String).dictionaryOIOTextFormat.parse("ifAdminStatus")will returnnew int[] { 1,3,6,1,2,1,2,2,1,7 }ifdictionaryOIOTextFormat.put("ifAdminStatus=1.3.6.1.2.1.2.2.1.7")was called before. Otherwise, aParseExceptionwill be thrown. An the other hand,dictionaryOIOTextFormat.format(new int[] { 1,3,6,1,2,1,2,2,1,7,1000 })will return"ifAdminStatus.1000"in the first case, i.e. with dictionary entry. -
DictionaryOIDTextFormat
Create a dictionary based OID formatter from a list of object name toOIDmappings of the form 'sysDescr=1.3.6.1.2.1.1.1'.- Parameters:
objectNameToDottedNumbers- an object name to OID mapping of the form "<oid>=<object-name>
-
-
Method Details
-
put
Put an object name to oid mapping into the internal dictionary used for the OID/text formatting.- Parameters:
objectName- an SMI object name like 'sysDescr'.dottedNumbersOidString- the SMI object identifier registered for the givenobjectNamein dotted number format, e.g. '1.3.6.1.2.1.1.1' for 'sysDescr'.- Returns:
- the parsed
OIDornullif the oid string contains characters other than digits and '.'. In that case, the dictionary is not changed.
-
put
Put an object name to oid mapping into the internal dictionary used for the OID/text formatting that is parsed from a string of the form 'sysDescr = 1.3.6.1.2.1.1.1' or 'sysDescr=1.3.6.1.2.1.1.1'.- Parameters:
objectNameEqualsDottedNumberString- a string with an SMI object name, a single equals sign, and after that equals sign a dotted number OID string: e.g. 'sysDescr=1.3.6.1.2.1.1.1'.- Returns:
- the parsed
OIDornullif the oid string contains characters other than digits and '.'. In that case, the dictionary is not changed.
-
size
public int size()Return the size of the dictionary.- Returns:
- the number of entries in the OID formatting dictionary.
-
format
Description copied from class:SimpleOIDTextFormatReturns a textual representation of a raw object ID as dotted string ("1.3.6.1.4").- Specified by:
formatin interfaceOIDTextFormat- Overrides:
formatin classSimpleOIDTextFormat- Parameters:
value- the OID value to format.- Returns:
- the textual representation.
-
parse
Description copied from class:SimpleOIDTextFormatParses a textual representation of an object ID as dotted string (e.g. "1.3.6.1.2.1.1") and returns its raw value.- Specified by:
parsein interfaceOIDTextFormat- Overrides:
parsein classSimpleOIDTextFormat- Parameters:
text- a textual representation of an OID.- Returns:
- the raw OID value.
- Throws:
ParseException- if the OID cannot be parsed successfully.
-