/**
  * Gets the trap varbinds decode.
  *
  * @param trap the trap object
  * @return the trap varbinds decode
  */
 protected List<Varbindsdecode> getTrapVarbindsDecode(Notification trap) {
   Map<String, Varbindsdecode> decode = new LinkedHashMap<String, Varbindsdecode>();
   int vbNum = 1;
   for (SmiVariable var : trap.getObjects()) {
     String parmName = "parm[#" + vbNum + "]";
     SmiPrimitiveType type = var.getType().getPrimitiveType();
     if (type.equals(SmiPrimitiveType.ENUM)) {
       SortedMap<BigInteger, String> map = new TreeMap<BigInteger, String>();
       for (SmiNamedNumber v : var.getType().getEnumValues()) {
         map.put(v.getValue(), v.getId());
       }
       for (Entry<BigInteger, String> entry : map.entrySet()) {
         if (!decode.containsKey(parmName)) {
           Varbindsdecode newVarbind = new Varbindsdecode();
           newVarbind.setParmid(parmName);
           decode.put(newVarbind.getParmid(), newVarbind);
         }
         Decode d = new Decode();
         d.setVarbinddecodedstring(entry.getValue());
         d.setVarbindvalue(entry.getKey().toString());
         decode.get(parmName).addDecode(d);
       }
     }
     vbNum++;
   }
   return new ArrayList<Varbindsdecode>(decode.values());
 }
 /**
  * Gets the trap event description.
  *
  * @param trap the trap object
  * @return the trap event description
  */
 protected String getTrapEventDescr(Notification trap) {
   String description = trap.getDescription();
   // FIXME There a lot of detail here (like removing the last \n) that can go away when we don't
   // need to match mib2opennms exactly
   final String descrStartingNewlines = description.replaceAll("^", "\n<p>");
   final String descrEndingNewlines = descrStartingNewlines.replaceAll("$", "</p>\n");
   final StringBuffer dbuf = new StringBuffer(descrEndingNewlines);
   if (dbuf.charAt(dbuf.length() - 1) == '\n') {
     dbuf.deleteCharAt(dbuf.length() - 1); // delete the \n at the end
   }
   dbuf.append("<table>");
   dbuf.append("\n");
   int vbNum = 1;
   for (SmiVariable var : trap.getObjects()) {
     dbuf.append("\t<tr><td><b>\n\n\t").append(var.getId());
     dbuf.append("</b></td><td>\n\t%parm[#").append(vbNum).append("]%;</td><td><p>");
     SmiPrimitiveType type = var.getType().getPrimitiveType();
     if (type.equals(SmiPrimitiveType.ENUM)) {
       SortedMap<BigInteger, String> map = new TreeMap<BigInteger, String>();
       for (SmiNamedNumber v : var.getType().getEnumValues()) {
         map.put(v.getValue(), v.getId());
       }
       dbuf.append("\n");
       for (Entry<BigInteger, String> entry : map.entrySet()) {
         dbuf.append("\t\t")
             .append(entry.getValue())
             .append("(")
             .append(entry.getKey())
             .append(")\n");
       }
       dbuf.append("\t");
     }
     dbuf.append("</p></td></tr>\n");
     vbNum++;
   }
   if (dbuf.charAt(dbuf.length() - 1) == '\n') {
     dbuf.deleteCharAt(dbuf.length() - 1); // delete the \n at the end
   }
   dbuf.append("</table>\n\t");
   return dbuf.toString();
 }