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