3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.news;
17 import java.text.DateFormat;
18 import java.text.SimpleDateFormat;
19 import java.util.Date;
20 import java.util.Locale;
21 import java.util.zip.CRC32;
24 * Created by pk910 on 23.01.2016.
26 public class NewsItem {
28 private String sSource;
30 private String sUniqueId;
32 private String sTitle;
33 private String sSummary;
34 private String sContent;
36 private String sCategories;
38 private boolean bIsNew;
40 public NewsItem(int id, String source, long time, String uniqueid, long chksum, String title, String summary, String content, String link, String categories) {
45 sTitle = title.trim();
49 sCategories = categories;
52 public long calculateChkSum() {
53 CRC32 crc = new CRC32();
54 crc.update(sTitle.getBytes());
55 crc.update(sUniqueId.getBytes());
56 crc.update((int)iTime);
57 crc.update(sSummary.getBytes());
59 crc.update(sContent.getBytes());
61 crc.update(sLink.getBytes());
62 if(sCategories != null)
63 crc.update(sCategories.getBytes());
65 long crcvalue = crc.getValue();
70 public long getChkSum() {
74 public void setIsNew(int id) {
79 public boolean getIsNew(boolean reset) {
80 boolean isnew = bIsNew;
90 public String getSource() {
94 public long getTime() {
98 public String getFormatedDate() {
99 return getFormatedDate("dd.MM.yyyy");
102 public String getFormatedDate(String format) {
103 DateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.ENGLISH);
104 return df.format(new Date(iTime * 1000));
107 public String getUniqueId() {
111 public String getTitle() {
115 public String getSummary() {
119 public String getContent() {
123 public String getLink() {
127 public String getCategories() {