@Test public void translateSimpleVarbindTokens() { Assert.assertEquals("Simple single-digit integer varbind token", "%parm[#1]%", m_utils.translateFormatSubstToken("{I 1}")); Assert.assertEquals("Simple two-digit integer varbind token", "%parm[#42]%", m_utils.translateFormatSubstToken("{I 42}")); Assert.assertEquals("Model type substitution token", "%asset[manufacturer]%", m_utils.translateFormatSubstToken("{t}")); Assert.assertEquals("Model type substitution token", "%nodelabel%", m_utils.translateFormatSubstToken("{m}")); Assert.assertEquals("Event code substitution token", "%uei%", m_utils.translateFormatSubstToken("{e}")); }
public String translateFormatSubstToken(String inToken) { if (inToken == null) { throw new IllegalArgumentException("The input token must be non-null"); } String outToken = inToken; if (inToken.startsWith("{d")) { outToken = "%time%"; } else if (inToken.equals("{t}")) { outToken = "%asset[" + m_modelTypeAssetField + "]%"; } else if (inToken.equals("{m}")) { outToken = "%nodelabel%"; } else if (inToken.equals("{e}")) { outToken = "%uei%"; } else if (inToken.startsWith("{I") || inToken.startsWith("{S") || inToken.startsWith("{T")) { Matcher m = Pattern.compile("^\\{\\s*[IST]\\s+(\\w+\\s+)?(\\d+)\\s*\\}$").matcher(inToken); if (m.matches()) { outToken = "%parm[#" + m.group(2) + "]%"; } } return outToken; }
SpectrumUtils { public String translateFormatSubstToken(String inToken) { if (inToken == null) { throw new IllegalArgumentException("The input token must be non-null"); } String outToken = inToken; if (inToken.startsWith("{d")) { outToken = "%time%"; } else if (inToken.equals("{t}")) { outToken = "%asset[" + m_modelTypeAssetField + "]%"; } else if (inToken.equals("{m}")) { outToken = "%nodelabel%"; } else if (inToken.equals("{e}")) { outToken = "%uei%"; } else if (inToken.startsWith("{I") || inToken.startsWith("{S") || inToken.startsWith("{T")) { Matcher m = Pattern.compile("^\\{\\s*[IST]\\s+(\\w+\\s+)?(\\d+)\\s*\\}$").matcher(inToken); if (m.matches()) { outToken = "%parm[#" + m.group(2) + "]%"; } } return outToken; } }
SpectrumUtils { public String translateFormatSubstToken(String inToken) { if (inToken == null) { throw new IllegalArgumentException("The input token must be non-null"); } String outToken = inToken; if (inToken.startsWith("{d")) { outToken = "%time%"; } else if (inToken.equals("{t}")) { outToken = "%asset[" + m_modelTypeAssetField + "]%"; } else if (inToken.equals("{m}")) { outToken = "%nodelabel%"; } else if (inToken.equals("{e}")) { outToken = "%uei%"; } else if (inToken.startsWith("{I") || inToken.startsWith("{S") || inToken.startsWith("{T")) { Matcher m = Pattern.compile("^\\{\\s*[IST]\\s+(\\w+\\s+)?(\\d+)\\s*\\}$").matcher(inToken); if (m.matches()) { outToken = "%parm[#" + m.group(2) + "]%"; } } return outToken; } SpectrumUtils(); }
SpectrumUtils { public String translateFormatSubstToken(String inToken) { if (inToken == null) { throw new IllegalArgumentException("The input token must be non-null"); } String outToken = inToken; if (inToken.startsWith("{d")) { outToken = "%time%"; } else if (inToken.equals("{t}")) { outToken = "%asset[" + m_modelTypeAssetField + "]%"; } else if (inToken.equals("{m}")) { outToken = "%nodelabel%"; } else if (inToken.equals("{e}")) { outToken = "%uei%"; } else if (inToken.startsWith("{I") || inToken.startsWith("{S") || inToken.startsWith("{T")) { Matcher m = Pattern.compile("^\\{\\s*[IST]\\s+(\\w+\\s+)?(\\d+)\\s*\\}$").matcher(inToken); if (m.matches()) { outToken = "%parm[#" + m.group(2) + "]%"; } } return outToken; } SpectrumUtils(); String translateAllSubstTokens(EventFormat format); String translateFormatSubstToken(String inToken); List<Varbindsdecode> translateAllEventTables(EventFormat ef, String eventTablePath); Varbindsdecode translateEventTable(EventTable et, String parmId); String translateSeverity(int spectrumSeverity); void setModelTypeAssetField(String fieldName); String getModelTypeAssetField(); }
SpectrumUtils { public String translateFormatSubstToken(String inToken) { if (inToken == null) { throw new IllegalArgumentException("The input token must be non-null"); } String outToken = inToken; if (inToken.startsWith("{d")) { outToken = "%time%"; } else if (inToken.equals("{t}")) { outToken = "%asset[" + m_modelTypeAssetField + "]%"; } else if (inToken.equals("{m}")) { outToken = "%nodelabel%"; } else if (inToken.equals("{e}")) { outToken = "%uei%"; } else if (inToken.startsWith("{I") || inToken.startsWith("{S") || inToken.startsWith("{T")) { Matcher m = Pattern.compile("^\\{\\s*[IST]\\s+(\\w+\\s+)?(\\d+)\\s*\\}$").matcher(inToken); if (m.matches()) { outToken = "%parm[#" + m.group(2) + "]%"; } } return outToken; } SpectrumUtils(); String translateAllSubstTokens(EventFormat format); String translateFormatSubstToken(String inToken); List<Varbindsdecode> translateAllEventTables(EventFormat ef, String eventTablePath); Varbindsdecode translateEventTable(EventTable et, String parmId); String translateSeverity(int spectrumSeverity); void setModelTypeAssetField(String fieldName); String getModelTypeAssetField();  }