001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.util.LocaleUtil;
018 import com.liferay.portal.model.BaseModel;
019 import com.liferay.portal.model.CacheModel;
020 import com.liferay.portal.service.ServiceContext;
021 import com.liferay.portlet.expando.model.ExpandoBridge;
022
023 import java.util.Collections;
024 import java.util.Locale;
025 import java.util.Map;
026
027
033 public abstract class BaseModelImpl<T> implements BaseModel<T> {
034
035 public BaseModelImpl() {
036 }
037
038 @Override
039 public abstract Object clone();
040
041 public ExpandoBridge getExpandoBridge() {
042 throw new UnsupportedOperationException();
043 }
044
045 public Map<String, Object> getModelAttributes() {
046 return Collections.emptyMap();
047 }
048
049 public boolean isCachedModel() {
050 return _cachedModel;
051 }
052
053 public boolean isEscapedModel() {
054 return _ESCAPED_MODEL;
055 }
056
057 public boolean isNew() {
058 return _new;
059 }
060
061 public void resetOriginalValues() {
062 }
063
064 public void setCachedModel(boolean cachedModel) {
065 _cachedModel = cachedModel;
066 }
067
068 public void setExpandoBridgeAttributes(BaseModel<?> baseModel) {
069 ExpandoBridge thisExpandoBridge = getExpandoBridge();
070
071 ExpandoBridge baseModelExpandoBridge = baseModel.getExpandoBridge();
072
073 thisExpandoBridge.setAttributes(baseModelExpandoBridge.getAttributes());
074 }
075
076 public void setExpandoBridgeAttributes(ExpandoBridge expandoBridge) {
077 ExpandoBridge thisExpandoBridge = getExpandoBridge();
078
079 thisExpandoBridge.setAttributes(expandoBridge.getAttributes());
080 }
081
082 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
083 throw new UnsupportedOperationException();
084 }
085
086 public void setModelAttributes(Map<String, Object> attributes) {
087 }
088
089 public void setNew(boolean n) {
090 _new = n;
091 }
092
093 public CacheModel<T> toCacheModel() {
094 throw new UnsupportedOperationException();
095 }
096
097 public T toEscapedModel() {
098 throw new UnsupportedOperationException();
099 }
100
101 public T toUnescapedModel() {
102 return (T)this;
103 }
104
105 protected Locale getLocale(String languageId) {
106 Locale locale = null;
107
108 if (languageId != null) {
109 locale = LocaleUtil.fromLanguageId(languageId);
110 }
111
112 if (locale == null) {
113 locale = LocaleUtil.getMostRelevantLocale();
114 }
115
116 return locale;
117 }
118
119 private static final boolean _ESCAPED_MODEL = false;
120
121 private boolean _cachedModel;
122 private boolean _new;
123
124 }