/**
  * Method which takes a single OID and returns the response from the agent as a String.
  *
  * @param oid
  * @return
  * @throws IOException
  */
 public String getAsString(OID... oid) throws IOException {
   //        ResponseEvent event = get(new OID[]{oid});
   //        return event.getResponse().get(0).getVariable().toString();
   ResponseEvent event = get(oid);
   PDU response = event.getResponse();
   int size = oid.length;
   //        VariableBinding variableBinding=response.get(0);
   //        Variable variable=variableBinding.getVariable();
   //        String varStirng=variable.toString();
   //        return varStirng;
   StringBuilder builder = new StringBuilder();
   for (int i = 0; i < size; i++) {
     VariableBinding variableBinding = response.get(i);
     Variable variable = variableBinding.getVariable();
     String varStirng = variable.toString();
     String oi = variableBinding.getOid().toString();
     builder.append("oid: ").append(oi).append(" var: ").append(varStirng).append("\n");
   }
   return builder.toString();
 }
Пример #2
0
 public String toString() {
   if (type == PDU.V1TRAP) {
     StringBuilder buf = new StringBuilder();
     buf.append(getTypeString(type));
     buf.append("[reqestID=");
     buf.append(requestID);
     buf.append(",timestamp=");
     buf.append(timestamp);
     buf.append(",enterprise=");
     buf.append(enterprise);
     buf.append(",genericTrap=");
     buf.append(genericTrap);
     buf.append(",specificTrap=");
     buf.append(specificTrap);
     buf.append(", VBS[");
     for (int i = 0; i < variableBindings.size(); i++) {
       buf.append(variableBindings.get(i));
       if (i + 1 < variableBindings.size()) {
         buf.append("; ");
       }
     }
     buf.append("]]");
     return buf.toString();
   }
   return super.toString();
 }