/src/com/google/wireless/gdata2/data/Entry.java

https://github.com/Jib-BAOSP/platform_external_gdata · Java · 401 lines · 185 code · 47 blank · 169 comment · 3 complexity · aeb76972b328c1cad9f12551a212dd9f MD5 · raw file

  1. // Copyright 2007 The Android Open Source Project
  2. package com.google.wireless.gdata2.data;
  3. import com.google.wireless.gdata2.data.batch.BatchInfo;
  4. import com.google.wireless.gdata2.parser.ParseException;
  5. /**
  6. * Entry in a GData feed. This is the rough equivalent of the atom:Entry
  7. * element. The "atom:entry" element represents an individual entry,
  8. * acting as a container for metadata and data associated with the
  9. * entry. This element can appear as a child of the atom:feed element,
  10. * or it can appear as the document (i.e., top-level) element of a
  11. * standalone Atom Entry Document.
  12. * The Entry class serves as a base class for Google service specific subclasses,
  13. * like a contact or a calendar event. As a base class it takes care of the default
  14. * attributes and elements that are common to all entries.
  15. */
  16. public class Entry {
  17. private String id = null;
  18. private String title = null;
  19. private String editUri = null;
  20. private String htmlUri = null;
  21. private String summary = null;
  22. private String content = null;
  23. private String author = null;
  24. private String email = null;
  25. private String category = null;
  26. private String categoryScheme = null;
  27. private String publicationDate = null;
  28. private String updateDate = null;
  29. private String eTagValue = null;
  30. private boolean deleted = false;
  31. private BatchInfo batchInfo = null;
  32. private String fields = null;
  33. private String contentSource = null;
  34. private String contentType = null;
  35. /**
  36. * Creates a new empty entry.
  37. */
  38. public Entry() {
  39. }
  40. /**
  41. * Clears all the values in this entry.
  42. */
  43. public void clear() {
  44. id = null;
  45. title = null;
  46. editUri = null;
  47. htmlUri = null;
  48. summary = null;
  49. content = null;
  50. contentType = null;
  51. contentSource = null;
  52. author = null;
  53. email = null;
  54. category = null;
  55. categoryScheme = null;
  56. publicationDate = null;
  57. updateDate = null;
  58. deleted = false;
  59. batchInfo = null;
  60. }
  61. /**
  62. * @return the author
  63. */
  64. public String getAuthor() {
  65. return author;
  66. }
  67. /**
  68. * @param author the author to set
  69. */
  70. public void setAuthor(String author) {
  71. this.author = author;
  72. }
  73. /**
  74. * @return the category
  75. */
  76. public String getCategory() {
  77. return category;
  78. }
  79. /**
  80. * @param category the category to set
  81. */
  82. public void setCategory(String category) {
  83. this.category = category;
  84. }
  85. /**
  86. * @return the categoryScheme
  87. */
  88. public String getCategoryScheme() {
  89. return categoryScheme;
  90. }
  91. /**
  92. * @param categoryScheme the categoryScheme to set
  93. */
  94. public void setCategoryScheme(String categoryScheme) {
  95. this.categoryScheme = categoryScheme;
  96. }
  97. /**
  98. * @return the content
  99. */
  100. public String getContent() {
  101. return this.content;
  102. }
  103. /**
  104. * @param content the content to set
  105. */
  106. public void setContent(String content) {
  107. this.content = content;
  108. }
  109. /**
  110. * @return the contents type, either one of the default
  111. * types (text, html, xhtml) or an atomMediaType
  112. */
  113. public String getContentType() {
  114. return contentType;
  115. }
  116. /**
  117. * @param type the contentType to set
  118. */
  119. public void setContentType(String type) {
  120. this.contentType = type;
  121. }
  122. /**
  123. * If the content itself is empty, the src attribute
  124. * points to the internet resource where the content
  125. * can be loaded from
  126. * @return the src attribute of the content element
  127. */
  128. public String getContentSource() {
  129. return contentSource;
  130. }
  131. /**
  132. * @param contentSource the url value to set
  133. */
  134. public void setContentSource(String contentSource) {
  135. this.contentSource = contentSource;
  136. }
  137. /**
  138. * @return the editUri
  139. */
  140. public String getEditUri() {
  141. return editUri;
  142. }
  143. /**
  144. * Note that setting the editUri is only valid during parsing
  145. * time, this is a server generated value and can not be changed
  146. * by the client normally
  147. * @param editUri the editUri to set
  148. */
  149. public void setEditUri(String editUri) {
  150. this.editUri = editUri;
  151. }
  152. /**
  153. * @return The uri for the HTML version of this entry.
  154. */
  155. public String getHtmlUri() {
  156. return htmlUri;
  157. }
  158. /**
  159. * Set the uri for the HTML version of this entry.
  160. * @param htmlUri The uri for the HTML version of this entry.
  161. */
  162. public void setHtmlUri(String htmlUri) {
  163. this.htmlUri = htmlUri;
  164. }
  165. /**
  166. * @return the id
  167. */
  168. public String getId() {
  169. return id;
  170. }
  171. /**
  172. * Note that setting the ID is only valid during parsing time,
  173. * an ID is a server generated value and can not be changed by
  174. * the client normally
  175. * @param id the id to set
  176. */
  177. public void setId(String id) {
  178. this.id = id;
  179. }
  180. /**
  181. * @return the publicationDate
  182. */
  183. public String getPublicationDate() {
  184. return publicationDate;
  185. }
  186. /**
  187. * Note that setting the publicationDate is only valid during
  188. * parsing time, this is a server generated value and can not be
  189. * changed by the client normally
  190. * @param publicationDate the publicationDate to set
  191. */
  192. public void setPublicationDate(String publicationDate) {
  193. this.publicationDate = publicationDate;
  194. }
  195. /**
  196. * @return the summary
  197. */
  198. public String getSummary() {
  199. return summary;
  200. }
  201. /**
  202. * @param summary the summary to set
  203. */
  204. public void setSummary(String summary) {
  205. this.summary = summary;
  206. }
  207. /**
  208. * @return the title
  209. */
  210. public String getTitle() {
  211. return title;
  212. }
  213. /**
  214. * @param title the title to set
  215. */
  216. public void setTitle(String title) {
  217. this.title = title;
  218. }
  219. /**
  220. * @return the updateDate
  221. */
  222. public String getUpdateDate() {
  223. return updateDate;
  224. }
  225. /**
  226. * Note that setting the updateDate is only valid during parsing
  227. * time, this is a server generated value and can not be changed
  228. * by the client normally
  229. * @param updateDate the updateDate to set
  230. */
  231. public void setUpdateDate(String updateDate) {
  232. this.updateDate = updateDate;
  233. }
  234. /**
  235. * @return true if this entry represents a tombstone
  236. */
  237. public boolean isDeleted() {
  238. return deleted;
  239. }
  240. /**
  241. * @param isDeleted true if the entry is deleted
  242. */
  243. public void setDeleted(boolean isDeleted) {
  244. deleted = isDeleted;
  245. }
  246. /**
  247. * @return the value of the parsed eTag attribute
  248. */
  249. public String getETag() {
  250. return eTagValue;
  251. }
  252. /**
  253. * Note that setting the etag is only valid during parsing
  254. * time, this is a server generated value and can not be changed
  255. * by the client normally
  256. * @param eTag the eTag on the entry
  257. */
  258. public void setETag(String eTag) {
  259. eTagValue = eTag;
  260. }
  261. /**
  262. * @return the value of the parsed fields attribute
  263. */
  264. public String getFields() {
  265. return fields;
  266. }
  267. /**
  268. * @param fields the fields expression on the entry, used during serialization
  269. */
  270. public void setFields(String fields) {
  271. this.fields = fields;
  272. }
  273. /**
  274. * Used internally to access batch related properties.
  275. * Clients should use {@link com.google.wireless.gdata2.data.batch.BatchUtils} instead.
  276. */
  277. public BatchInfo getBatchInfo() {
  278. return batchInfo;
  279. }
  280. /**
  281. * Used internally to update batch related properties.
  282. * Clients should use {@link com.google.wireless.gdata2.data.batch.BatchUtils} instead.
  283. */
  284. public void setBatchInfo(BatchInfo batchInfo) {
  285. this.batchInfo = batchInfo;
  286. }
  287. /**
  288. * Appends the name and value to this StringBuffer, if value is not null.
  289. * Uses the format: "<NAME>: <VALUE>\n"
  290. * @param sb The StringBuffer in which the name and value should be
  291. * appended.
  292. * @param name The name that should be appended.
  293. * @param value The value that should be appended.
  294. */
  295. protected void appendIfNotNull(StringBuffer sb,
  296. String name, String value) {
  297. if (!StringUtils.isEmpty(value)) {
  298. sb.append(name);
  299. sb.append(": ");
  300. sb.append(value);
  301. sb.append("\n");
  302. }
  303. }
  304. /**
  305. * Helper method that creates the String representation of this Entry.
  306. * Called by {@link #toString()}.
  307. * Subclasses can add additional data to the StringBuffer.
  308. * @param sb The StringBuffer that should be modified to add to the String
  309. * representation of this Entry.
  310. */
  311. protected void toString(StringBuffer sb) {
  312. appendIfNotNull(sb, "ID", id);
  313. appendIfNotNull(sb, "TITLE", title);
  314. appendIfNotNull(sb, "EDIT URI", editUri);
  315. appendIfNotNull(sb, "HTML URI", htmlUri);
  316. appendIfNotNull(sb, "SUMMARY", summary);
  317. appendIfNotNull(sb, "CONTENT", content);
  318. appendIfNotNull(sb, "AUTHOR", author);
  319. appendIfNotNull(sb, "CATEGORY", category);
  320. appendIfNotNull(sb, "CATEGORY SCHEME", categoryScheme);
  321. appendIfNotNull(sb, "PUBLICATION DATE", publicationDate);
  322. appendIfNotNull(sb, "UPDATE DATE", updateDate);
  323. appendIfNotNull(sb, "DELETED", String.valueOf(deleted));
  324. appendIfNotNull(sb, "ETAG", String.valueOf(eTagValue));
  325. if (batchInfo != null) {
  326. appendIfNotNull(sb, "BATCH", batchInfo.toString());
  327. }
  328. }
  329. /**
  330. * Creates a StringBuffer and calls {@link #toString(StringBuffer)}. The
  331. * return value for this method is simply the result of calling
  332. * {@link StringBuffer#toString()} on this StringBuffer. Mainly used for
  333. * debugging.
  334. */
  335. public String toString() {
  336. StringBuffer sb = new StringBuffer();
  337. toString(sb);
  338. return sb.toString();
  339. }
  340. /**
  341. * @return the email
  342. */
  343. public String getEmail() {
  344. return email;
  345. }
  346. /**
  347. * @param email the email to set
  348. */
  349. public void setEmail(String email) {
  350. this.email = email;
  351. }
  352. public void validate() throws ParseException {
  353. }
  354. }