当前位置: 首页>>代码示例>>Java>>正文


Java Variable.getSyntaxString方法代码示例

本文整理汇总了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;
  }
}
 
开发者ID:kaitoy,项目名称:sneo,代码行数:50,代码来源:ColonSeparatedOidTypeValueVariableTextFormat.java

示例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;
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:11,代码来源:SnmpHelper.java

示例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;
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:11,代码来源:SnmpHelper.java

示例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;
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:11,代码来源:SnmpHelper.java

示例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");
	}
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:10,代码来源:SnmpHelper.java

示例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");
	}
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:16,代码来源:SnmpHelper.java


注:本文中的org.snmp4j.smi.Variable.getSyntaxString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。