001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.notes; 003 004import java.util.Date; 005 006import org.openstreetmap.josm.data.osm.User; 007 008/** 009 * Represents a comment made on a note. All notes have at least on comment 010 * which is the comment the note was opened with. Comments are immutable. 011 */ 012public class NoteComment { 013 014 private final String text; 015 private final User user; 016 private final Date commentTimestamp; 017 private final Action action; 018 019 //not currently used. I'm planning on using this to keep track of new actions that need to be uploaded 020 private boolean isNew; 021 022 /** 023 * Every comment has an associated action. Some comments are just comments 024 * while others indicate the note being opened, closed or reopened 025 */ 026 public enum Action { 027 opened, 028 closed, 029 reopened, 030 commented, 031 hidden 032 } 033 034 /** 035 * @param createDate The time at which this comment was added 036 * @param user JOSM User object of the user who created the comment 037 * @param commentText The text left by the user. Is sometimes blank 038 * @param action The action associated with this comment 039 * @param isNew Whether or not this comment is new and needs to be uploaded 040 */ 041 public NoteComment(Date createDate, User user, String commentText, Action action, boolean isNew) { 042 this.text = commentText; 043 this.user = user; 044 this.commentTimestamp = createDate; 045 this.action = action; 046 this.isNew = isNew; 047 } 048 049 /** @return Plain text of user's comment */ 050 public String getText() { 051 return text; 052 } 053 054 /** @return JOSM's User object for the user who made this comment */ 055 public User getUser() { 056 return user; 057 } 058 059 /** @return The time at which this comment was created */ 060 public Date getCommentTimestamp() { 061 return commentTimestamp; 062 } 063 064 /** @return the action associated with this note */ 065 public Action getNoteAction() { 066 return action; 067 } 068 069 public void setNew(boolean isNew) { 070 this.isNew = isNew; 071 } 072 073 /** @return true if this is a new comment/action and needs to be uploaded to the API */ 074 public boolean isNew() { 075 return isNew; 076 } 077 078 @Override 079 public String toString() { 080 return text; 081 } 082}