001
014
015 package com.liferay.portal.kernel.search;
016
017 import com.liferay.portal.kernel.util.StringPool;
018 import com.liferay.portal.kernel.util.StringUtil;
019 import com.liferay.portal.kernel.util.Validator;
020
021 import java.util.Locale;
022
023 import javax.portlet.PortletURL;
024
025
029 public class Summary {
030
031 public Summary(
032 Locale locale, String title, String content, PortletURL portletURL) {
033
034 _title = title;
035 _content = content;
036 _locale = locale;
037 _portletURL = portletURL;
038 }
039
040 public Summary(String title, String content, PortletURL portletURL) {
041 _title = title;
042 _content = content;
043 _portletURL = portletURL;
044 }
045
046 public String getContent() {
047 if (Validator.isNull(_content)) {
048 return StringPool.BLANK;
049 }
050
051 return _content;
052 }
053
054 public Locale getLocale() {
055 return _locale;
056 }
057
058 public int getMaxContentLength() {
059 return _maxContentLength;
060 }
061
062 public PortletURL getPortletURL() {
063 return _portletURL;
064 }
065
066 public String getTitle() {
067 if (Validator.isNull(_title)) {
068 return StringPool.BLANK;
069 }
070
071 return _title;
072 }
073
074 public void setContent(String content) {
075 _content = content;
076
077 if ((_content != null) && (_maxContentLength > 0) &&
078 (_content.length() > _maxContentLength)) {
079
080 _content = StringUtil.shorten(_content, _maxContentLength);
081 }
082 }
083
084 public void setLocale(Locale locale) {
085 _locale = locale;
086 }
087
088 public void setMaxContentLength(int maxContentLength) {
089 _maxContentLength = maxContentLength;
090
091 setContent(_content);
092 }
093
094 public void setPortletURL(PortletURL portletURL) {
095 _portletURL = portletURL;
096 }
097
098 public void setTitle(String title) {
099 _title = title;
100 }
101
102 private String _content;
103 private Locale _locale;
104 private int _maxContentLength;
105 private PortletURL _portletURL;
106 private String _title;
107
108 }