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