@Test public void testProcessSyntaxWithNull() { SnmpValueFactory valueFactory = SnmpUtils.getValueFactory(); assertNotNull(valueFactory); byte [] macAddr = {0x00, 0x55, 0x55, 0x55, 0x55, 0x55}; SnmpValue octetString = valueFactory.getOctetString(macAddr); Parm parm = SyntaxToEvent.processSyntax("Test",octetString); assertEquals("Test", parm.getParmName()); assertEquals(EventConstants.XML_ENCODING_MAC_ADDRESS, parm.getValue().getEncoding()); assertEquals("00:55:55:55:55:55", parm.getValue().getContent()); }
public static Parm processSyntax(final String name, final SnmpValue value) { final Value val = new Value(); boolean found = false; for (int i = 0; i < m_syntaxToEvents.length; i++) { if (m_syntaxToEvents[i].getTypeId() == -1 || m_syntaxToEvents[i].getTypeId() == value.getType()) { val.setType(m_syntaxToEvents[i].getType()); String encoding = null; if (value.isDisplayable()) { if (name.matches(".*[Mm][Aa][Cc].*")) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_TEXT; } } else { if (value.getBytes().length == 6) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_BASE64; } } val.setEncoding(encoding); val.setContent(EventConstants.toString(encoding, value)); found = true; break; } } if (!found) { throw new IllegalStateException("Internal error: fell through the " + "bottom of the loop. The syntax-to-events array might not have a " + "catch-all for Object"); } final Parm parm = new Parm(); parm.setParmName(name); parm.setValue(val); return parm; }
SyntaxToEvent { public static Parm processSyntax(final String name, final SnmpValue value) { final Value val = new Value(); boolean found = false; for (int i = 0; i < m_syntaxToEvents.length; i++) { if (m_syntaxToEvents[i].getTypeId() == -1 || m_syntaxToEvents[i].getTypeId() == value.getType()) { val.setType(m_syntaxToEvents[i].getType()); String encoding = null; if (value.isDisplayable()) { if (name.matches(".*[Mm][Aa][Cc].*")) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_TEXT; } } else { if (value.getBytes().length == 6) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_BASE64; } } val.setEncoding(encoding); val.setContent(EventConstants.toString(encoding, value)); found = true; break; } } if (!found) { throw new IllegalStateException("Internal error: fell through the " + "bottom of the loop. The syntax-to-events array might not have a " + "catch-all for Object"); } final Parm parm = new Parm(); parm.setParmName(name); parm.setValue(val); return parm; } }
SyntaxToEvent { public static Parm processSyntax(final String name, final SnmpValue value) { final Value val = new Value(); boolean found = false; for (int i = 0; i < m_syntaxToEvents.length; i++) { if (m_syntaxToEvents[i].getTypeId() == -1 || m_syntaxToEvents[i].getTypeId() == value.getType()) { val.setType(m_syntaxToEvents[i].getType()); String encoding = null; if (value.isDisplayable()) { if (name.matches(".*[Mm][Aa][Cc].*")) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_TEXT; } } else { if (value.getBytes().length == 6) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_BASE64; } } val.setEncoding(encoding); val.setContent(EventConstants.toString(encoding, value)); found = true; break; } } if (!found) { throw new IllegalStateException("Internal error: fell through the " + "bottom of the loop. The syntax-to-events array might not have a " + "catch-all for Object"); } final Parm parm = new Parm(); parm.setParmName(name); parm.setValue(val); return parm; } private  SyntaxToEvent(int typeId, String type); }
SyntaxToEvent { public static Parm processSyntax(final String name, final SnmpValue value) { final Value val = new Value(); boolean found = false; for (int i = 0; i < m_syntaxToEvents.length; i++) { if (m_syntaxToEvents[i].getTypeId() == -1 || m_syntaxToEvents[i].getTypeId() == value.getType()) { val.setType(m_syntaxToEvents[i].getType()); String encoding = null; if (value.isDisplayable()) { if (name.matches(".*[Mm][Aa][Cc].*")) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_TEXT; } } else { if (value.getBytes().length == 6) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_BASE64; } } val.setEncoding(encoding); val.setContent(EventConstants.toString(encoding, value)); found = true; break; } } if (!found) { throw new IllegalStateException("Internal error: fell through the " + "bottom of the loop. The syntax-to-events array might not have a " + "catch-all for Object"); } final Parm parm = new Parm(); parm.setParmName(name); parm.setValue(val); return parm; } private  SyntaxToEvent(int typeId, String type); static void setupSyntax(); static Parm processSyntax(final String name, final SnmpValue value); }
SyntaxToEvent { public static Parm processSyntax(final String name, final SnmpValue value) { final Value val = new Value(); boolean found = false; for (int i = 0; i < m_syntaxToEvents.length; i++) { if (m_syntaxToEvents[i].getTypeId() == -1 || m_syntaxToEvents[i].getTypeId() == value.getType()) { val.setType(m_syntaxToEvents[i].getType()); String encoding = null; if (value.isDisplayable()) { if (name.matches(".*[Mm][Aa][Cc].*")) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_TEXT; } } else { if (value.getBytes().length == 6) { encoding = EventConstants.XML_ENCODING_MAC_ADDRESS; } else { encoding = EventConstants.XML_ENCODING_BASE64; } } val.setEncoding(encoding); val.setContent(EventConstants.toString(encoding, value)); found = true; break; } } if (!found) { throw new IllegalStateException("Internal error: fell through the " + "bottom of the loop. The syntax-to-events array might not have a " + "catch-all for Object"); } final Parm parm = new Parm(); parm.setParmName(name); parm.setValue(val); return parm; } private  SyntaxToEvent(int typeId, String type); static void setupSyntax(); static Parm processSyntax(final String name, final SnmpValue value); static SyntaxToEvent[] m_syntaxToEvents; }