blob: e8792b4e3600db0b6ccdd768a2bf548799f66382 [file] [log] [blame]
Nils Diewaldf399a672013-11-18 17:55:22 +00001package de.ids_mannheim.korap;
2
3import java.util.*;
4
5import de.ids_mannheim.korap.util.KorapDate;
6import de.ids_mannheim.korap.document.KorapPrimaryData;
7import de.ids_mannheim.korap.index.FieldDocument;
8
Nils Diewaldf399a672013-11-18 17:55:22 +00009import com.fasterxml.jackson.databind.ObjectMapper;
10import com.fasterxml.jackson.annotation.*;
11
12/* Todo:: Author and textClass may be arrays! */
13
Nils Diewaldf399a672013-11-18 17:55:22 +000014/**
15 * Abstract class representing a document in the KorAP index.
16 *
17 * @author ndiewald
18 */
Nils Diewald010c10f2013-12-17 01:58:31 +000019@JsonIgnoreProperties(ignoreUnknown = true)
Nils Diewaldf399a672013-11-18 17:55:22 +000020public abstract class KorapDocument {
21 private KorapPrimaryData primaryData;
22
23 @JsonIgnore
Nils Diewaldff6f7662014-09-21 15:08:52 +000024 public int internalDocID, localDocID, UID;
Nils Diewaldf399a672013-11-18 17:55:22 +000025
Nils Diewaldf399a672013-11-18 17:55:22 +000026 private String author, textClass, corpusID,
Nils Diewald49729942013-11-27 20:30:07 +000027 pubPlace, ID, title, subTitle,
Nils Diewald010c10f2013-12-17 01:58:31 +000028 foundries, tokenization,
Nils Diewald2cd1c3d2014-01-08 22:53:08 +000029 layerInfo, field;
30
Nils Diewaldf399a672013-11-18 17:55:22 +000031 private KorapDate pubDate;
32
33 /**
34 * Set the publication date of the document the match occurs in.
35 *
36 * @param date The date as a KorapDate compatible string representation.
37 * @return A KorapDate object for chaining.
38 * @see KorapDate#Constructor(String)
39 */
40 public KorapDate setPubDate (String date) {
41 // ObjectMapper mapper = new ObjectMapper();
42 this.pubDate = new KorapDate(date);
43 return this.pubDate;
44 };
45
46 /**
47 * Set the publication date of the document the match occurs in.
48 *
49 * @param date The date as a KorapDate object.
50 * @return A KorapDate object for chaining.
51 * @see KorapDate
52 */
53 public KorapDate setPubDate (KorapDate date) {
54 return (this.pubDate = date);
55 };
56
57 /**
58 * Get the publication date of the document the match occurs in as a KorapDate object.
59 */
60 @JsonIgnore
61 public KorapDate getPubDate () {
62 return this.pubDate;
63 };
64
65 @JsonProperty("pubDate")
66 public String getPubDateString () {
Nils Diewaldcde69082014-01-16 15:46:48 +000067 if (this.pubDate != null)
68 return this.pubDate.toDisplay();
69 return null;
Nils Diewaldf399a672013-11-18 17:55:22 +000070 };
71
72 public void setAuthor (String author) {
73 this.author = author;
74 };
75
76 public String getAuthor () {
77 return this.author;
78 };
79
80 public void setTextClass (String textClass) {
81 this.textClass = textClass;
82 };
83
84 public String getTextClass () {
85 return this.textClass;
86 };
87
88 public void setPubPlace (String pubPlace) {
89 this.pubPlace = pubPlace;
90 };
91
92 public String getPubPlace () {
93 return this.pubPlace;
94 };
95
96 public void setCorpusID (String corpusID) {
97 this.corpusID = corpusID;
98 };
99
100 @JsonProperty("corpusID")
101 public String getCorpusID () {
102 return this.corpusID;
103 };
104
105 public void setID (String ID) {
106 this.ID = ID;
107 };
108
Nils Diewald7cbcfe92014-09-22 22:01:51 +0000109 @JsonProperty("ID")
110 public String getID () {
111 return this.ID;
112 };
113
Nils Diewaldff6f7662014-09-21 15:08:52 +0000114 public void setUID (int UID) {
115 this.UID = UID;
116 };
117
Nils Diewald7cbcfe92014-09-22 22:01:51 +0000118 public void setUID (String UID) {
119 if (UID != null)
120 this.UID = Integer.parseInt(UID);
121 };
122
123
Nils Diewaldff6f7662014-09-21 15:08:52 +0000124 @JsonProperty("UID")
125 public int getUID () {
126 return this.UID;
127 };
128
Nils Diewaldf399a672013-11-18 17:55:22 +0000129 public void setTitle (String title) {
130 this.title = title;
131 };
132
133 public String getTitle () {
134 return this.title;
135 };
136
137 public void setSubTitle (String subTitle) {
138 this.subTitle = subTitle;
139 };
140
141 public String getSubTitle () {
142 return this.subTitle;
143 };
144
145 @JsonIgnore
146 public void setPrimaryData (String primary) {
147 this.primaryData = new KorapPrimaryData(primary);
148 };
149
150 public void setPrimaryData (KorapPrimaryData primary) {
151 this.primaryData = primary;
152 };
153
154 public String getPrimaryData () {
155 if (this.primaryData == null)
156 return "";
157 return this.primaryData.toString();
158 };
159
160 public String getPrimaryData (int startOffset) {
161 return this.primaryData.substring(startOffset);
162 };
163
164 public String getPrimaryData (int startOffset, int endOffset) {
165 return this.primaryData.substring(startOffset, endOffset);
166 };
167
168 @JsonIgnore
169 public int getPrimaryDataLength () {
170 return this.primaryData.length();
171 };
Nils Diewald49729942013-11-27 20:30:07 +0000172
173 public void setFoundries (String foundries) {
174 this.foundries = foundries;
175 };
176
177 public String getFoundries () {
178 return this.foundries;
179 };
180
181 public void setTokenization (String tokenization) {
182 this.tokenization = tokenization;
183 };
184
185 public String getTokenization () {
186 return this.tokenization;
187 };
Nils Diewald010c10f2013-12-17 01:58:31 +0000188
189 public void setLayerInfo (String layerInfo) {
190 this.layerInfo = layerInfo;
191 };
192
193 public String getLayerInfo () {
194 return this.layerInfo;
195 };
Nils Diewald2cd1c3d2014-01-08 22:53:08 +0000196
197 public void setField (String field) {
198 this.field = field;
199 };
200
201 public String getField () {
202 return this.field;
203 };
Nils Diewaldf399a672013-11-18 17:55:22 +0000204};