001 /** 002 * Copyright (c) 2000-2010 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> 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 a copy of this entity as an escaped model instance by wrapping it 122 * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}. 123 * 124 * @return the escaped model instance 125 * @see com.liferay.portal.kernel.bean.AutoEscapeBeanHandler 126 */ 127 public T toEscapedModel(); 128 129 /** 130 * Gets the XML representation of this model instance. 131 * 132 * @return the XML representation of this model instance 133 */ 134 public String toXmlString(); 135 136 }