public class Comment extends Object implements Comparable<Comment>
| Modifier and Type | Field and Description |
|---|---|
static int | MAX_NAME_LENMaximum length of a commenter name |
| Constructor and Description |
|---|
Comment(String text,
String name,
int rating)My comment, now |
Comment(String text,
String name,
int rating,
long time,
boolean isMine)Create a comment with the specified text, name, rating, time, and ownership. |
| Modifier and Type | Method and Description |
|---|---|
int | compareTo(Comment c)Compares comments in reverse chronological order (newest first). |
boolean | equals(Object o)Comments within 10 minutes (not necessarily in same bucket) and otherwise equal are
considered equal. |
boolean | equalsIgnoreTimestamp(Comment c)Checks equality ignoring the timestamp, comparing only rating, text, and name. |
static Comment | fromPersistentString(String s)Parses a comment from its persistent string representation. |
int | getID()Returns a unique ID for this comment, usable with CommentSet.remove(int). |
String | getName()Returns the commenter's name. |
int | getRating()Returns the rating (0-5). |
String | getText()Returns the comment text. |
long | getTime()Returns the comment timestamp in java time (milliseconds since epoch). |
int | hashCode()Returns the bucket number for hash-based grouping. |
boolean | isHidden()Returns whether this comment is hidden (deleted by the user). |
boolean | isMine()Returns whether this comment was posted by the local user. |
(package private) void | setHidden()Mark this comment as hidden. |
String | toPersistentString()Converts this comment to a persistent string representation. |
public static final int MAX_NAME_LEN
public Comment(String text, String name, int rating)
text - may be null, will be truncated to max length, newlines replaced with spacesname - may be null, will be truncated to max length, newlines and commas removedrating - 0-5public Comment(String text, String name, int rating, long time, boolean isMine)
text - may be null, will be truncated to max length, newlines replaced with spacesname - may be null, will be truncated to max length, newlines and commas removedtime - java time (ms)rating - 0-5isMine - whether this comment is from the local userpublic int compareTo(Comment c)
compareTo in interface Comparable<Comment>c - the other Comment to compare topublic boolean equals(Object o)
public boolean equalsIgnoreTimestamp(Comment c)
c - the other Comment to compare topublic static Comment fromPersistentString(String s)
s - the persistent stringpublic int getID()
public String getName()
public int getRating()
public String getText()
public long getTime()
public int hashCode()
public boolean isHidden()
public boolean isMine()
void setHidden()
public String toPersistentString()