本文整理汇总了Java中org.snmp4j.smi.Variable.getSyntaxString方法的典型用法代码示例。如果您正苦于以下问题:Java Variable.getSyntaxString方法的具体用法?Java Variable.getSyntaxString怎么用?Java Variable.getSyntaxString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.smi.Variable
的用法示例。
在下文中一共展示了Variable.getSyntaxString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
/**
* Returns a textual representation of the supplied variable against the
* optionally supplied instance OID.
*
* @param instanceOID the instance OID <code>variable</code> is associated
* with. If <code>null</code> the formatting cannot take any MIB
* specification of the variable into account and has to format it based
* on its type only.
* @param variable
* the variable to format.
* @param withOID
* if <code>true</code> the <code>instanceOID</code> should be included
* in the textual representation to form a {@link VariableBinding}
* representation.
* @return the textual representation.
*/
public String format(OID instanceOID, Variable variable, boolean withOID) {
String valueString;
String typeString = variable.getSyntaxString();
switch (variable.getSyntax()) {
case SMIConstants.SYNTAX_TIMETICKS :
valueString = String.valueOf(((TimeTicks) variable).getValue());
break;
case SMIConstants.SYNTAX_OCTET_STRING :
if (!is_PrintableOneLine(((OctetString)variable))) {
typeString = TYPE_NAME_4_OCTETSTRING_IN_HEX;
valueString = ((OctetString)variable).toHexString();
}
else {
valueString = variable.toString();
}
break;
case BER.BITSTRING:
valueString = ((BitString)variable).toHexString();
break;
default :
valueString = variable.toString();
break;
}
if (withOID) {
return oidFormat.format(instanceOID.getValue())
+ SEPARATOR + typeString + SEPARATOR + valueString;
}
else {
return valueString;
}
}
示例2: stringToVariable
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public static Variable stringToVariable(String value, int smiSyntax) {
Variable var = AbstractVariable.createFromSyntax(smiSyntax);
if (var instanceof AssignableFromString)
((AssignableFromString) var).setValue(value);
else
throw new IllegalArgumentException(
"Unsupported conversion from String to "
+ var.getSyntaxString());
return var;
}
示例3: intToVariable
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public static Variable intToVariable(int i, int smiSyntax) {
Variable var = AbstractVariable.createFromSyntax(smiSyntax);
if (var instanceof AssignableFromInteger)
((AssignableFromInteger) var).setValue(i);
else
throw new IllegalArgumentException(
"Unsupported conversion from int to "
+ var.getSyntaxString());
return var;
}
示例4: longToVariable
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public static Variable longToVariable(long l, int smiSyntax) {
Variable var = AbstractVariable.createFromSyntax(smiSyntax);
if (var instanceof AssignableFromLong)
((AssignableFromLong) var).setValue(l);
else
throw new IllegalArgumentException(
"Unsupported conversion from long to "
+ var.getSyntaxString());
return var;
}
示例5: castToInt
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public static int castToInt(Variable variable) {
switch (variable.getSyntax()) {
case SMIConstants.SYNTAX_INTEGER:
return ((Integer32) variable).toInt();
default:
throw new IllegalArgumentException("Unsupported cast from "
+ variable.getSyntaxString() + " to int");
}
}
示例6: castToLong
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public static long castToLong(Variable variable) {
switch (variable.getSyntax()) {
case SMIConstants.SYNTAX_GAUGE32:
return ((Gauge32) variable).toLong();
case SMIConstants.SYNTAX_COUNTER32:
return ((Counter32) variable).toLong();
case SMIConstants.SYNTAX_COUNTER64:
return ((Counter64) variable).toLong();
case SMIConstants.SYNTAX_TIMETICKS:
return ((TimeTicks) variable).toLong();
default:
throw new IllegalArgumentException("Unsupported cast from "
+ variable.getSyntaxString() + " to long");
}
}