PageRenderTime 24ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/src/api/forum/forum/ForumThread.java

http://github.com/Gwindow/WhatAPI
Java | 255 lines | 83 code | 34 blank | 138 comment | 0 complexity | eb75e5fac9bfb238c6b9a78c0bdc200d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package api.forum.forum;
  2. import api.soup.MySoup;
  3. /**
  4. * The Class ForumThread.
  5. * Describes a single forum thread
  6. *
  7. * @author Gwindow
  8. */
  9. public class ForumThread {
  10. /**
  11. * The topic id.
  12. */
  13. private Number topicId;
  14. /**
  15. * The thread title.
  16. */
  17. private String title;
  18. /**
  19. * The author id.
  20. */
  21. private Number authorId;
  22. /**
  23. * The author name
  24. */
  25. private String authorName;
  26. /**
  27. * The thread post count
  28. */
  29. private Number postCount;
  30. /**
  31. * The last post time.
  32. */
  33. private String lastTime;
  34. /**
  35. * The last post author id.
  36. */
  37. private Number lastAuthorId;
  38. /**
  39. * The last post author name.
  40. */
  41. private String lastAuthorName;
  42. /**
  43. * The last post id.
  44. */
  45. private Number lastID;
  46. /**
  47. * The last read page.
  48. */
  49. private Number lastReadPage;
  50. /**
  51. * The last read post id.
  52. */
  53. private Number lastReadPostId;
  54. /**
  55. * If the thread is locked
  56. */
  57. private boolean locked;
  58. /**
  59. * If the thread is stickied
  60. */
  61. private boolean sticky;
  62. /**
  63. * If the thread has been read
  64. */
  65. private boolean read;
  66. /**
  67. * Get the author id.
  68. *
  69. * @return the author id
  70. */
  71. public Number getAuthorId() {
  72. return this.authorId;
  73. }
  74. /**
  75. * Get the author name.
  76. *
  77. * @return the author name
  78. */
  79. public String getAuthorName() {
  80. return this.authorName;
  81. }
  82. /**
  83. * Get the last post author id.
  84. *
  85. * @return the last post author id
  86. */
  87. public Number getLastAuthorId() {
  88. return this.lastAuthorId;
  89. }
  90. /**
  91. * Get the last post author name.
  92. *
  93. * @return the last post author name
  94. */
  95. public String getLastAuthorName() {
  96. return this.lastAuthorName;
  97. }
  98. /**
  99. * Get the last post id
  100. *
  101. * @return the last post id
  102. */
  103. public Number getLastPostId() {
  104. return this.lastID;
  105. }
  106. /**
  107. * Get the last read page.
  108. *
  109. * @return the last read page number
  110. */
  111. public Number getLastReadPage() {
  112. return this.lastReadPage;
  113. }
  114. /**
  115. * Get the last read post id.
  116. *
  117. * @return the last read post id
  118. */
  119. public Number getLastReadPostId() {
  120. return this.lastReadPostId;
  121. }
  122. /**
  123. * Get the last post time
  124. *
  125. * @return the post time
  126. */
  127. public String getLastTime() {
  128. return this.lastTime;
  129. }
  130. /**
  131. * Get the post count.
  132. *
  133. * @return the post count
  134. */
  135. public Number getPostCount() {
  136. return this.postCount;
  137. }
  138. /**
  139. * Get the thread title
  140. *
  141. * @return the thread title
  142. */
  143. public String getTitle() {
  144. return this.title;
  145. }
  146. /**
  147. * Get the topic id.
  148. *
  149. * @return the topicId
  150. */
  151. public Number getTopicId() {
  152. return this.topicId;
  153. }
  154. /**
  155. * Check if the thread is locked
  156. *
  157. * @return True if the thread is locked
  158. */
  159. public boolean isLocked() {
  160. return this.locked;
  161. }
  162. /**
  163. * Checks if is sticky.
  164. *
  165. * @return the sticky
  166. */
  167. public boolean isSticky() {
  168. return sticky;
  169. }
  170. /**
  171. * Checks if is read.
  172. *
  173. * @return true, if is read
  174. */
  175. public boolean isRead() {
  176. return this.read;
  177. }
  178. /**
  179. * Get the url to view the thread
  180. *
  181. * @return the thread url
  182. */
  183. public String getUrl() {
  184. return "forums.php?action=viewthread&threadid=" + topicId;
  185. }
  186. /**
  187. * Gets the url to jump to the last read post
  188. *
  189. * @return the last read url
  190. */
  191. public String getLastReadUrl() {
  192. return "forums.php?action=viewthread&threadid=" + topicId + "&page=" + lastReadPage;
  193. }
  194. /**
  195. * Subscribe to the thread.
  196. *
  197. * @return true if successful
  198. */
  199. public boolean subscribe(){
  200. return MySoup.pressLink("userhistory.php?action=thread_subscribe&topicid="
  201. + getTopicId().intValue() + "&auth=" + MySoup.getAuthKey());
  202. }
  203. /**
  204. * Unsubscribe from the thread.
  205. *
  206. * @return true if successful
  207. */
  208. public boolean unsubscribe(){
  209. return MySoup.pressLink("userhistory.php?action=thread_subscribe&topicid="
  210. + getTopicId().intValue() + "&auth=" + MySoup.getAuthKey());
  211. }
  212. @Override
  213. public String toString() {
  214. return "ForumThread [getAuthorId=" + getAuthorId() + ", getAuthorName=" + getAuthorName() + ", getLastAuthorId="
  215. + getLastAuthorId() + ", getLastAuthorName=" + getLastAuthorName() + ", getLastPostId=" + getLastPostId()
  216. + ", getLastReadPage=" + getLastReadPage() + ", getLastReadPostId=" + getLastReadPostId() + ", getLastTime="
  217. + getLastTime() + ", isLocked=" + isLocked() + ", getPostCount=" + getPostCount() + ", isSticky=" + isSticky()
  218. + ", getTitle=" + getTitle() + ", getTopicId=" + getTopicId() + ", getUrl=" + getUrl() + ", getLastReadUrl="
  219. + getLastReadUrl() + ", isRead=" + isRead() + "]";
  220. }
  221. }