Added README.txt and GPL Header to Source Files
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / search / SearchIndices.java
1 /* SearchIndices.java
2  *
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.
7  *
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.
12  *
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/>.
15  */
16 package de.dhbwloe.campusapp.search;
17
18 import java.util.ArrayList;
19 import java.util.Date;
20
21 import de.dhbwloe.campusapp.CampusAppContext;
22
23 /**
24  * Created by pk910 on 19.01.2016.
25  */
26 public class SearchIndices {
27     private String keyname = null;
28     private StringBuilder keywordsBuffer = new StringBuilder();
29     protected boolean isStatic = false;
30     protected String target = new String();
31     protected String keywords = null;
32     protected String title = null;
33     protected String description = null;
34     protected long updateTime = 0;
35
36     public SearchIndices(String keyname) {
37         this.keyname = keyname;
38         this.updateTime = (new Date()).getTime()/1000;
39     }
40
41     public SearchIndices(String keyname, boolean isStatic) {
42         this.keyname = keyname;
43         this.isStatic = isStatic;
44     }
45
46     public void addKeyWord(String words) {
47         if(keywordsBuffer.length() > 0)
48             keywordsBuffer.append('\n');
49         keywordsBuffer.append(words);
50     }
51
52     public void addKeyWord(int words) {
53         addKeyWord(CampusAppContext.getInstance().getResString(words));
54     }
55
56     public void setTarget(String target) {
57         this.target = target;
58     }
59
60     public void setDescription(String description) {
61         this.description = description;
62     }
63
64     public void setTitle(String title) {
65         this.title = title;
66     }
67
68     public void setDescription(int description) {
69         this.description = CampusAppContext.getInstance().getResString(description);
70     }
71
72     public void setTitle(int title) {
73         this.title = CampusAppContext.getInstance().getResString(title);
74     }
75
76     public void setUpdateTime(long updateTime) {
77         this.updateTime = updateTime;
78     }
79
80     public String getKeyName() {
81         return this.keyname;
82     }
83
84     public String getKeyWords() {
85         return (this.keywords != null ? this.keywords : "") + this.keywordsBuffer.toString();
86     }
87
88     public boolean getIsStatic() {
89         return this.isStatic;
90     }
91
92     public String getTarget() {
93         return this.target;
94     }
95
96     public String getDescription() {
97         return this.description;
98     }
99
100     public String getTitle() {
101         return this.title;
102     }
103
104     public long getUpdateTime() {
105         return this.updateTime;
106     }
107 }
108