/** Constructor */
 public SOAPMonitorData(Long id, String target, String soap_request) {
   this.id = id;
   // A null id is used to signal that the "most recent" entry
   // is being created.
   if (id == null) {
     this.time = "Most Recent";
     this.target = "---";
     this.soap_request = null;
     this.soap_response = null;
   } else {
     this.time = DateFormat.getTimeInstance().format(new Date());
     this.target = target;
     this.soap_request = soap_request;
     this.soap_response = null;
   }
 }
  /**
   * Tries very, very hard to parse the a date. We assume that the text is neither empty nor <code>
   * null</code>.
   */
  private Date parseDate(String text) {
    DateFormat formats[] =
        new DateFormat[] {
          DateFormat.getDateInstance(DateFormat.SHORT),
          DateFormat.getDateInstance(DateFormat.MEDIUM),
          DateFormat.getDateInstance(DateFormat.LONG),
          DateFormat.getDateInstance(DateFormat.FULL),
        };

    for (int i = 0; i < formats.length; i++) {
      DateFormat df = formats[i];
      try {
        Date date = df.parse(text);
        return date;

      } catch (ParseException ex) {
        continue;
      }
    }

    error("Could not parse date: " + text);
    return null;
  }
Exemple #3
0
/**
 * This class is used in the model of the ACLTree. The MessageNode contains an ACLMessage, a
 * direction and a date/timestamp
 *
 * @author Chris van Aart - Acklin B.V., the Netherlands
 * @created April 26, 2002
 */
public class ACLMessageNode extends DefaultMutableTreeNode {

  /**
   * Constructor for the MessageNode object
   *
   * @param str Description of Parameter
   */
  ACLMessageNode(String str) {
    super(str);
  }

  /**
   * Gets the Message attribute of the MessageNode object
   *
   * @return The Message value
   */
  public ACLMessage getMessage() {
    return theMessage;
  }

  /**
   * Gets the Performative attribute of the MessageNode object
   *
   * @return The Performative value
   */
  public String getPerformative() {
    return theMessage.getPerformative(theMessage.getPerformative());
  }

  /**
   * Gets the SendTo attribute of the MessageNode object
   *
   * @return The SendTo value
   */
  public String getSendTo() {
    if (theMessage.getAllReceiver().hasNext()) {
      AID sender = (AID) theMessage.getAllReceiver().next();
      return sender.getName();
    }
    return "<unknown>";
  }

  /**
   * Gets the Ontology attribute of the MessageNode object
   *
   * @return The Ontology value
   */
  public String getOntology() {
    String ontology = theMessage.getOntology();
    if (ontology != null) {
      return ontology;
    }
    return "<unknown>";
  }

  /**
   * Gets the Direction attribute of the MessageNode object
   *
   * @return The Direction value
   */
  public String getDirection() {
    return direction;
  }

  public String getTime() {
    return time;
  }

  public Date getTheDate() {
    return theDate;
  }

  /**
   * Sets the Message attribute of the MessageNode object
   *
   * @param msg The new Message value
   */
  public void setMessage(ACLMessage msg) {
    theMessage = (ACLMessage) msg.clone();
  }

  /**
   * Sets the Direction attribute of the MessageNode object
   *
   * @param theDirection The new Direction value
   */
  public void setDirection(String theDirection) {
    direction = theDirection;
  }

  public void setTime(String theTime) {
    time = theTime;
    try {
      this.theDate = dateFormat.parse(time);
    } catch (Exception ex) {
      jade.util.Logger.getMyLogger(this.getClass().getName())
          .log(jade.util.Logger.WARNING, ex.getMessage());
    }
  }

  public void setTheDate(Date theTheDate) {
    theDate = theTheDate;
  }

  public String receivedFrom() {
    if (theMessage.getSender() != null) {
      AID sender = theMessage.getSender();
      return sender.getName();
    }
    return "<unknown>";
  }

  private static DateFormat dateFormat =
      DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
  private Date theDate = new Date();
  private ACLMessage theMessage;
  private String direction;
  private String time;
}