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 has been wrapped with an HTML auto
065             * escape handler.
066             *
067             * @return <code>true</code> if this model instance has been wrapped with an
068             *                 HTML auto escape handler; <code>false</code> otherwise
069             * @see    #setEscapedModel(boolean)
070             */
071            public boolean isEscapedModel();
072    
073            /**
074             * Sets whether this model instance has been wrapped with an HTML auto
075             * escape handler.
076             *
077             * <p>
078             * A model instance can be wrapped with an HTML auto escape handler using
079             * its <code>toEscapedModel</code> method. For example, {@link
080             * com.liferay.portal.model.UserModel#toEscapedModel()}.
081             * </p>
082             *
083             * @param escapedModel whether this model instance has been wrapped with an
084             *                HTML auto escape handler
085             * @see   com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
086             */
087            public void setEscapedModel(boolean escapedModel);
088    
089            /**
090             * Gets the primary key for this model instance.
091             *
092             * @return the primary key
093             */
094            public Serializable getPrimaryKeyObj();
095    
096            /**
097             * Gets the expando bridge for this model instance.
098             *
099             * @return the expando bridge
100             */
101            public ExpandoBridge getExpandoBridge();
102    
103            /**
104             * Sets the expando bridge attributes for this model instance to the
105             * attributes stored in the service context.
106             *
107             * @param serviceContext the service context to retrieve the expando bridge
108             *                attributes from
109             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
110             *                )
111             */
112            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
113    
114            /**
115             * Creates a shallow clone of this model instance.
116             *
117             * @return the clone
118             */
119            public Object clone();
120    
121            /**
122             * Gets the XML representation of this model instance.
123             *
124             * @return the XML representation of this model instance
125             */
126            public String toXmlString();
127    
128    }