/** * Method to add {@link FlowFile} attributes from a {@link VariableBinding} * @param variableBinding {@link VariableBinding} * @param attributes {@link FlowFile} attributes to update */ private static void addAttributeFromVariable(VariableBinding variableBinding, Map<String, String> attributes) { attributes.put(SNMP_PROP_PREFIX + variableBinding.getOid() + SNMP_PROP_DELIMITER + variableBinding.getVariable().getSyntax(), variableBinding.getVariable().toString()); }
/** * Gets the syntax of the variable bindings value. * @return * a SMI syntax identifier (see {@link SMIConstants}). */ public final int getSyntax() { return variable.getSyntax(); }
@Override public boolean isEndOfMib() { return m_value.getSyntax() == SMIConstants.EXCEPTION_END_OF_MIB_VIEW; }
@Override public boolean isNumeric() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_INTEGER: case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: case SMIConstants.SYNTAX_TIMETICKS: case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: return true; default: return false; } }
private static boolean isVolatileByDefault(Variable value) { if (value == null) { return true; } switch (value.getSyntax()) { case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: { return true; } default: return false; } }
@Override public int getType() { return m_value.getSyntax(); }
/** * Gets the syntax of the variable bindings value. * @return * a SMI syntax identifier (see {@link SMIConstants}). */ public final int getSyntax() { return variable.getSyntax(); }
public boolean isNumeric() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_INTEGER: case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: case SMIConstants.SYNTAX_TIMETICKS: case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: return true; default: return false; } }
/** * Gets the syntax of the variable bindings value. * @return * a SMI syntax identifier (see {@link SMIConstants}). */ public final int getSyntax() { return variable.getSyntax(); }
/** * Get the syntax of the scalars value by evaluating the internal cached value first. If that is {@code null}, * the {@link #getValue()} method is called instead to allow subclasses to return an updated value. * * @return {@code value.getSyntax()} if value is not null and {@code getValue().,getSyntax()} if value is null. */ protected int getSyntax() { return (value != null) ? value.getSyntax() : getValue().getSyntax(); }
@Override public InetAddress toInetAddress() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_IPADDRESS: return ((IpAddress)m_value).getInetAddress(); default: throw new IllegalArgumentException("cannot convert "+m_value+" to an InetAddress"); } }
@Override public String toHexString() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).toHexString().replaceAll(":", ""); default: throw new IllegalArgumentException("cannot convert "+m_value+" to a HexString"); } }
public String toHexString() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).toHexString().replaceAll(":", ""); default: throw new IllegalArgumentException("cannot convert "+m_value+" to a HexString"); } }
public InetAddress toInetAddress() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_IPADDRESS: return ((IpAddress)m_value).getInetAddress(); default: throw new IllegalArgumentException("cannot convert "+m_value+" to an InetAddress"); } }
@Override public String toHexString() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).toHexString().replaceAll(":", ""); default: throw new IllegalArgumentException("cannot convert "+m_value+" to a HexString"); } }
@Override public SnmpObjId toSnmpObjId() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return SnmpObjId.get(((OID)m_value).getValue()); default: throw new IllegalArgumentException("cannot convert "+m_value+" to an SnmpObjId"); } }
@Override public SnmpObjId toSnmpObjId() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return SnmpObjId.get(((OID)m_value).getValue()); default: throw new IllegalArgumentException("cannot convert "+m_value+" to an SnmpObjId"); } }
public SnmpObjId toSnmpObjId() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return SnmpObjId.get(((OID)m_value).getValue()); default: throw new IllegalArgumentException("cannot convert "+m_value+" to an SnmpObjId"); } }
public String toDisplayString() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_OBJECT_IDENTIFIER : return SnmpObjId.get(((OID)m_value).getValue()).toString(); case SMIConstants.SYNTAX_TIMETICKS : return Long.toString(toLong()); case SMIConstants.SYNTAX_OCTET_STRING : return toStringDottingCntrlChars(((OctetString)m_value).getValue()); default : return m_value.toString(); } }
@Override public long getTimeStamp() { LOG.debug("V2 {} first varbind value: {}", m_pduTypeString, getVarBindAt(0).getVariable()); switch (getVarBindAt(SNMP_SYSUPTIME_OID_INDEX).getVariable().getSyntax()) { case SMIConstants.SYNTAX_TIMETICKS: LOG.debug("V2 {} first varbind value is of type TIMETICKS (correct)", m_pduTypeString); return ((TimeTicks) getVarBindAt(SNMP_SYSUPTIME_OID_INDEX).getVariable()).getValue(); case SMIConstants.SYNTAX_INTEGER32: LOG.debug("V2 {} first varbind value is of type INTEGER, casting to TIMETICKS", m_pduTypeString); return ((Integer32) getVarBindAt(SNMP_SYSUPTIME_OID_INDEX).getVariable()).getValue(); default: throw new IllegalArgumentException("V2 "+m_pduTypeString+" does not have the required first varbind as TIMETICKS - cannot process "+m_pduTypeString); } }