92 lines
1.8 KiB
Java
92 lines
1.8 KiB
Java
package model;
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
|
|
import Classes.Category;
|
|
|
|
public class NewsModel {
|
|
|
|
private String author;
|
|
private String source;
|
|
private String imageURL;
|
|
private String newsURL;
|
|
private String title;
|
|
private String description;
|
|
private ArrayList<Category> tags;
|
|
private Date date;
|
|
|
|
public NewsModel(){
|
|
this.tags = new ArrayList<Category>();
|
|
}
|
|
public NewsModel addTag(Category tag) {
|
|
this.tags.add(tag);
|
|
return this;
|
|
}
|
|
|
|
public String getAuthor() {
|
|
return author;
|
|
}
|
|
public NewsModel setAuthor(String author) {
|
|
this.author = author;
|
|
return this;
|
|
}
|
|
public String getSource() {
|
|
return source;
|
|
}
|
|
public NewsModel setSource(String source) {
|
|
this.source = source;
|
|
return this;
|
|
}
|
|
public String getImageURL() {
|
|
return imageURL;
|
|
}
|
|
public NewsModel setImageURL(String imageURL) {
|
|
this.imageURL = imageURL;
|
|
return this;
|
|
}
|
|
public String getNewsURL() {
|
|
return newsURL;
|
|
}
|
|
public ArrayList<Category> getTags() {
|
|
return tags;
|
|
}
|
|
public NewsModel setNewsURL(String newsURL) {
|
|
this.newsURL = newsURL;
|
|
return this;
|
|
}
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
public NewsModel setTitle(String title) {
|
|
this.title = title;
|
|
return this;
|
|
}
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
public NewsModel setDescription(String description) {
|
|
this.description = description+"\n\n";
|
|
return this;
|
|
}
|
|
public Date getDate() {
|
|
return date;
|
|
}
|
|
public NewsModel setDate(String date) throws ParseException {
|
|
//on déclare le format de date
|
|
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
|
|
date = date.replace("Z", "+0000");
|
|
this.date = fmt.parse(date);
|
|
return this;
|
|
}
|
|
|
|
public NewsModel setDate(Date date){
|
|
this.date = date;
|
|
return this;
|
|
}
|
|
|
|
}
|