private Event cursorToEvent(Cursor cursor) {
    Event event = new EventImpl();
    event.setID(cursor.getLong(0));

    long ts = cursor.getLong(1);
    Timestamp timestamp = new Timestamp(ts);
    event.setTimestamp(timestamp);

    event.setTitle(cursor.getString(2));
    event.setUser(cursor.getString(3));

    ts = cursor.getLong(4);
    timestamp = new Timestamp(ts);
    event.setStartTime(timestamp);

    ts = cursor.getLong(5);
    timestamp = new Timestamp(ts);
    event.setEndTime(timestamp);

    event.setDescription(cursor.getString(6));

    event.setProfilePicURI(cursor.getString(7));

    return event;
  }
예제 #2
0
  /**
   * Sets default values for each field that hasn't been provided manually.
   *
   * @param event currently handled event.
   */
  private static void autoSetMissingValues(Event event) {
    // Ensure that a timestamp is set (to now at least!)
    if (event.getTimestamp() == null) event.setTimestamp(new Date());

    // Ensure that a platform is set
    if (event.getPlatform() == null) event.setPlatform(DEFAULT_PLATFORM);

    // Ensure that a hostname is set
    if (event.getServerName() == null) event.setServerName(HOSTNAME_CACHE.getHostname());
  }
예제 #3
0
  public Event parse(String text) {
    Event event = null;
    Matcher matcher = pattern.matcher(text);

    if (matcher.find() && matcher.groupCount() == 4) {
      event = new Event();
      event.setEventType(EventType.valueOf(matcher.group(1)));
      event.setTimestamp(Long.valueOf(matcher.group(2)));
      event.setPath(matcher.group(3));
      event.setContentHash(matcher.group(4));
    }

    return event;
  }
예제 #4
0
 /**
  * Sets the timestamp in the event.
  *
  * @param timestamp timestamp of the event.
  * @return the current {@code EventBuilder} for chained calls.
  */
 public EventBuilder setTimestamp(Date timestamp) {
   event.setTimestamp(timestamp);
   return this;
 }