001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model;
016    
017    import com.liferay.portal.service.ServiceContext;
018    import com.liferay.portlet.expando.model.ExpandoBridge;
019    
020    import java.io.Serializable;
021    
022    /**
023     * The base interface for all model classes. This interface should never need to
024     * be used directly.
025     *
026     * @author Brian Wing Shun Chan
027     * @see    com.liferay.portal.model.impl.BaseModelImpl
028     */
029    public interface BaseModel<T>
030            extends ClassedModel, Cloneable, Comparable<T>, Serializable {
031    
032            /**
033             * Returns <code>true</code> if this model instance does not yet exist in
034             * the database.
035             *
036             * @return <code>true</code> if this model instance does not yet exist in
037             *         the database; <code>false</code> otherwise
038             */
039            public boolean isNew();
040    
041            /**
042             * Sets whether this model instance does not yet exist in the database.
043             *
044             * @param n whether this model instance does not yet exist in the database
045             */
046            public void setNew(boolean n);
047    
048            /**
049             * Returns <code>true</code> if this model instance was retrieved from the
050             * entity cache.
051             *
052             * @return <code>true</code> if this model instance was retrieved from the
053             *         entity cache; <code>false</code> otherwise
054             * @see    #setCachedModel(boolean)
055             */
056            public boolean isCachedModel();
057    
058            /**
059             * Sets whether this model instance was retrieved from the entity cache.
060             *
061             * @param cachedModel whether this model instance was retrieved from the
062             *        entity cache
063             * @see   com.liferay.portal.kernel.dao.orm.EntityCache
064             */
065            public void setCachedModel(boolean cachedModel);
066    
067            /**
068             * Returns <code>true</code> if this model instance is escaped.
069             *
070             * @return <code>true</code> if this model instance is escaped;
071             *         <code>false</code> otherwise
072             * @see    #setEscapedModel(boolean)
073             */
074            public boolean isEscapedModel();
075    
076            /**
077             * Sets whether this model instance is escaped, meaning that all strings
078             * returned from getter methods are HTML safe.
079             *
080             * <p>
081             * A model instance can be made escaped by wrapping it with an HTML auto
082             * escape handler using its <code>toEscapedModel</code> method. For example,
083             * {@link com.liferay.portal.model.UserModel#toEscapedModel()}.
084             * </p>
085             *
086             * @param escapedModel whether this model instance is escaped
087             * @see   com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
088             */
089            public void setEscapedModel(boolean escapedModel);
090    
091            /**
092             * Returns the primary key of this model instance.
093             *
094             * @return the primary key of this model instance
095             */
096            public Serializable getPrimaryKeyObj();
097    
098            /**
099             * Sets the primary key of this model instance.
100             *
101             * @param primaryKeyObj the primary key of this model instance
102             */
103            public void setPrimaryKeyObj(Serializable primaryKeyObj);
104    
105            /**
106             * Returns the expando bridge for this model instance.
107             *
108             * @return the expando bridge for this model instance
109             */
110            public ExpandoBridge getExpandoBridge();
111    
112            /**
113             * Sets the expando bridge attributes for this model instance to the
114             * attributes stored in the service context.
115             *
116             * @param serviceContext the service context
117             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
118             *        )
119             */
120            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
121    
122            /**
123             * Creates a shallow clone of this model instance.
124             *
125             * @return the shallow clone of this model instance
126             */
127            public Object clone();
128    
129            /**
130             * Reset all original fields to current values.
131             */
132            public void resetOriginalValues();
133    
134            /**
135             * Returns a cache model object for this entity used by entity cache.
136             *
137             * @return the cache model object
138             */
139            public CacheModel<T> toCacheModel();
140    
141            /**
142             * Returns a copy of this entity as an escaped model instance by wrapping it
143             * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}.
144             *
145             * @return the escaped model instance
146             * @see    com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
147             */
148            public T toEscapedModel();
149    
150            /**
151             * Returns the XML representation of this model instance.
152             *
153             * @return the XML representation of this model instance
154             */
155            public String toXmlString();
156    
157    }