Author: ssolsagl
Date: 2007-05-08 13:09:28 +0200 (Tue, 08 May 2007)
New Revision: 5017
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/BlogSearchResultItem.java
Log:
added more functionality
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/BlogSearchResultItem.java
===================================================================
---
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/BlogSearchResultItem.java
2007-05-08 11:09:06 UTC (rev 5016)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/BlogSearchResultItem.java
2007-05-08 11:09:28 UTC (rev 5017)
@@ -1,34 +1,203 @@
package no.schibstedsok.searchportal.result;
+import no.schibstedsok.searchportal.view.StringChopper;
+
public class BlogSearchResultItem extends BasicSearchResultItem { // Extend
BasicSearchResultItem
/* Path to blogtipsicon */
- String blogTipsIcon;
+ private String blogTipsIcon;
/* Display this date */
- String displayDate;
+ private String displayDate;
+ private String blogTitle;
- public String getBlogTipsIcon() {
+ private String contentTitle;
+
+ private String parentUrl;
+
+ private String url;
+
+ private String comments;
+
+ private String body;
+
+ private String moreHits;
+
+ private String author;
+
+
+ public String getContentTitle() {
+ return contentTitle;
+ }
+
+ public void setContentTitle(String contentTitle) {
+ this.contentTitle = contentTitle;
+ }
+
+
+ /**
+ * Return first non-null value of contentTitle, blogTitle or url
+ * @return linktitle
+ */
+ // Transient
+ public String getLinkTitle() {
+ if(contentTitle != null) {
+ return contentTitle;
+ }
+ if(blogTitle != null){
+ return blogTitle;
+ }
+ return url;
+ }
+
+ /**
+ * Trim linktitle
+ * @return trimmed linktitle
+ */
+ public String getLinkTitleTrimmed() {
+ return StringChopper.chop(getLinkTitle(), 70);
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getBlogTipsIcon() {
return blogTipsIcon;
}
-
public void setBlogTipsIcon(String blogTipsIcon) {
this.blogTipsIcon = blogTipsIcon;
}
-
public String getDisplayDate() {
return displayDate;
}
-
public void setDisplayDate(String displayDate) {
this.displayDate = displayDate;
}
-
-
-
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ public String getComments() {
+ return comments;
+ }
+
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+
+ public String getMoreHits() {
+ return moreHits;
+ }
+
+ public void setMoreHits(String moreHits) {
+ this.moreHits = moreHits;
+ }
+
+ public String getParentUrl() {
+ return parentUrl;
+ }
+
+ public void setParentUrl(String parentUrl) {
+ this.parentUrl = parentUrl;
+ }
+
+ private boolean isHitInBody() {
+ if(body == null) {
+ return false;
+ }
+ return body.indexOf("<b>") > -1;
+ }
+
+ /**
+ * isHitInComments()
+ * @return true if hit in comments
+ */
+ private boolean isHitInComments() {
+ if(comments == null || isHitInBody()) {
+ return false;
+ }
+ return comments.indexOf("<b>") > -1;
+ }
+
+ /**
+ * Get the title of the blog
+ * @return title of the blog
+ */
+ public String getBlogTitle() {
+ return blogTitle;
+
+ }
+
+ /**
+ * Set the title for the blog.
+ * @param title for blog
+ */
+ public void setBlogTitle(String title) {
+ blogTitle = title;
+ }
+
+ /**
+ * Get body or comment, depends on where the search matched.
+ * @return body or comment
+ */
+ public String getBodyOrComments() {
+ if(isHitInBody()) {
+ return body;
+ }
+ return comments;
+ }
+
+ /**
+ * hasAuthor() checks if the blog entry has an authorinformation.
+ * @return true if has author information.
+ */
+ public boolean hasAuthor() {
+ return author != null;
+ }
+
+ /**
+ * hasMoreHits() can be used to determine if we have severeal hits
+ * from blog
+ * @return true if has more hits
+ */
+ public boolean hasMoreHitsFromBlog() {
+ return moreHits != null;
+ }
+
+ /**
+ * If the blog result does not refert to a parentUrl it means that
+ * we have the frontpage of the article. Otherwise it may a comment
+ * from the article.
+ * @return if entry is blog frontpage.
+ */
+ public boolean isFrontPage() {
+
+ if(parentUrl == null) {
+ return true;
+ }
+ boolean isFrontPage = parentUrl.equals(url);
+ return isFrontPage;
+ }
}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits