summaryrefslogtreecommitdiff
path: root/src/com/google/wireless/gdata/data/Entry.java
blob: 3971f6b539962759fd4c7364f74e3292aa99d0a0 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
// Copyright 2007 The Android Open Source Project

package com.google.wireless.gdata.data;

import com.google.wireless.gdata.parser.ParseException;

/**
 * Entry in a GData feed.
 */
// TODO: make this an interface?
// allow for writing directly into data structures used by native PIM, etc.,
// APIs.
// TODO: comment that setId(), etc., only used for parsing code.
public class Entry {
    private String id = null;
    private String title = null;
    private String editUri = null;
    private String htmlUri = null;
    private String summary = null;
    private String content = null;
    private String author = null;
    private String email = null;
    private String category = null;
    private String categoryScheme = null;
    private String publicationDate = null;
    private String updateDate = null;
    private boolean deleted = false;
    
    /**
     * Creates a new empty entry.
     */
    public Entry() {
    }

    /**
     * Clears all the values in this entry.
     */
    public void clear() {
        id = null;
        title = null;
        editUri = null;
        htmlUri = null;
        summary = null;
        content = null;
        author = null;
        email = null;
        category = null;
        categoryScheme = null;
        publicationDate = null;
        updateDate = null;
        deleted = false;
    }

    /**
     * @return the author
     */
    public String getAuthor() {
        return author;
    }

    /**
     * @param author the author to set
     */
    public void setAuthor(String author) {
        this.author = author;
    }

    /**
     * @return the category
     */
    public String getCategory() {
        return category;
    }

    /**
     * @param category the category to set
     */
    public void setCategory(String category) {
        this.category = category;
    }

    /**
     * @return the categoryScheme
     */
    public String getCategoryScheme() {
        return categoryScheme;
    }

    /**
     * @param categoryScheme the categoryScheme to set
     */
    public void setCategoryScheme(String categoryScheme) {
        this.categoryScheme = categoryScheme;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * @return the editUri
     */
    public String getEditUri() {
        return editUri;
    }

    /**
     * @param editUri the editUri to set
     */
    public void setEditUri(String editUri) {
        this.editUri = editUri;
    }

    /**
     * @return The uri for the HTML version of this entry.
     */
    public String getHtmlUri() {
        return htmlUri;
    }

    /**
     * Set the uri for the HTML version of this entry.
     * @param htmlUri The uri for the HTML version of this entry.
     */
    public void setHtmlUri(String htmlUri) {
        this.htmlUri = htmlUri;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the publicationDate
     */
    public String getPublicationDate() {
        return publicationDate;
    }

    /**
     * @param publicationDate the publicationDate to set
     */
    public void setPublicationDate(String publicationDate) {
        this.publicationDate = publicationDate;
    }

    /**
     * @return the summary
     */
    public String getSummary() {
        return summary;
    }

    /**
     * @param summary the summary to set
     */
    public void setSummary(String summary) {
        this.summary = summary;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the updateDate
     */
    public String getUpdateDate() {
        return updateDate;
    }

    /**
     * @param updateDate the updateDate to set
     */
    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }

    /**
     * @return true if this entry represents a tombstone
     */
    public boolean isDeleted() {
        return deleted;
    }

    /**
     * @param isDeleted true if the entry is deleted
     */
    public void setDeleted(boolean isDeleted) {
        deleted = isDeleted;
    }
 
    /**
     * Appends the name and value to this StringBuffer, if value is not null.
     * Uses the format: "<NAME>: <VALUE>\n"
     * @param sb The StringBuffer in which the name and value should be
     * appended.
     * @param name The name that should be appended.
     * @param value The value that should be appended.
     */
    protected void appendIfNotNull(StringBuffer sb,
                                   String name, String value) {
        if (!StringUtils.isEmpty(value)) {
            sb.append(name);
            sb.append(": ");
            sb.append(value);
            sb.append("\n");
        }
    }

    /**
     * Helper method that creates the String representation of this Entry.
     * Called by {@link #toString()}.
     * Subclasses can add additional data to the StringBuffer.
     * @param sb The StringBuffer that should be modified to add to the String
     * representation of this Entry.
     */
    protected void toString(StringBuffer sb) {
        appendIfNotNull(sb, "ID", id);
        appendIfNotNull(sb, "TITLE", title);
        appendIfNotNull(sb, "EDIT URI", editUri);
        appendIfNotNull(sb, "HTML URI", htmlUri);        
        appendIfNotNull(sb, "SUMMARY", summary);
        appendIfNotNull(sb, "CONTENT", content);
        appendIfNotNull(sb, "AUTHOR", author);
        appendIfNotNull(sb, "CATEGORY", category);
        appendIfNotNull(sb, "CATEGORY SCHEME", categoryScheme);
        appendIfNotNull(sb, "PUBLICATION DATE", publicationDate);
        appendIfNotNull(sb, "UPDATE DATE", updateDate);
        appendIfNotNull(sb, "DELETED", String.valueOf(deleted));
    }

    /**
     * Creates a StringBuffer and calls {@link #toString(StringBuffer)}.  The
     * return value for this method is simply the result of calling
     * {@link StringBuffer#toString()} on this StringBuffer.  Mainly used for
     * debugging.
     */
    public String toString() {
        StringBuffer sb = new StringBuffer();
        toString(sb);
        return sb.toString();
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    public void validate() throws ParseException {
    }
}