forked from taywils/java_spark_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticle.java
More file actions
83 lines (67 loc) · 1.93 KB
/
Article.java
File metadata and controls
83 lines (67 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Article {
private String title;
private String content;
private Date createdAt;
private String summary;
private Integer id;
private Boolean deleted;
public Article(String title, String summary, String content, Integer size) {
this.title = title;
this.summary = summary;
this.content = content;
this.createdAt = new Date();
this.id = size;
this.deleted = false;
}
public Article(String title, String summary, String content, Integer id, Date createdAt, Boolean deleted) {
this.title = title;
this.summary = summary;
this.content = content;
this.createdAt = createdAt;
this.id = id;
this.deleted = deleted;
}
public String getTitle() {
return title;
}
public String getContent() {
return content;
}
public String getSummary() {
return summary;
}
public void setTitle(String title) {
this.title = title;
}
public void setContent(String content) {
this.content = content;
}
public void setSummary(String summary) {
this.summary = summary;
}
public Integer getId() {
return id;
}
public void delete() {
this.deleted = true;
}
public Boolean readable() {
return !this.deleted;
}
public String getCreatedAt() {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
return dateFormat.format(this.createdAt);
}
public String getEditLink() {
return "<a href='/article/update/" + this.id + "'>Edit</a>";
}
public String getDeleteLink() {
return "<a href='/article/delete/" + this.id + "'>Delete</a>";
}
public String getSummaryLink() {
return "<a href='/article/read/" + this.id + "'>" + this.summary + "</a>";
}
}