001    /**
002     * Copyright (c) 2000-2013 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    import java.util.Map;
023    
024    /**
025     * The base interface for all model classes. This interface should never need to
026     * be used directly.
027     *
028     * @author Brian Wing Shun Chan
029     * @see    com.liferay.portal.model.impl.BaseModelImpl
030     */
031    public interface BaseModel<T>
032            extends ClassedModel, Cloneable, Comparable<T>, Serializable {
033    
034            /**
035             * Creates a shallow clone of this model instance.
036             *
037             * @return the shallow clone of this model instance
038             */
039            public Object clone();
040    
041            /**
042             * Returns the expando bridge for this model instance.
043             *
044             * @return the expando bridge for this model instance
045             */
046            @Override
047            public ExpandoBridge getExpandoBridge();
048    
049            public Map<String, Object> getModelAttributes();
050    
051            /**
052             * Returns the primary key of this model instance.
053             *
054             * @return the primary key of this model instance
055             */
056            @Override
057            public Serializable getPrimaryKeyObj();
058    
059            /**
060             * Returns <code>true</code> if this model instance was retrieved from the
061             * entity cache.
062             *
063             * @return <code>true</code> if this model instance was retrieved from the
064             *         entity cache; <code>false</code> otherwise
065             * @see    #setCachedModel(boolean)
066             */
067            public boolean isCachedModel();
068    
069            /**
070             * Returns <code>true</code> if this model instance is escaped.
071             *
072             * @return <code>true</code> if this model instance is escaped;
073             *         <code>false</code> otherwise
074             */
075            public boolean isEscapedModel();
076    
077            /**
078             * Returns <code>true</code> if this model instance does not yet exist in
079             * the database.
080             *
081             * @return <code>true</code> if this model instance does not yet exist in
082             *         the database; <code>false</code> otherwise
083             */
084            public boolean isNew();
085    
086            /**
087             * Reset all original fields to current values.
088             */
089            public void resetOriginalValues();
090    
091            /**
092             * Sets whether this model instance was retrieved from the entity cache.
093             *
094             * @param cachedModel whether this model instance was retrieved from the
095             *        entity cache
096             * @see   com.liferay.portal.kernel.dao.orm.EntityCache
097             */
098            public void setCachedModel(boolean cachedModel);
099    
100            /**
101             * Sets the expando bridge attributes for this model instance to the
102             * attributes stored in the service context.
103             *
104             * @param serviceContext the service context
105             * @see   com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes(
106             *        )
107             */
108            public void setExpandoBridgeAttributes(ServiceContext serviceContext);
109    
110            public void setModelAttributes(Map<String, Object> attributes);
111    
112            /**
113             * Sets whether this model instance does not yet exist in the database.
114             *
115             * @param n whether this model instance does not yet exist in the database
116             */
117            public void setNew(boolean n);
118    
119            /**
120             * Sets the primary key of this model instance.
121             *
122             * @param primaryKeyObj the primary key of this model instance
123             */
124            @Override
125            public void setPrimaryKeyObj(Serializable primaryKeyObj);
126    
127            /**
128             * Returns a cache model object for this entity used by entity cache.
129             *
130             * @return the cache model object
131             */
132            public CacheModel<T> toCacheModel();
133    
134            /**
135             * Returns a copy of this entity as an escaped model instance by wrapping it
136             * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}.
137             *
138             * @return the escaped model instance
139             * @see    com.liferay.portal.kernel.bean.AutoEscapeBeanHandler
140             */
141            public T toEscapedModel();
142    
143            public T toUnescapedModel();
144    
145            /**
146             * Returns the XML representation of this model instance.
147             *
148             * @return the XML representation of this model instance
149             */
150            public String toXmlString();
151    
152    }