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             */
073            public boolean isEscapedModel();
074    
075            /**
076             * Returns the primary key of this model instance.
077             *
078             * @return the primary key of this model instance
079             */
080            public Serializable getPrimaryKeyObj();
081    
082            /**
083             * Sets the primary key of this model instance.
084             *
085             * @param primaryKeyObj the primary key of this model instance
086             */
087            public void setPrimaryKeyObj(Serializable primaryKeyObj);
088    
089            /**
090             * Returns the expando bridge for this model instance.
091             *
092             * @return the expando bridge for this model instance
093             */
094            public ExpandoBridge getExpandoBridge();
095    
096            /**
097             * Sets the expando bridge attributes for this model instance to the
098             * attributes stored in the service context.
099             *
100             * @param serviceContext the service context
101             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
102             *        )
103             */
104            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
105    
106            /**
107             * Creates a shallow clone of this model instance.
108             *
109             * @return the shallow clone of this model instance
110             */
111            public Object clone();
112    
113            /**
114             * Reset all original fields to current values.
115             */
116            public void resetOriginalValues();
117    
118            /**
119             * Returns a cache model object for this entity used by entity cache.
120             *
121             * @return the cache model object
122             */
123            public CacheModel<T> toCacheModel();
124    
125            /**
126             * Returns a copy of this entity as an escaped model instance by wrapping it
127             * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}.
128             *
129             * @return the escaped model instance
130             * @see    com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
131             */
132            public T toEscapedModel();
133    
134            /**
135             * Returns the XML representation of this model instance.
136             *
137             * @return the XML representation of this model instance
138             */
139            public String toXmlString();
140    
141    }