001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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.
024     *
025     * @author Brian Wing Shun Chan
026     * @see    com.liferay.portal.model.impl.BaseModelImpl
027     */
028    public interface BaseModel<T> extends Cloneable, Comparable<T>, Serializable {
029    
030            /**
031             * Determines if this model instance does not yet exist in the database.
032             *
033             * @return <code>true</code> if this model instance does not yet exist in
034             *                 the database; <code>false</code> otherwise
035             */
036            public boolean isNew();
037    
038            /**
039             * Sets whether this model instance does not yet exist in the database.
040             *
041             * @param n whether this model instance does not yet exist in the database
042             */
043            public void setNew(boolean n);
044    
045            /**
046             * Determines if this model instance was retrieved from the entity cache.
047             *
048             * @return <code>true</code> if this model instance was retrieved from the
049             *                 entity cache; <code>false</code> otherwise
050             * @see    #setCachedModel(boolean)
051             */
052            public boolean isCachedModel();
053    
054            /**
055             * Sets whether this model instance was retrieved from the entity cache.
056             *
057             * @param cachedModel whether this model instance was retrieved from the
058             *                entity cache
059             * @see   com.liferay.portal.kernel.dao.orm.EntityCache
060             */
061            public void setCachedModel(boolean cachedModel);
062    
063            /**
064             * Determines if this model instance is escaped.
065             *
066             * @return <code>true</code> if this model instance is escaped;
067             *                 <code>false</code> otherwise
068             * @see    #setEscapedModel(boolean)
069             */
070            public boolean isEscapedModel();
071    
072            /**
073             * Sets whether this model instance is escaped, meaning that all strings
074             * returned from getter methods are HTML safe.
075             *
076             * <p>
077             * A model instance can be made escaped by wrapping it with an HTML auto
078             * escape handler using its <code>toEscapedModel</code> method. For example,
079             * {@link com.liferay.portal.model.UserModel#toEscapedModel()}.
080             * </p>
081             *
082             * @param escapedModel whether this model instance is escaped
083             * @see   com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
084             */
085            public void setEscapedModel(boolean escapedModel);
086    
087            /**
088             * Gets the primary key of this model instance.
089             *
090             * @return the primary key of this model instance
091             */
092            public Serializable getPrimaryKeyObj();
093    
094            /**
095             * Gets the expando bridge for this model instance.
096             *
097             * @return the expando bridge for this model instance
098             */
099            public ExpandoBridge getExpandoBridge();
100    
101            /**
102             * Sets the expando bridge attributes for this model instance to the
103             * attributes stored in the service context.
104             *
105             * @param serviceContext the service context to retrieve the expando bridge
106             *                attributes from
107             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
108             *                )
109             */
110            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
111    
112            /**
113             * Creates a shallow clone of this model instance.
114             *
115             * @return the shallow clone of this model instance
116             */
117            public Object clone();
118    
119            /**
120             * Gets the XML representation of this model instance.
121             *
122             * @return the XML representation of this model instance
123             */
124            public String toXmlString();
125    
126    }