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. 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> extends Cloneable, Comparable<T>, Serializable {
030    
031            /**
032             * Determines if this model instance does not yet exist in the database.
033             *
034             * @return <code>true</code> if this model instance does not yet exist in
035             *                 the database; <code>false</code> otherwise
036             */
037            public boolean isNew();
038    
039            /**
040             * Sets whether this model instance does not yet exist in the database.
041             *
042             * @param n whether this model instance does not yet exist in the database
043             */
044            public void setNew(boolean n);
045    
046            /**
047             * Determines if this model instance was retrieved from the entity cache.
048             *
049             * @return <code>true</code> if this model instance was retrieved from the
050             *                 entity cache; <code>false</code> otherwise
051             * @see    #setCachedModel(boolean)
052             */
053            public boolean isCachedModel();
054    
055            /**
056             * Sets whether this model instance was retrieved from the entity cache.
057             *
058             * @param cachedModel whether this model instance was retrieved from the
059             *                entity cache
060             * @see   com.liferay.portal.kernel.dao.orm.EntityCache
061             */
062            public void setCachedModel(boolean cachedModel);
063    
064            /**
065             * Determines if this model instance is escaped.
066             *
067             * @return <code>true</code> if this model instance is escaped;
068             *                 <code>false</code> otherwise
069             * @see    #setEscapedModel(boolean)
070             */
071            public boolean isEscapedModel();
072    
073            /**
074             * Sets whether this model instance is escaped, meaning that all strings
075             * returned from getter methods are HTML safe.
076             *
077             * <p>
078             * A model instance can be made escaped by wrapping it with an HTML auto
079             * escape handler using its <code>toEscapedModel</code> method. For example,
080             * {@link com.liferay.portal.model.UserModel#toEscapedModel()}.
081             * </p>
082             *
083             * @param escapedModel whether this model instance is escaped
084             * @see   com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
085             */
086            public void setEscapedModel(boolean escapedModel);
087    
088            /**
089             * Gets the primary key of this model instance.
090             *
091             * @return the primary key of this model instance
092             */
093            public Serializable getPrimaryKeyObj();
094    
095            /**
096             * Gets the expando bridge for this model instance.
097             *
098             * @return the expando bridge for this model instance
099             */
100            public ExpandoBridge getExpandoBridge();
101    
102            /**
103             * Sets the expando bridge attributes for this model instance to the
104             * attributes stored in the service context.
105             *
106             * @param serviceContext the service context to retrieve the expando bridge
107             *                attributes from
108             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
109             *                )
110             */
111            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
112    
113            /**
114             * Creates a shallow clone of this model instance.
115             *
116             * @return the shallow clone of this model instance
117             */
118            public Object clone();
119    
120            /**
121             * Gets the XML representation of this model instance.
122             *
123             * @return the XML representation of this model instance
124             */
125            public String toXmlString();
126    
127    }